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(httpSessionEvent.getSession());
035
036 httpSessionEvent = new HttpSessionEvent(
037 compoundSessionIdHttpSession);
038 }
039
040 new PortalSessionCreator(httpSessionEvent);
041
042 HttpSession session = httpSessionEvent.getSession();
043
044 session.setAttribute(
045 PortalSessionActivationListener.class.getName(),
046 PortalSessionActivationListener.getInstance());
047 }
048
049 public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
050 if (CompoundSessionIdSplitterUtil.hasSessionDelimiter()) {
051 CompoundSessionIdHttpSession compoundSessionIdHttpSession =
052 new CompoundSessionIdHttpSession(httpSessionEvent.getSession());
053
054 httpSessionEvent = new HttpSessionEvent(
055 compoundSessionIdHttpSession);
056 }
057
058 new PortalSessionDestroyer(httpSessionEvent);
059
060 ThreadLocalCacheManager.clearAll(Lifecycle.SESSION);
061 }
062
063 }