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.PortalInitable;
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 implements PortalInitable {
032
033 public PortalSessionCreator(HttpSessionEvent event) {
034 _event = event;
035 }
036
037 public void portalInit() {
038 if (PropsValues.SESSION_DISABLED) {
039 return;
040 }
041
042 HttpSession session = _event.getSession();
043
044 try {
045 PortalSessionContext.put(session.getId(), session);
046 }
047 catch (IllegalStateException ise) {
048 if (_log.isWarnEnabled()) {
049 _log.warn(ise, ise);
050 }
051 }
052
053
054
055 try {
056 EventsProcessorUtil.process(
057 PropsKeys.SERVLET_SESSION_CREATE_EVENTS,
058 PropsValues.SERVLET_SESSION_CREATE_EVENTS, session);
059 }
060 catch (ActionException ae) {
061 _log.error(ae, ae);
062 }
063 }
064
065 private static Log _log = LogFactoryUtil.getLog(
066 PortalSessionCreator.class);
067
068 private HttpSessionEvent _event;
069
070 }