org.norther.tammi.spray.session
Interface Manager

All Known Subinterfaces:
SessionManager
All Known Implementing Classes:
DefaultSessionManager

public interface Manager

An interface to manager MBeans managing sessions that are associated with a particular container. Different manager implementations may support value-added features such as the persistent storage of session data, as well as migrating sessions for distributable web applications.

Author:
Ilkka Priha

Field Summary
static int ALLOW_MULTIPLE_USER_SESSIONS
          Allows multiple sessions for the same principal.
static int EXPIRE_EXISTING_USER_SESSION
          Expires an existing session for the same principal.
static int JOIN_EXISTING_USER_SESSION
          Joins an existing session for the same principal.
 
Method Summary
 AuthenticatedSession createSession()
          Constructs a new session based on the default settings specified by manager properties.
 AuthenticatedSession createSession(String id)
          Constructs a new session based on the default settings specified by manager properties.
 void expireAll()
          Expires all sessions.
 void expireSession(String id)
          Expires the specified session.
 int getDefaultExpirationTime()
          Gets the default expiration time for existing sessions.
 int getIdLength()
          Gets the length of session ids.
 int getInitialExpirationTime()
          Gets the initial expiration time for new sessions.
 ServletContext getServletContext()
          Gets a servlet context.
 AuthenticatedSession getSession(String id)
          Gets the active session with the specified session id.
 int getUserSessionPolicy()
          Gets the policy for multiple sessions for the same principal.
 String[] getUserSessions(Principal principal)
          Gets ids of active sessions of the specified principal.
 String[] getUserSessions(String username)
          Gets ids of active sessions of the named user.
 boolean isDistributable()
          Checks the distributable flag for the sessions.
 void load()
          Loads currently active sessions that were previously unloaded to the appropriate persistence mechanism, if any.
 AuthenticatedSession registerUserPrincipal(Principal principal, String id)
          Registers a user principal to a session.
 void setDefaultExpirationTime(int t)
          Sets the default expiration time for existing sessions.
 void setDistributable(boolean flag)
          Sets the distributable flag for the sessions.
 void setIdLength(int l)
          Sets the length of session ids.
 void setInitialExpirationTime(int t)
          Sets the initial expiration time for new sessions.
 void setSessionExpirationTime(String id, int t)
          Sets the expiration time for a specific session.
 void setUserSessionPolicy(int policy)
          Sets the policy for multiple sessions for the same principal.
 void unload()
          Saves currently active sessions in the appropriate persistence mechanism, if any.
 void unregisterUserPrincipal(Principal principal, String id)
          Unregisters a user principal from a session.
 Set userPrincipalSet()
          Returns a read-only set of registered user principals.
 

Field Detail

ALLOW_MULTIPLE_USER_SESSIONS

static final int ALLOW_MULTIPLE_USER_SESSIONS
Allows multiple sessions for the same principal.

See Also:
Constant Field Values

EXPIRE_EXISTING_USER_SESSION

static final int EXPIRE_EXISTING_USER_SESSION
Expires an existing session for the same principal.

See Also:
Constant Field Values

JOIN_EXISTING_USER_SESSION

static final int JOIN_EXISTING_USER_SESSION
Joins an existing session for the same principal.

See Also:
Constant Field Values
Method Detail

getIdLength

int getIdLength()
Gets the length of session ids.

Returns:
the id length.

setIdLength

void setIdLength(int l)
Sets the length of session ids.

Parameters:
l - the id length.

isDistributable

boolean isDistributable()
Checks the distributable flag for the sessions.

Returns:
the distributable flag.

setDistributable

void setDistributable(boolean flag)
Sets the distributable flag for the sessions. If this flag is set, all user data objects added to sessions associated must be serializable.

Parameters:
flag - the distributable flag.

getInitialExpirationTime

int getInitialExpirationTime()
Gets the initial expiration time for new sessions.

Returns:
the initial expiration time in seconds (0 = default).

setInitialExpirationTime

void setInitialExpirationTime(int t)
Sets the initial expiration time for new sessions.

Parameters:
t - the initial expiration time in seconds (0 = default).

getDefaultExpirationTime

int getDefaultExpirationTime()
Gets the default expiration time for existing sessions.

Returns:
the default expiration time in seconds.

setDefaultExpirationTime

void setDefaultExpirationTime(int t)
Sets the default expiration time for existing sessions.

Parameters:
t - the default expiration time in seconds.

setSessionExpirationTime

void setSessionExpirationTime(String id,
                              int t)
Sets the expiration time for a specific session.

Parameters:
id - the id of the session to set.
t - the expiration time in seconds.

getUserSessionPolicy

int getUserSessionPolicy()
Gets the policy for multiple sessions for the same principal.

Returns:
the policy to apply.

setUserSessionPolicy

void setUserSessionPolicy(int policy)
Sets the policy for multiple sessions for the same principal. Supported policies are ALLOW_MULTIPLE_USER_SESSIONS, EXPIRE_EXISTING_USER_SESSION and JOIN_EXISTING_USER_SESSION.

Parameters:
policy - the policy to apply.

createSession

AuthenticatedSession createSession()
                                   throws LogException
Constructs a new session based on the default settings specified by manager properties. The session id will be assigned by this method, and available via the getId() method of the returned session.

Returns:
a new session.
Throws:
LogException - if a new session cannot be instantiated.

createSession

AuthenticatedSession createSession(String id)
                                   throws LogException
Constructs a new session based on the default settings specified by manager properties. The session id is specified by the caller.

Parameters:
id - the session id.
Returns:
a new session.
Throws:
LogException - if a new session cannot be instantiated.

getSession

AuthenticatedSession getSession(String id)
Gets the active session with the specified session id.

Parameters:
id - the session id.
Returns:
the session or null.

getUserSessions

String[] getUserSessions(Principal principal)
Gets ids of active sessions of the specified principal.

Parameters:
principal - the principal instance.
Returns:
an array of session ids or null.

getUserSessions

String[] getUserSessions(String username)
Gets ids of active sessions of the named user.

Parameters:
username - the named user.
Returns:
an array of session ids or null.

registerUserPrincipal

AuthenticatedSession registerUserPrincipal(Principal principal,
                                           String id)
Registers a user principal to a session. The registration session depends on the defined user session policy and can be different from the session associated to the given id.

Parameters:
principal - the user principal.
id - the session id.
Returns:
the session of the registered principal.
Throws:
IllegalStateException - if no such session.

unregisterUserPrincipal

void unregisterUserPrincipal(Principal principal,
                             String id)
Unregisters a user principal from a session.

Parameters:
principal - the user principal.
id - the session id.

userPrincipalSet

Set userPrincipalSet()
Returns a read-only set of registered user principals.

Returns:
a set of user principals.

expireSession

void expireSession(String id)
Expires the specified session.

Parameters:
id - the id of the session to expire.

expireAll

void expireAll()
Expires all sessions.


getServletContext

ServletContext getServletContext()
Gets a servlet context.

Returns:
the servlet context.

load

void load()
          throws LogException
Loads currently active sessions that were previously unloaded to the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything.

Throws:
LogException - for processing errors.

unload

void unload()
            throws LogException
Saves currently active sessions in the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything.

Throws:
LogException - for processing errors.


Copyright © 2004 The Norther Organization. All rights reserved.