org.aselect.agent.session
Class SessionManager

java.lang.Object
  extended by org.aselect.agent.session.SessionManager

public class SessionManager
extends java.lang.Object

Manages A-Select Agent sessions.

Description:
Provides methods for managing sessions:

The session contexts are stored using a StorageManager.

Note: This manager is implemented as a Singleton.

Concurrency issues:
-

Author:
Alfa & Ariss

Field Summary
static java.lang.String MODULE
          The MODULE name.
 
Method Summary
 boolean createSession(java.lang.String sSessionId, java.util.Hashtable htSessionContext)
          Create a session.
static SessionManager getHandle()
          Get a static handle to the SessionManager instance.
 java.util.Hashtable getSessionContext(java.lang.String sSessionId)
          Get the session context of a session.
 java.util.Hashtable getSessionContexts()
          Retrieve all session contexts.
 long getSessionsCounter()
          Get the number of issued sessions since startup.
 long getSessionTimeout(java.lang.String sSessionId)
          Returns then session timeout.
 boolean init()
          Initializes the SessionManager.
 void killSession(java.lang.String sSessionId)
          Kill a session.
 void stop()
          Stop the SessionManager.
 boolean updateSessionContext(java.lang.String sSessionId, java.util.Hashtable htSessionContext)
          Update a session context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODULE

public static final java.lang.String MODULE
The MODULE name.

See Also:
Constant Field Values
Method Detail

getHandle

public static SessionManager getHandle()
Get a static handle to the SessionManager instance.

Description:
Checks if a static instance exists, otherwise it is created. This instance is returned.

Concurrency issues:
-

Preconditions:
-

Postconditions:
One instance of the SessionManager exists.

Returns:
A static handle to the SessionManager

init

public boolean init()
Initializes the SessionManager.

Description:
Read configuration settings and initializes the components.

Concurrency issues:
-

Preconditions:
-

Postconditions:
The instance variables and components are initialized.

Returns:
true if initialization succeeds, otherwise false.

stop

public void stop()
Stop the SessionManager.

Description:
Destroys all current sessions.

Concurrency issues:
After this method is finished, no methods may be called in other threads.

Preconditions:
-

Postconditions:
The SessionManager has stopped.


createSession

public boolean createSession(java.lang.String sSessionId,
                             java.util.Hashtable htSessionContext)
Create a session.

Description:
Adds the given session context with the given ID to the storage.

Concurrency issues:
none.

Preconditions:
Postconditions:
The given session is stored.

Parameters:
sSessionId - The id of the session.
htSessionContext - The contents of the session (context).
Returns:
True if creation succeeds, otherwise false.

killSession

public void killSession(java.lang.String sSessionId)
Kill a session.

Description:
Removes the session with the given ID form the storage.

Concurrency issues:
-

Preconditions:
sSessionId != null

Postconditions:
The session is removed from storage.

Parameters:
sSessionId - The ID of the session to be removed.

updateSessionContext

public boolean updateSessionContext(java.lang.String sSessionId,
                                    java.util.Hashtable htSessionContext)
Update a session context.

Description:
Overwrites the new session context with the given ID in the storage.

Concurrency issues:
-

Preconditions:
Postconditions:
The given session is updated with the new context.

Parameters:
sSessionId - The ID of the session.
htSessionContext - The new session context.
Returns:
True if updating succeeds, otherwise false.

getSessionsCounter

public long getSessionsCounter()
Get the number of issued sessions since startup.

Returns:
The number of issued sessions.

getSessionContext

public java.util.Hashtable getSessionContext(java.lang.String sSessionId)
Get the session context of a session.

Description:
Retrieve the session context (session parameters) belonging to the given session ID.

Concurrency issues:
-

Preconditions:
sSessionId != null

Postconditions:
-

Parameters:
sSessionId - The ID of the session.
Returns:
The session context as Hashtable.

getSessionContexts

public java.util.Hashtable getSessionContexts()
Retrieve all session contexts.

Description:
Retrieve all session contexts from the storage.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Returns:
All session contexts in a Hashtable.

getSessionTimeout

public long getSessionTimeout(java.lang.String sSessionId)
                       throws ASelectStorageException
Returns then session timeout.

Description:
Return the session timeout form the given session.

Concurrency issues:
-

Preconditions:
sSessionId != null

Postconditions:
-

Parameters:
sSessionId - The session ID.
Returns:
The expiration time of the session.
Throws:
ASelectStorageException - If retrieving session timeout fails.


Copyright © 2008 SURFnet BV. All Rights Reserved.