%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.container.session.PortletApplicationSessionMonitorImpl |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.jetspeed.container.session; |
|
18 | ||
19 | import javax.servlet.http.HttpSession; |
|
20 | import javax.servlet.http.HttpSessionBindingEvent; |
|
21 | import javax.servlet.http.HttpSessionEvent; |
|
22 | ||
23 | import org.apache.jetspeed.container.session.PortalSessionsManager; |
|
24 | import org.apache.jetspeed.container.session.PortletApplicationSessionMonitor; |
|
25 | import org.apache.jetspeed.services.JetspeedPortletServices; |
|
26 | import org.apache.jetspeed.services.PortletServices; |
|
27 | ||
28 | /** |
|
29 | * PortletApplicationSessionMonitorImpl |
|
30 | * |
|
31 | * @author <a href="mailto:ate@douma.nu">Ate Douma</a> |
|
32 | * @version $Id: $ |
|
33 | */ |
|
34 | public class PortletApplicationSessionMonitorImpl implements PortletApplicationSessionMonitor |
|
35 | { |
|
36 | private static final long serialVersionUID = -6729032046828426324L; |
|
37 | ||
38 | private String contextPath; |
|
39 | private String portalSessionId; |
|
40 | private long portalSessionKey; |
|
41 | private transient HttpSession session; |
|
42 | private boolean forceInvalidate; |
|
43 | ||
44 | public PortletApplicationSessionMonitorImpl(String contextPath, String portalSessionId, long portalSessionKey) |
|
45 | { |
|
46 | 0 | this(contextPath, portalSessionId, portalSessionKey, true); |
47 | 0 | } |
48 | ||
49 | public PortletApplicationSessionMonitorImpl(String contextPath, String portalSessionId, long portalSessionKey, boolean forceInvalidate) |
|
50 | 0 | { |
51 | 0 | this.contextPath = contextPath; |
52 | 0 | this.portalSessionId = portalSessionId; |
53 | 0 | this.portalSessionKey = portalSessionKey; |
54 | 0 | this.forceInvalidate = forceInvalidate; |
55 | 0 | } |
56 | ||
57 | /* (non-Javadoc) |
|
58 | * @see org.apache.jetspeed.container.session.PortletApplicationSessionMonitor#getPortalSessionKey() |
|
59 | */ |
|
60 | public long getPortalSessionKey() |
|
61 | { |
|
62 | 0 | return portalSessionKey; |
63 | } |
|
64 | ||
65 | /* (non-Javadoc) |
|
66 | * @see org.apache.jetspeed.container.session.PortletApplicationSessionMonitor#getPortalSessionId() |
|
67 | */ |
|
68 | public String getPortalSessionId() |
|
69 | { |
|
70 | 0 | return portalSessionId; |
71 | } |
|
72 | ||
73 | public HttpSession getSession() |
|
74 | { |
|
75 | 0 | return session; |
76 | } |
|
77 | ||
78 | /* (non-Javadoc) |
|
79 | * @see org.apache.jetspeed.container.session.PortletApplicationSessionMonitor#getContextPath() |
|
80 | */ |
|
81 | public String getContextPath() |
|
82 | { |
|
83 | 0 | return contextPath; |
84 | } |
|
85 | ||
86 | /* (non-Javadoc) |
|
87 | * @see org.apache.jetspeed.container.session.PortletApplicationSessionMonitor#invalidateSession() |
|
88 | */ |
|
89 | public void invalidateSession() |
|
90 | { |
|
91 | 0 | if ( session != null ) |
92 | { |
|
93 | 0 | HttpSession thisSession = session; |
94 | 0 | session = null; |
95 | 0 | if (forceInvalidate) |
96 | { |
|
97 | try |
|
98 | { |
|
99 | 0 | thisSession.invalidate(); |
100 | } |
|
101 | 0 | catch (Exception ise) |
102 | { |
|
103 | // ignore |
|
104 | 0 | } |
105 | } |
|
106 | } |
|
107 | 0 | } |
108 | ||
109 | /* (non-Javadoc) |
|
110 | * @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent) |
|
111 | */ |
|
112 | public void valueBound(HttpSessionBindingEvent event) |
|
113 | { |
|
114 | 0 | this.session = event.getSession(); |
115 | 0 | } |
116 | ||
117 | /* (non-Javadoc) |
|
118 | * @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(javax.servlet.http.HttpSessionBindingEvent) |
|
119 | */ |
|
120 | public void valueUnbound(HttpSessionBindingEvent event) |
|
121 | { |
|
122 | 0 | if ( session != null ) |
123 | { |
|
124 | 0 | PortalSessionsManager manager = getManager(); |
125 | 0 | if ( manager != null ) |
126 | { |
|
127 | 0 | manager.sessionDestroyed(this); |
128 | } |
|
129 | 0 | session = null; |
130 | } |
|
131 | 0 | } |
132 | ||
133 | /* (non-Javadoc) |
|
134 | * @see javax.servlet.http.HttpSessionActivationListener#sessionDidActivate(javax.servlet.http.HttpSessionEvent) |
|
135 | */ |
|
136 | public void sessionDidActivate(HttpSessionEvent event) |
|
137 | { |
|
138 | 0 | this.session = event.getSession(); |
139 | 0 | PortalSessionsManager manager = getManager(); |
140 | 0 | if ( manager != null ) |
141 | { |
|
142 | 0 | manager.sessionDidActivate(this); |
143 | } |
|
144 | 0 | } |
145 | ||
146 | /* (non-Javadoc) |
|
147 | * @see javax.servlet.http.HttpSessionActivationListener#sessionWillPassivate(javax.servlet.http.HttpSessionEvent) |
|
148 | */ |
|
149 | public void sessionWillPassivate(HttpSessionEvent event) |
|
150 | { |
|
151 | 0 | PortalSessionsManager manager = getManager(); |
152 | 0 | if ( manager != null ) |
153 | { |
|
154 | 0 | manager.sessionWillPassivate(this); |
155 | } |
|
156 | 0 | session = null; |
157 | 0 | } |
158 | ||
159 | private PortalSessionsManager getManager() |
|
160 | { |
|
161 | 0 | PortletServices services = JetspeedPortletServices.getSingleton(); |
162 | 0 | if (services != null) |
163 | { |
|
164 | 0 | return (PortalSessionsManager)services.getService(PortalSessionsManager.SERVICE_NAME); |
165 | } |
|
166 | 0 | return null; |
167 | } |
|
168 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |