KickJava   Java API By Example, From Geeks To Geeks.

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


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: PagedSession.java,v 1.2 2005/03/24 10:51:20 slobodan Exp $
23  */

24
25 package com.lutris.appserver.server.sessionEnhydra;
26
27 import java.io.Serializable JavaDoc;
28
29 import com.lutris.appserver.server.session.SessionException;
30 import com.lutris.appserver.server.user.User;
31
32 /**
33  * PagedSession requires that all session data and the user
34  * associated with the session be serializable.
35  *
36  * @version $Revision: 1.2 $
37  * @author Kyle Clark
38  * @see PagedSessionHome
39  */

40 public class PagedSession extends BasicSession {
41
42     // Need the following constructor in order to serialize.
43
public PagedSession() {
44     }
45     
46     /**
47      * Construct a new session. Only called by
48      * <CODE>PagedSessionHome</CODE>.
49      *
50      * @param sessionManager The session manager that will manage this session.
51      * @param sessionKey The unique session key associated with the session.
52      */

53     protected PagedSession(StandardSessionManager sessionManager,
54                            String JavaDoc sessionKey) {
55         super(sessionManager, sessionKey, new PagedSessionData());
56     }
57
58     /**
59      * Ensures that the user associated with the session is serializable.<p>
60      *
61      * @param user
62      * the user object to associate with the session.
63      * @exception SessionException
64      * if the user cannot be associated with the session.
65      */

66     public void setUser(User user) throws SessionException {
67         if (!(user instanceof Serializable JavaDoc)) {
68             throw new SessionException("Paged session user must be serializable.");
69         }
70         super.setUser(user);
71     }
72
73     /**
74      * Called before the session is paged to disk.
75      * Returns the transient data that should be restored
76      * when the session is read from disk.
77      *
78      * @param data
79      * array of transient data objects.
80      * @see #restoreTransientData
81      */

82     Object JavaDoc [] getTransientData() {
83         Object JavaDoc [] transientData = new Object JavaDoc[1];
84         transientData[0] = sessionManager;
85         return transientData;
86     }
87
88     /**
89      * Called when the session is paged back into memory.
90      * Allows it to restore references to the transient
91      * data associated with the session.
92      *
93      * @param data
94      * array of transient data objects.
95      * @see #getTransientData
96      */

97     void restoreTransientData(Object JavaDoc [] data) {
98         this.sessionManager = (StandardSessionManager)data[0];
99     }
100
101 }
102
103
104
105
106
Popular Tags