amwebarsentitlementservice.session
Class SessionTable

java.lang.Object
  |
  +--amwebarsentitlementservice.session.SessionTable

public class SessionTable
extends java.lang.Object

The SessionTable contains all the Sessions of the AMWebARSEntitlementService. It generates all Sessions and manages the access to them. The SessionTable is a Singleton. There is only one instance in the system.


Field Summary
static boolean BOUND_NUMBER_OF_SESSIONS
           
static int MAX_NUMBER_OF_SESSIONS
           
 
Constructor Summary
protected SessionTable()
           
 
Method Summary
 void cleanSessionTable(java.util.Date current_date)
          Removes all sessions from the SessionTable, whose validity time is expired or not reached at current_date.
 void cleanSessionTable(long current_date)
           
 void clear()
          Removes all elements of the SessionTable.
protected  java.lang.Object clone()
          It isn't permited to clone the object: The clone method throws the CloneNotSupportedException.
 boolean containsSession(Session session)
          Tests whether a session is contained in the SessionTable.
 boolean containsSessionID(java.lang.String session_id)
          Tests whether a Session with given session_id is contained in the SessionTable.
 boolean equals(java.lang.Object other_object)
          Tests whether this SessionTable is equal to another.
static SessionTable getInstance()
          Returns the only instance of the SessionTable.
 Session getSession(java.lang.String session_id)
          Returns a session of a given session_id.
 boolean isEmpty()
          Tests whether this Table contains no Sessions.
 java.util.Enumeration keys()
          Returns all keys of the SessionTable.
 Session registerSession(java.lang.String session_id)
          Registers a new Session in the SessionTable.
 Session removeSession(Session session)
          Removes a Session from the SessionTable.
 Session removeSession(java.lang.String session_id)
          Removes a Session with given session_id from the SessionTable.
 void returnSession(Session session)
          Returns this session to the SessionPool.
 int size()
          Returns the size of the table that means the number of session stored in it.
 java.lang.String toString()
           
 org.jdom.Document toXML()
          Translates the SessionTable to XML.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BOUND_NUMBER_OF_SESSIONS

public static final boolean BOUND_NUMBER_OF_SESSIONS

MAX_NUMBER_OF_SESSIONS

public static final int MAX_NUMBER_OF_SESSIONS
Constructor Detail

SessionTable

protected SessionTable()
Method Detail

getInstance

public static SessionTable getInstance()
Returns the only instance of the SessionTable.
Returns:
only instance of SessionTable

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
It isn't permited to clone the object: The clone method throws the CloneNotSupportedException.
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException -  

getSession

public Session getSession(java.lang.String session_id)
                   throws java.util.NoSuchElementException
Returns a session of a given session_id. If the session isn't found an exception is thrown.
Parameters:
session_id - String ID of the session
Returns:
session of given id.
Throws:
java.util.NoSuchElementException - If the session isn't found.
NullPointerException - if parameter is null

registerSession

public Session registerSession(java.lang.String session_id)
Registers a new Session in the SessionTable. The instance is generated by the SessionTable.
Parameters:
session_id - String ID of the Session that is registered.
Returns:
generated Session
Throws:
NullPointerException - if parameter is null

removeSession

public Session removeSession(java.lang.String session_id)
                      throws java.util.NoSuchElementException
Removes a Session with given session_id from the SessionTable. The removed Session is returned.
Parameters:
String - session_id of the Session to be removed
Returns:
removed Session
Throws:
java.util.NoSuchElementException - if the Session isn't found
NullPointerException - if parameter is null

removeSession

public Session removeSession(Session session)
                      throws java.util.NoSuchElementException
Removes a Session from the SessionTable. The removed Session is returned.
Parameters:
session - Session to be removed
Returns:
removed Session
Throws:
java.util.NoSuchElementException - if the Session isn't found
NullPointerException - if parameter is null

returnSession

public void returnSession(Session session)
Returns this session to the SessionPool. The class returning the Session is responsible for not holding any references to the Session!

containsSession

public boolean containsSession(Session session)
Tests whether a session is contained in the SessionTable.
Parameters:
session - Session to be looked for.
Returns:
boolean true, if the SessionTable contains the Session
Throws:
NullPointerException - if parameter is null

containsSessionID

public boolean containsSessionID(java.lang.String session_id)
Tests whether a Session with given session_id is contained in the SessionTable.
Parameters:
session_id - String ID of the Session to be looked for.
Returns:
boolean true, if the SessionTable contains the Session
Throws:
NullPointerException - if parameter is null

size

public int size()
Returns the size of the table that means the number of session stored in it.
Returns:
int number of sessions

isEmpty

public boolean isEmpty()
Tests whether this Table contains no Sessions.
Returns:
boolean true if the table is empty

clear

public void clear()
Removes all elements of the SessionTable.

keys

public java.util.Enumeration keys()
Returns all keys of the SessionTable.
Returns:
Enumeration aller session_ids

cleanSessionTable

public void cleanSessionTable(java.util.Date current_date)
Removes all sessions from the SessionTable, whose validity time is expired or not reached at current_date.
Parameters:
current_date - current date
Throws:
NullPointerException - if parameter is null

cleanSessionTable

public void cleanSessionTable(long current_date)

equals

public boolean equals(java.lang.Object other_object)
Tests whether this SessionTable is equal to another.
Overrides:
equals in class java.lang.Object
Returns:
boolean true if both obj are the same.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toXML

public org.jdom.Document toXML()
Translates the SessionTable to XML.
Returns:
XML Document of the SessionTable