KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > appserver > server > sessionEnhydra > persistent > PersistentSessionUserTable


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

24
25 package com.lutris.appserver.server.sessionEnhydra.persistent;
26
27 import java.util.Enumeration JavaDoc;
28
29 import com.lutris.appserver.server.session.SessionException;
30 import com.lutris.appserver.server.sessionEnhydra.StandardSessionUserTable;
31 import com.lutris.appserver.server.user.User;
32 import com.lutris.util.Config;
33 import com.lutris.util.ConfigException;
34
35 /**
36  * Table used by StandardSessionManager to cross reference <CODE>User</CODE>
37  * objects and sessions.<p>
38  *
39  * @version $Revision: 1.2 $
40  * @author Kyle Clark
41  */

42 public class PersistentSessionUserTable implements StandardSessionUserTable {
43
44     String JavaDoc dbName = null;
45
46     /**
47      * @param config
48      * configuration options for this table - currently ignored.
49      */

50     public PersistentSessionUserTable(Config config) throws ConfigException {
51         // This is a bit messy....
52
dbName = PersistentSessionHome.getDatabaseName(config);
53     }
54
55     /**
56      * Add a session key to the user to session xref table.
57      *
58      * @param session
59      * The session key.
60      * @param user
61      * the user to associated with the session key.
62      */

63     public void add(String JavaDoc sessionKey, User user) {
64         // noop - maintained in DB
65
}
66
67     /**
68      * Remove a session from the user to session mapping table.
69      * If the session is not it the table, it is ignored.
70      *
71      * @param session The session object, with the user already
72      * filled in.
73      */

74     public void remove(String JavaDoc sessionKey, User user) {
75         // noop - maintained in DB
76
}
77
78     /**
79      * Remove a session from the user to session mapping table.
80      * If the session is not it the table, it is ignored.
81      *
82      * @param session The session object, with the user already
83      * filled in.
84      */

85     public void remove(String JavaDoc sessionKey) {
86         // noop - maintained in DB
87
}
88
89     /**
90      * Get the number of sessions for a user.
91      *
92      * @param user The user object to check for.
93      * @return The count of the number of sessions associated with this
94      * user.
95      * @exception SessionException if an error occurs.
96      */

97     public int numSessions(User user) throws SessionException {
98         try {
99             UserNumSessionsQuery q = new UserNumSessionsQuery(user);
100             Integer JavaDoc num = (Integer JavaDoc)DBUtil.dbQuery(q, dbName);
101             return num.intValue();
102         } catch (Exception JavaDoc e) {
103             throw new SessionException(e);
104         }
105     }
106
107     /**
108      * Returns the session keys associated with a particular user.
109      *
110      * @param user The user object to check for.
111      * @return An enumeration of the session keys associated
112      * with the user.
113      * @exception SessionException if an error occurs.
114      */

115     public Enumeration JavaDoc getSessionKeys(User user) throws SessionException {
116         try {
117             UserSessionsQuery q = new UserSessionsQuery(user);
118             return (Enumeration JavaDoc)DBUtil.dbQuery(q, dbName);
119         } catch (Exception JavaDoc e) {
120             throw new SessionException(e);
121         }
122     }
123
124     /**
125      * Shutdown this session user table as required. The session
126      * user table should not be used after this method has been called
127      */

128     public void shutdown() {
129         // noop
130
}
131
132 }
133
Popular Tags