001
014
015 package com.liferay.portal.servlet;
016
017 import com.liferay.portal.kernel.cache.Lifecycle;
018 import com.liferay.portal.kernel.cache.ThreadLocalCacheManager;
019 import com.liferay.portal.kernel.servlet.filters.compoundsessionid.CompoundSessionIdHttpSession;
020 import com.liferay.portal.kernel.servlet.filters.compoundsessionid.CompoundSessionIdSplitterUtil;
021
022 import javax.servlet.http.HttpSession;
023 import javax.servlet.http.HttpSessionEvent;
024 import javax.servlet.http.HttpSessionListener;
025
026
029 public class PortalSessionListener implements HttpSessionListener {
030
031 public void sessionCreated(HttpSessionEvent httpSessionEvent) {
032 if (CompoundSessionIdSplitterUtil.hasSessionDelimiter()) {
033 CompoundSessionIdHttpSession compoundSessionIdHttpSession =
034 new CompoundSessionIdHttpSession(
035 httpSessionEvent.getSession());
036
037 httpSessionEvent = new HttpSessionEvent(
038 compoundSessionIdHttpSession);
039 }
040
041 new PortalSessionCreator(httpSessionEvent);
042
043 HttpSession session = httpSessionEvent.getSession();
044
045 session.setAttribute(
046 PortalSessionActivationListener.class.getName(),
047 PortalSessionActivationListener.getInstance());
048 }
049
050 public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
051 if (CompoundSessionIdSplitterUtil.hasSessionDelimiter()) {
052 CompoundSessionIdHttpSession compoundSessionIdHttpSession =
053 new CompoundSessionIdHttpSession(
054 httpSessionEvent.getSession());
055
056 httpSessionEvent = new HttpSessionEvent(
057 compoundSessionIdHttpSession);
058 }
059
060 new PortalSessionDestroyer(httpSessionEvent);
061
062 ThreadLocalCacheManager.clearAll(Lifecycle.SESSION);
063 }
064
065 }