KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > appserver > server > sessionEnhydra > SimpleServletSessionManager


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: SimpleServletSessionManager.java,v 1.3 2005/03/24 10:51:20 slobodan Exp $
22  *
23  * formatted with JxBeauty (c) johann.langhofer@nextra.at
24  */

25
26
27 package com.lutris.appserver.server.sessionEnhydra;
28
29 import java.util.Date JavaDoc;
30
31 import javax.servlet.http.HttpSession JavaDoc;
32
33 import com.lutris.appserver.server.Application;
34 import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
35 import com.lutris.appserver.server.session.Session;
36 import com.lutris.appserver.server.session.SessionException;
37 import com.lutris.logging.LogChannel;
38 import com.lutris.util.Config;
39 import com.lutris.util.ConfigException;
40
41 /**
42  * This session manager extends <code>StandardSessionManager</code>
43  * it obtains SessionId from the servletContainer and uses it to
44  * create a new Enhydra session
45  *
46  * @version $Revision: 1.3 $
47  * @author DT
48  */

49 public class SimpleServletSessionManager extends StandardSessionManager {
50
51     public SimpleServletSessionManager (){
52         super();
53     }
54
55   /**
56    * Creates a new <code>SessionManager</code> object.
57    * This constructor will first looks for the session manager
58    * configuration parameters that have the specified configuration
59    * prefix prepended to the standard session manager configuration
60    * option.<p>
61    *
62    * @param app the application associate with this session
63    * manager.
64    * @param config Object parsed from configuration file. This should be
65    * for the section constaining the session manager configuration.
66    * @param sessionMgrLogChannel If not <CODE>null</CODE>, channel to
67    * log debugging information to.
68    * @exception ConfigException signifies a problem in the
69    * configuration file.
70    * @exception SessionException
71    * if all classes (Home and UserTable) couldn't be loaded
72    * by the session manager.
73    */

74   public SimpleServletSessionManager (Application application, Config config,
75                  LogChannel sessionMgrLogChannel)
76     throws ConfigException, SessionException {
77     super(application,config,sessionMgrLogChannel);
78   }
79
80     /**
81    * Creates a new <code>SessionManager</code> object.
82    * This constructor will first looks for the session manager
83    * configuration parameters that have the specified configuration
84    * prefix prepended to the standard session manager configuration
85    * option.<p>
86    *
87    * @param app the ClassLoader associate with this application.
88    * @param config Object parsed from configuration file. This should be
89    * for the section constaining the session manager configuration.
90    * @param sessionMgrLogChannel If not <CODE>null</CODE>, channel to
91    * log debugging information to.
92    * @exception ConfigException signifies a problem in the
93    * configuration file.
94    * @exception SessionException
95    * if all classes (Home and UserTable) couldn't be loaded
96    * by the session manager.
97    */

98   public SimpleServletSessionManager (ClassLoader JavaDoc classLoader, Config config,
99                  LogChannel sessionMgrLogChannel) throws ConfigException, SessionException {
100         super(classLoader,config,sessionMgrLogChannel);
101   }
102
103     /**
104    * Create a new <CODE>Session</CODE> object.
105    *
106    * @param comms the HttpPresentationComms object used for geting existing
107    * Session object ID.
108    * @return session The new <code>Session</code> object.
109    * @exception SessionException
110    * if the session cannot be created.
111    * @see Session
112    */

113   public Session JavaDoc createSession (HttpPresentationComms comms) throws SessionException {
114     Session JavaDoc session = null;
115     HttpSession JavaDoc servletSession = comms.request.getHttpServletRequest().getSession();
116     String JavaDoc servletSessionId = servletSession.getId();
117     session = sessionHome.createSession(servletSessionId);
118     int currentSize = sessionHome.size();
119     if (currentSize > maxSessions) {
120       maxSessions = currentSize;
121       maxSessionsDate = new Date JavaDoc();
122     }
123     return session;
124   }
125 }
126
127
128
129
Popular Tags