001
014
015 package com.liferay.portal.servlet;
016
017 import com.liferay.portal.events.EventsProcessorUtil;
018 import com.liferay.portal.kernel.events.ActionException;
019 import com.liferay.portal.kernel.log.Log;
020 import com.liferay.portal.kernel.log.LogFactoryUtil;
021 import com.liferay.portal.kernel.util.BasePortalLifecycle;
022 import com.liferay.portal.kernel.util.PropsKeys;
023 import com.liferay.portal.util.PropsValues;
024
025 import javax.servlet.http.HttpSession;
026 import javax.servlet.http.HttpSessionEvent;
027
028
031 public class PortalSessionCreator extends BasePortalLifecycle {
032
033 public PortalSessionCreator(HttpSessionEvent httpSessionEvent) {
034 _httpSessionEvent = httpSessionEvent;
035
036 registerPortalLifecycle();
037 }
038
039 protected void doPortalDestroy() {
040 }
041
042 protected void doPortalInit() {
043 if (PropsValues.SESSION_DISABLED) {
044 return;
045 }
046
047 HttpSession session = _httpSessionEvent.getSession();
048
049 try {
050 PortalSessionContext.put(session.getId(), session);
051 }
052 catch (IllegalStateException ise) {
053 if (_log.isWarnEnabled()) {
054 _log.warn(ise, ise);
055 }
056 }
057
058
059
060 try {
061 EventsProcessorUtil.process(
062 PropsKeys.SERVLET_SESSION_CREATE_EVENTS,
063 PropsValues.SERVLET_SESSION_CREATE_EVENTS, session);
064 }
065 catch (ActionException ae) {
066 _log.error(ae, ae);
067 }
068 }
069
070 private static Log _log = LogFactoryUtil.getLog(
071 PortalSessionCreator.class);
072
073 private HttpSessionEvent _httpSessionEvent;
074
075 }