org.aselect.server.session
Class SessionManager

java.lang.Object
  extended by org.aselect.system.storagemanager.StorageManager
      extended by org.aselect.server.session.SessionManager

public class SessionManager
extends StorageManager

Manages A-Select Server 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
 java.lang.String createSession(java.util.Hashtable htSessionContext)
          Create a unique session ID and stores the htSessionContext using this ID.
 boolean createSession(java.lang.String sSessionId, java.util.Hashtable htSessionContext)
          Stores a new session context using the supplied session ID.
 void destroy()
          Destroy the SessionManager.
 long getCounter()
          Retrieve the number of issued sessions since startup.
static SessionManager getHandle()
          Returns a static handle to the SessionManager instance.
 long getProcessingTime()
          Retrieve the processing time.
 java.util.Hashtable getSessionContext(java.lang.String sSessionId)
          Get the session context of a session.
 void init()
          Initializes the SessionManager.
 void killSession(java.lang.String sSessionId)
          Kill a session.
 boolean updateSession(java.lang.String sSessionId, java.util.Hashtable htSessionContext)
          Update a session context.
 
Methods inherited from class org.aselect.system.storagemanager.StorageManager
containsKey, get, getAll, getCount, getExpirationTime, getTimestamp, init, put, remove, removeAll, update
 
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

init

public void init()
          throws ASelectException,
                 ASelectConfigException
Initializes the SessionManager.

Description:
Read configuration settings and initializes the components.

Concurrency issues:
-

Preconditions:
-

Postconditions:
The instance variables and components are initialized.

Throws:
ASelectException - If initialization fails.
ASelectConfigException - If one or more mandatory configuration settings are missing or invalid.

getHandle

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

Description:

Concurrency issues:
-

Preconditions:
-

Postconditions:
One instance of the SessionManager exists.

Returns:
A static handle to the SessionManager.

destroy

public void destroy()
Destroy the SessionManager.

Description:
Destroys the storage manager by calling super.destroy()

Concurrency issues:
-

Preconditions:
-

Postconditions:
The SessionManager is destroyed.

Overrides:
destroy in class StorageManager
See Also:
IStorageHandler.destroy(), Cleaner#destroy()

createSession

public java.lang.String createSession(java.util.Hashtable htSessionContext)
                               throws ASelectException
Create a unique session ID and stores the htSessionContext using this ID.

Description:
Stores the htSessionContext supplied by the caller under a unique generated session id of 8 bytes.

Concurrency issues:
-

Preconditions:
htSessionContext != null

Postconditions:
The given session is stored.

Parameters:
htSessionContext - The session context parameters in a Hashtable.
Returns:
The created session id.
Throws:
ASelectException - If server is busy.

createSession

public boolean createSession(java.lang.String sSessionId,
                             java.util.Hashtable htSessionContext)
Stores a new session context using the supplied session ID.

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

Use this method also instead of updateSession(String, Hashtable), if the session allready exists. In this case this method is faster.

Concurrency issues:
-

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

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

updateSession

public boolean updateSession(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.

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.

killSession

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

Description:
Removes the session with the given ID from the storage manager.

Concurrency issues:
-

Preconditions:
sSessionId != null

Postconditions:
The session is removed from storage.

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

getProcessingTime

public long getProcessingTime()
Retrieve the processing time.

Returns:
The processing time.

getCounter

public long getCounter()
Retrieve the number of issued sessions since startup.

Returns:
The session counter.


Copyright © 2008 SURFnet BV. All Rights Reserved.