1
14
15 package com.liferay.portal.servlet;
16
17 import com.liferay.portal.events.EventsProcessorUtil;
18 import com.liferay.portal.kernel.events.ActionException;
19 import com.liferay.portal.kernel.log.Log;
20 import com.liferay.portal.kernel.log.LogFactoryUtil;
21 import com.liferay.portal.kernel.util.PortalInitable;
22 import com.liferay.portal.kernel.util.PropsKeys;
23 import com.liferay.portal.util.PropsValues;
24
25 import javax.servlet.http.HttpSession;
26 import javax.servlet.http.HttpSessionEvent;
27
28
33 public class PortalSessionCreator implements PortalInitable {
34
35 public PortalSessionCreator(HttpSessionEvent event) {
36 _event = event;
37 }
38
39 public void portalInit() {
40 if (PropsValues.SESSION_DISABLED) {
41 return;
42 }
43
44 HttpSession session = _event.getSession();
45
46 try {
47 PortalSessionContext.put(session.getId(), session);
48 }
49 catch (IllegalStateException ise) {
50 if (_log.isWarnEnabled()) {
51 _log.warn(ise, ise);
52 }
53 }
54
55
57 try {
58 EventsProcessorUtil.process(
59 PropsKeys.SERVLET_SESSION_CREATE_EVENTS,
60 PropsValues.SERVLET_SESSION_CREATE_EVENTS, session);
61 }
62 catch (ActionException ae) {
63 _log.error(ae, ae);
64 }
65 }
66
67 private static Log _log = LogFactoryUtil.getLog(
68 PortalSessionCreator.class);
69
70 private HttpSessionEvent _event;
71
72 }