001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: *
021: * $Id: PagedSession.java,v 1.3 2007-10-19 10:05:39 sinisa Exp $
022: */
023:
024: package com.lutris.appserver.server.sessionEnhydra;
025:
026: import java.io.Serializable;
027:
028: import com.lutris.appserver.server.session.SessionException;
029: import com.lutris.appserver.server.user.User;
030:
031: /**
032: * PagedSession requires that all session data and the user
033: * associated with the session be serializable.
034: *
035: * @version $Revision: 1.3 $
036: * @author Kyle Clark
037: * @see PagedSessionHome
038: */
039: public class PagedSession extends BasicSession {
040:
041: // Need the following constructor in order to serialize.
042: public PagedSession() {
043: }
044:
045: /**
046: * Construct a new session. Only called by
047: * <CODE>PagedSessionHome</CODE>.
048: *
049: * @param sessionManager The session manager that will manage this session.
050: * @param sessionKey The unique session key associated with the session.
051: */
052: protected PagedSession(StandardSessionManager sessionManager,
053: String sessionKey) {
054: super (sessionManager, sessionKey, new PagedSessionData());
055: }
056:
057: /**
058: * Ensures that the user associated with the session is serializable.<p>
059: *
060: * @param user
061: * the user object to associate with the session.
062: * @exception SessionException
063: * if the user cannot be associated with the session.
064: */
065: public void setUser(User user) throws SessionException {
066: /* Alex
067: *
068: * if (!(user instanceof Serializable)) {
069: throw new SessionException("Paged session user must be serializable.");
070: }*/
071: super .setUser(user);
072: }
073:
074: /**
075: * Called before the session is paged to disk.
076: * Returns the transient data that should be restored
077: * when the session is read from disk.
078: *
079: * @param data
080: * array of transient data objects.
081: * @see #restoreTransientData
082: */
083: Object[] getTransientData() {
084: Object[] transientData = new Object[1];
085: transientData[0] = sessionManager;
086: return transientData;
087: }
088:
089: /**
090: * Called when the session is paged back into memory.
091: * Allows it to restore references to the transient
092: * data associated with the session.
093: *
094: * @param data
095: * array of transient data objects.
096: * @see #getTransientData
097: */
098: void restoreTransientData(Object[] data) {
099: this .sessionManager = (StandardSessionManager) data[0];
100: }
101:
102: }
|