%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.services.session.SessionListener |
|
|
1 | package org.apache.turbine.services.session; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2004 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
17 | */ |
|
18 | ||
19 | import java.io.Serializable; |
|
20 | import javax.servlet.http.HttpSessionActivationListener; |
|
21 | import javax.servlet.http.HttpSessionEvent; |
|
22 | import javax.servlet.http.HttpSessionListener; |
|
23 | ||
24 | /** |
|
25 | * This class is a listener for both session creation and destruction, |
|
26 | * and for session activation and passivation. It must be configured |
|
27 | * via your web application's <code>web.xml</code> deployment |
|
28 | * descriptor as follows for the container to call it: |
|
29 | * |
|
30 | * <blockquote><code><pre> |
|
31 | * <listener> |
|
32 | * <listener-class> |
|
33 | * org.apache.turbine.session.SessionListener |
|
34 | * </listener-class> |
|
35 | * </listener> |
|
36 | * </pre></code></blockquote> |
|
37 | * |
|
38 | * <code><listener></code> elemements can occur between |
|
39 | * <code><context-param></code> and <code><servlet></code> |
|
40 | * elements in your deployment descriptor. |
|
41 | * |
|
42 | * The {@link #sessionCreated(HttpSessionEvent)} callback will |
|
43 | * automatically add an instance of this listener to any newly created |
|
44 | * <code>HttpSession</code> for detection of session passivation and |
|
45 | * re-activation. |
|
46 | * |
|
47 | * @since 2.3 |
|
48 | * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a> |
|
49 | * @author <a href="mailto:dlr@apache.org">Daniel Rall</a> |
|
50 | * @version $Id: SessionListener.java,v 1.9.2.2 2004/05/20 03:06:50 seade Exp $ |
|
51 | * @see javax.servlet.http.HttpSessionListener |
|
52 | */ |
|
53 | 0 | public class SessionListener |
54 | implements HttpSessionListener, HttpSessionActivationListener, Serializable |
|
55 | { |
|
56 | // ---- HttpSessionListener implementation ----------------------------- |
|
57 | ||
58 | /** |
|
59 | * Called by the servlet container when a new session is created |
|
60 | * |
|
61 | * @param event Session creation event. |
|
62 | */ |
|
63 | public void sessionCreated(HttpSessionEvent event) |
|
64 | { |
|
65 | 0 | TurbineSession.addSession(event.getSession()); |
66 | 0 | event.getSession().setAttribute(getClass().getName(), this); |
67 | 0 | } |
68 | ||
69 | /** |
|
70 | * Called by the servlet container when a session is destroyed |
|
71 | * |
|
72 | * @param event Session destruction event. |
|
73 | */ |
|
74 | public void sessionDestroyed(HttpSessionEvent event) |
|
75 | { |
|
76 | 0 | TurbineSession.removeSession(event.getSession()); |
77 | 0 | } |
78 | ||
79 | ||
80 | // ---- HttpSessionActivationListener implementation ------------------- |
|
81 | ||
82 | /** |
|
83 | * Called by the servlet container when an existing session is |
|
84 | * (re-)activated. |
|
85 | * |
|
86 | * @param event Session activation event. |
|
87 | */ |
|
88 | public void sessionDidActivate(HttpSessionEvent event) |
|
89 | { |
|
90 | 0 | TurbineSession.addSession(event.getSession()); |
91 | 0 | } |
92 | ||
93 | /** |
|
94 | * Called by the servlet container when a an existing session is |
|
95 | * passivated. |
|
96 | * |
|
97 | * @param event Session passivation event. |
|
98 | */ |
|
99 | public void sessionWillPassivate(HttpSessionEvent event) |
|
100 | { |
|
101 | 0 | TurbineSession.removeSession(event.getSession()); |
102 | 0 | } |
103 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |