simple.http.session
Interface Session


public interface Session

The Session object is used to store session data relating to a specific HTTP client. The HTTP protocol does not maintain state between requests, so in order to build up data some identifier from the HTTP request must be used to acquire session information. Typically the session identifier is taken from a HTTP cookie, which can then be used to acquire data. That data is stored in a Session implementation.

This interface hides the complexities of the session handling system, which is broken into two separate entities. The first is the Store which acts as the storage mechanism for session variables, the other is the leasing mechanism, which is used to determine when a session has expired. The result is a very simple session management mechanism.

Author:
Niall Gallagher
See Also:
Store

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.
 boolean isEmpty()
          This is a convenience method that can be used to determine whether there are any variables within the session.
 java.util.Set keySet()
          To ascertain what mappings exist, the names of all values previously put into a session can be retrieved with this method.
 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

get

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. If there is no value by the given name within the store then this will return null. Also, if there is a problem retrieving the data null is returned instead.

Parameters:
name - this is the name of the variable to retrieve
Returns:
returns the variable mapped to the provided name

put

void put(java.lang.String name,
         java.lang.Object value)
This maps the given session variable to the provided name. The session variable can later be retrieved from future requests using the get method with its name.

Parameters:
name - this is the name of the variable to be mapped
value - this is the value mapped to the given name

contains

boolean contains(java.lang.String name)
This method is used to determine whether there is a value mapped to the specified name. If there is an existing mapping for the name this returns true, otherwise false.

Returns:
this returns true if the mapping already exists

remove

void remove(java.lang.String name)
This removes the mapping for the specified name. Once this has been done the underlying session must not contain any lingering reference to the mapped object.

Parameters:
name - this is the name of the variable to remove

isEmpty

boolean isEmpty()
This is a convenience method that can be used to determine whether there are any variables within the session. This can be useful in determining if the session is new.

Returns:
this returns true if the session has no mappings

keySet

java.util.Set keySet()
To ascertain what mappings exist, the names of all values previously put into a session 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

destroy

void destroy()
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.