KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mortbay > jetty > servlet > SessionManager


1 // ========================================================================
2
// $Id: SessionManager.java,v 1.18 2005/03/15 10:03:58 gregwilkins Exp $
3
// Copyright 1996-2004 Mort Bay Consulting Pty. Ltd.
4
// ------------------------------------------------------------------------
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
// ========================================================================
15

16 package org.mortbay.jetty.servlet;
17
18 import java.io.Serializable JavaDoc;
19 import java.util.EventListener JavaDoc;
20
21 import javax.servlet.http.Cookie JavaDoc;
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23 import javax.servlet.http.HttpSession JavaDoc;
24
25 import org.mortbay.util.LifeCycle;
26
27     
28 /* --------------------------------------------------------------------- */
29 /** Session Manager.
30  * The API required to manage sessions for a servlet context.
31  *
32  * @version $Id: SessionManager.java,v 1.18 2005/03/15 10:03:58 gregwilkins Exp $
33  * @author Greg Wilkins
34  */

35 public interface SessionManager extends LifeCycle, Serializable JavaDoc
36 {
37     /* ------------------------------------------------------------ */
38     /** Session cookie name.
39      * Defaults to JSESSIONID, but can be set with the
40      * org.mortbay.jetty.servlet.SessionCookie system property.
41      */

42     public final static String JavaDoc __SessionCookie=
43         System.getProperty("org.mortbay.jetty.servlet.SessionCookie","JSESSIONID");
44     
45     /* ------------------------------------------------------------ */
46     /** Session URL parameter name.
47      * Defaults to jsessionid, but can be set with the
48      * org.mortbay.jetty.servlet.SessionURL system property.
49      */

50     public final static String JavaDoc __SessionURL =
51         System.getProperty("org.mortbay.jetty.servlet.SessionURL","jsessionid");
52
53     final static String JavaDoc __SessionUrlPrefix=";"+__SessionURL+"=";
54
55     /* ------------------------------------------------------------ */
56     /** Session Domain.
57      * If this property is set as a ServletContext InitParam, then it is
58      * used as the domain for session cookies. If it is not set, then
59      * no domain is specified for the session cookie.
60      */

61     public final static String JavaDoc __SessionDomain=
62         "org.mortbay.jetty.servlet.SessionDomain";
63     
64     /* ------------------------------------------------------------ */
65     /** Session Path.
66      * If this property is set as a ServletContext InitParam, then it is
67      * used as the path for the session cookie. If it is not set, then
68      * the context path is used as the path for the cookie.
69      */

70     public final static String JavaDoc __SessionPath=
71         "org.mortbay.jetty.servlet.SessionPath";
72     
73     /* ------------------------------------------------------------ */
74     /** Session Max Age.
75      * If this property is set as a ServletContext InitParam, then it is
76      * used as the max age for the session cookie. If it is not set, then
77      * a max age of -1 is used.
78      */

79     public final static String JavaDoc __MaxAge=
80         "org.mortbay.jetty.servlet.MaxAge";
81     
82     /* ------------------------------------------------------------ */
83     public void initialize(ServletHandler handler);
84     
85     /* ------------------------------------------------------------ */
86     public HttpSession JavaDoc getHttpSession(String JavaDoc id);
87     
88     /* ------------------------------------------------------------ */
89     public HttpSession JavaDoc newHttpSession(HttpServletRequest JavaDoc request);
90
91     /* ------------------------------------------------------------ */
92     /** @return true if session cookies should be secure
93      */

94     public boolean getSecureCookies();
95
96     /* ------------------------------------------------------------ */
97     /** @return true if session cookies should be httponly (microsoft extension)
98      */

99     public boolean getHttpOnly();
100
101     /* ------------------------------------------------------------ */
102     public int getMaxInactiveInterval();
103
104     /* ------------------------------------------------------------ */
105     public void setMaxInactiveInterval(int seconds);
106
107     /* ------------------------------------------------------------ */
108     /** Add an event listener.
109      * @param listener An Event Listener. Individual SessionManagers
110      * implemetations may accept arbitrary listener types, but they
111      * are expected to at least handle
112      * HttpSessionActivationListener,
113      * HttpSessionAttributeListener,
114      * HttpSessionBindingListener,
115      * HttpSessionListener
116      * @exception IllegalArgumentException If an unsupported listener
117      * is passed.
118      */

119     public void addEventListener(EventListener JavaDoc listener)
120         throws IllegalArgumentException JavaDoc;
121     
122     /* ------------------------------------------------------------ */
123     public void removeEventListener(EventListener JavaDoc listener);
124     
125
126     /* ------------------------------------------------------------ */
127     /** Get a Cookie for a session.
128      * @param session
129      * @return
130      */

131     public Cookie JavaDoc getSessionCookie(HttpSession JavaDoc session,boolean requestIsSecure);
132     
133     
134     /* ------------------------------------------------------------ */
135     /* ------------------------------------------------------------ */
136     public interface Session extends HttpSession JavaDoc
137     {
138         /* ------------------------------------------------------------ */
139         public boolean isValid();
140
141         /* ------------------------------------------------------------ */
142         public void access();
143     }
144
145
146 }
147
Popular Tags