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.BasePortalLifecycle;
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 extends BasePortalLifecycle {
34
35 public PortalSessionCreator(HttpSessionEvent httpSessionEvent) {
36 _httpSessionEvent = httpSessionEvent;
37
38 registerPortalLifecycle(METHOD_INIT);
39 }
40
41 protected void doPortalDestroy() {
42 }
43
44 protected void doPortalInit() {
45 if (PropsValues.SESSION_DISABLED) {
46 return;
47 }
48
49 HttpSession session = _httpSessionEvent.getSession();
50
51 try {
52 PortalSessionContext.put(session.getId(), session);
53 }
54 catch (IllegalStateException ise) {
55 if (_log.isWarnEnabled()) {
56 _log.warn(ise, ise);
57 }
58 }
59
60
62 try {
63 EventsProcessorUtil.process(
64 PropsKeys.SERVLET_SESSION_CREATE_EVENTS,
65 PropsValues.SERVLET_SESSION_CREATE_EVENTS, session);
66 }
67 catch (ActionException ae) {
68 _log.error(ae, ae);
69 }
70 }
71
72 private static Log _log = LogFactoryUtil.getLog(
73 PortalSessionCreator.class);
74
75 private HttpSessionEvent _httpSessionEvent;
76
77 }