simple.http.session
Interface Store

All Known Implementing Classes:
ReflectionStore

public interface Store

The Store object provides the persistence scheme used by sessions. In order to facilitate a range of storage techniques for session data the Session must be able to avail of arbitrary strategies. An implementation of this interface can be used to store all objects given to a session instance. For example, objects can be stored within a relational database, a file, or some in-memory container.

To configure the system to use a specific implementation the system property simple.http.session.store can be used. If this is not specified then a default implementation is used which simply stores the data within an internal map. All Store implementations must have a single argument constructor that takes a Cookie.

Author:
Niall Gallagher

Method Summary
 boolean contains(java.lang.String name)
          This method is used to determine whether there is a value mapped to the specified name.
 void destroy()
          In order to free up any resources consumed by this object it must be destroyed when it is no longer useful.
 java.lang.Object get(java.lang.String name)
          This method is used to acquire a session variable that has been previously stored with the put method.
 java.util.Set keySet()
          To ascertain what mappings exist, the names of all values previously put into this store can be retrieved with this method.
 void prepare(java.lang.Object data)
          This method is used to prepare the Store for use with an active session.
 void put(java.lang.String name, java.lang.Object value)
          This maps the given session variable to the provided name.
 void remove(java.lang.String name)
          This removes the mapping for the specified name.
 

Method Detail

prepare

void prepare(java.lang.Object data)
             throws StoreException
This method is used to prepare the Store for use with an active session. This should contain sufficent functionality to setup the storage environment so that the Session object can transparently store and retrieve session variables from the storage medium. If there is a problem initializing an exception is thrown.

Parameters:
data - the data used to initialize this instance
Throws:
StoreException - if there problem initializing

get

java.lang.Object get(java.lang.String name)
                     throws StoreException
This method is used to acquire a session variable that has been previously stored with the put method. If there is no value by the given name within this store then this will return null. Also, if there is a problem retrieving the data from the underlying storage mechanism this may thrown an StoreException.

Parameters:
name - this is the name of the variable to retrieve
Returns:
returns the variable mapped to the provided name
Throws:
StoreException - thrown if there is an I/O error

put

void put(java.lang.String name,
         java.lang.Object value)
         throws StoreException
This maps the given session variable to the provided name. An implementation of this must insert the variable into a container in such a way that it can be retrieved at a later stage using the get method. If the object can not be stored an StoreException is thrown.

Parameters:
name - this is the name of the variable to be mapped
value - this is the value mapped to the given name
Throws:
StoreException - if there is an storage problem

contains

boolean contains(java.lang.String name)
                 throws StoreException
This method is used to determine whether there is a value mapped to the specified name. If there is an existing mapping for the specified name this returns true, if not then false is returned. An exception is thrown if there is a problem accessing the underlying storage mechanism.

Returns:
this returns true if the mapping already exists
Throws:
StoreException - if there is an storage problem

remove

void remove(java.lang.String name)
            throws StoreException
This removes the mapping for the specified name. Once this has been done the underlying storage must not contain any reference to the mapped object. If there is a problem with the underlying storage mechanism an exception is thrown.

Parameters:
name - this is the name of the variable to remove
Throws:
StoreException - if there is an storage problem

keySet

java.util.Set keySet()
                     throws StoreException
To ascertain what mappings exist, the names of all values previously put into this store can be retrieved with this method. This will return a Set that contains the names of all the session variables currently stored.

Returns:
this returns the the keys for existing mappings
Throws:
StoreException - if there is an storage problem

destroy

void destroy()
             throws StoreException
In order to free up any resources consumed by this object it must be destroyed when it is no longer useful. This can be used to delete files, close JDBC connections, or free up other such resources used for storing session data.

Throws:
StoreException - if there is an storage problem