1
22
23 package com.liferay.util.servlet;
24
25 import com.liferay.portal.kernel.util.ServerDetector;
26
27 import java.util.Map;
28
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpServletRequestWrapper;
31 import javax.servlet.http.HttpSession;
32
33
40 public class SharedSessionServletRequest extends HttpServletRequestWrapper {
41
42 public SharedSessionServletRequest(
43 HttpServletRequest request, Map<String, Object> sharedSessionAttributes,
44 boolean shared) {
45
46 super(request);
47
48 _sharedSessionAttributes = sharedSessionAttributes;
49
50 _session = getSharedSessionWrapper(request.getSession());
51 _shared = shared;
52 }
53
54 public HttpSession getSession() {
55 if (_shared) {
56 return _session;
57 }
58 else {
59 return getSharedSessionWrapper(super.getSession());
60 }
61 }
62
63 public HttpSession getSession(boolean create) {
64 if (_shared) {
65 return _session;
66 }
67 else {
68 return getSharedSessionWrapper(super.getSession(create));
69 }
70 }
71
72 protected HttpSession getSharedSessionWrapper(HttpSession session) {
73 if (!ServerDetector.isJOnAS() && ServerDetector.isJetty()) {
74 return new JettySharedSessionWrapper(
75 session, _sharedSessionAttributes);
76 }
77 else {
78 return new SharedSessionWrapper(session, _sharedSessionAttributes);
79 }
80 }
81
82 private HttpSession _session;
83 private Map<String, Object> _sharedSessionAttributes;
84 private boolean _shared;
85
86 }