com.plumtree.uiinfrastructure.web
Class DefaultSessionManager

java.lang.Object
  extended by com.plumtree.uiinfrastructure.web.DefaultSessionManager
All Implemented Interfaces:
ISessionManager

public class DefaultSessionManager
extends java.lang.Object
implements ISessionManager

Title: Session Manager

Description:

Copyright: Copyright (c) 2002

Company: Plumtree

Version:
1.0
Author:
Marc Harrison

Constructor Summary
DefaultSessionManager(java.lang.String keyName)
          Default constructor.
 
Method Summary
 void Abandon()
          Abandon this session at the end of this request so that the Java/.NET session can be reclaimed by the server.
 void Clear()
          Remove all the elements in this session manager.
 boolean ContainsSubSession(java.lang.String key)
          Check if a subsession is already in the subsession table (i.e.
 java.lang.Object GetAttribute(java.lang.String key)
          Get an Attribute from this SessionManager.
 IXPEnumerator GetKeys()
          An IXPEnumertor of all the keys contained in the session manager.
 int GetMaxCount()
          Get the max number of objects that can be placed on this session.
 int GetMaxInactiveInterval()
          Get the max inactive interval until this session should be timed out.
 java.lang.Object GetMostRecentlyAccessedObject()
          Get the most recently accessed Object (by set or get).
 ISessionManager GetSubSession(java.lang.String key)
          Get a sub session.
 long GetTimeStamp(java.lang.String key)
          Get the timestamp of an Attribute from this SessionManager.
 boolean IsAbandoned()
          Check if the underlying Java/.NET session will be abandoned at the end of this request.
 boolean IsNewSession()
          Check if the session is created from the factory.
 void RemoveAttribute(java.lang.String key)
          Remove an attribute from the session manager.
 void RemoveSubSession(java.lang.String subSessionName)
          Remove a subspace from this session.
 java.lang.String SetAttribute(java.lang.Object value)
          Place an object on the session.
 void SetAttribute(java.lang.String key, java.lang.Object value)
          Place an object on the session based on a key.
 void SetAttribute(java.lang.String key, java.lang.Object value, ICacheUpdateListener callback, int timeout)
          Set an attribute with a call back.
 void SetMaxCount(int maxCount)
          Set the max number of objects that can be placed into this session.
 void SetMaxInactiveInterval(int timeOut)
          Have this session manager timeout objects after x number of seconds.
 void SetNewSession(boolean flag)
          Set if the session is new.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSessionManager

public DefaultSessionManager(java.lang.String keyName)
Default constructor.

Parameters:
keyName -
Method Detail

Clear

public void Clear()
Remove all the elements in this session manager. This includes all sub-sessions.

Specified by:
Clear in interface ISessionManager

ContainsSubSession

public boolean ContainsSubSession(java.lang.String key)
Check if a subsession is already in the subsession table (i.e. a subsession will already exist if GetSubSession(key) has been called).

Specified by:
ContainsSubSession in interface ISessionManager
Parameters:
key - The key which the subsession is under.
Returns:
true if the subsession exists.

GetAttribute

public java.lang.Object GetAttribute(java.lang.String key)
Get an Attribute from this SessionManager.

Specified by:
GetAttribute in interface ISessionManager
Parameters:
key - Key to look up the value to return.
Returns:
Object placed on the session manager.
See Also:
SetAttribute

GetKeys

public IXPEnumerator GetKeys()
An IXPEnumertor of all the keys contained in the session manager. This does not include keys in sub-sessions or keys to sub-sessions.

Specified by:
GetKeys in interface ISessionManager
Returns:
A String[] of all the keys contained in the session manager.

GetMaxCount

public int GetMaxCount()
Get the max number of objects that can be placed on this session. This does NOT include sub-sessions.

Specified by:
GetMaxCount in interface ISessionManager
Returns:
The max number of objects this session manager can hold.
See Also:
SetMaxCount

GetMaxInactiveInterval

public int GetMaxInactiveInterval()
Get the max inactive interval until this session should be timed out. 0 or a negative number mean the session will expire with the underlying Java/.NET Session.

Specified by:
GetMaxInactiveInterval in interface ISessionManager
Returns:
When the session will time out.
See Also:
SetMaxInactiveInterval

GetMostRecentlyAccessedObject

public java.lang.Object GetMostRecentlyAccessedObject()
Get the most recently accessed Object (by set or get).

Specified by:
GetMostRecentlyAccessedObject in interface ISessionManager
Returns:
The object that has the newest timestamp.

GetSubSession

public ISessionManager GetSubSession(java.lang.String key)
Get a sub session. This is to provide seperate spaces to place objects in. By grouping objects that belong together in one session it is easier to clean up, debug and maintain.

Specified by:
GetSubSession in interface ISessionManager
Parameters:
key - The key which the subsession is under.
Returns:
The subsession - ISessionManager

GetTimeStamp

public long GetTimeStamp(java.lang.String key)
Get the timestamp of an Attribute from this SessionManager.

Specified by:
GetTimeStamp in interface ISessionManager
Parameters:
key - Key to look up the value to return.
Returns:
long the time stamp of the object placed on the session manager. -1 if there was an error

IsNewSession

public boolean IsNewSession()
Check if the session is created from the factory.

Specified by:
IsNewSession in interface ISessionManager
Returns:
false is the session has been created by a previous call to the session factory. True the session was just created.

RemoveAttribute

public void RemoveAttribute(java.lang.String key)
Remove an attribute from the session manager.

Specified by:
RemoveAttribute in interface ISessionManager
Parameters:
key - The key to remove.

RemoveSubSession

public void RemoveSubSession(java.lang.String subSessionName)
Remove a subspace from this session.

Specified by:
RemoveSubSession in interface ISessionManager
Parameters:
subSessionName -

SetAttribute

public java.lang.String SetAttribute(java.lang.Object value)
Place an object on the session. Key is generated.

Specified by:
SetAttribute in interface ISessionManager
Parameters:
value - The value interested in storing on the session.
Returns:
String used by GetAttribute to get the object

SetAttribute

public void SetAttribute(java.lang.String key,
                         java.lang.Object value)
Place an object on the session based on a key.

Specified by:
SetAttribute in interface ISessionManager
Parameters:
key - The key to place the value under.
value - The value interested in storing on the session.

SetAttribute

public void SetAttribute(java.lang.String key,
                         java.lang.Object value,
                         ICacheUpdateListener callback,
                         int timeout)
Set an attribute with a call back. The callback will be called when the session manager asks for the key from GetAttribute and the timeout has elapsed.

Specified by:
SetAttribute in interface ISessionManager
Parameters:
key - Key on the session
value - The value to place on the session.
callback - Object to call back when time has elapsed.
timeout - Time in seconds before calling the callback.

SetMaxCount

public void SetMaxCount(int maxCount)
Set the max number of objects that can be placed into this session. After the max count is reached the object used last will be removed to make space.

Specified by:
SetMaxCount in interface ISessionManager
Parameters:
maxCount - The max number of objects this session can hold.

SetMaxInactiveInterval

public void SetMaxInactiveInterval(int timeOut)
Have this session manager timeout objects after x number of seconds. 0 or a negative number means all the objects the session manager contains will expire with the underlying Java/.NET Session. NOTE: The session manager and any sub sessions will only time out with the underlying Java/.NET session.

Specified by:
SetMaxInactiveInterval in interface ISessionManager
Parameters:
timeOut -
See Also:
GetMaxInactiveInterval

SetNewSession

public void SetNewSession(boolean flag)
Set if the session is new. True = new session. False = session previously created.

Parameters:
flag - if the session was previously created.

Abandon

public void Abandon()
Abandon this session at the end of this request so that the Java/.NET session can be reclaimed by the server. This call will be ignored for sub-sessions.

Specified by:
Abandon in interface ISessionManager

IsAbandoned

public boolean IsAbandoned()
Check if the underlying Java/.NET session will be abandoned at the end of this request. This call will return incorrect values for sub-sessions.

Specified by:
IsAbandoned in interface ISessionManager
Returns:
boolean true implies that this session will be abandoned at the end of this request.



Copyright © 2002,2003,2004,2005 Plumtree Software, Inc., All Rights Reserved.