org.norther.tammi.spray.session
Interface Manager

All Superinterfaces:
Configurable, Startable
All Known Subinterfaces:
SessionManager
All Known Implementing Classes:
DefaultSessionManager

public interface Manager
extends Configurable, Startable

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.

Version:
$Id: Manager.java,v 1.10 2010-01-18 12:30:18 cvsimp Exp $
Author:
Ilkka Priha

Nested Class Summary
static class Manager.SessionPolicy
          The session policy.
 
Method Summary
 void addHttpSessionAttributeListener(HttpSessionAttributeListener listener)
          Adds a HTTP session attribute listener.
 void addHttpSessionListener(HttpSessionListener listener)
          Adds a HTTP session listener.
 void addServletContextAttributeListener(ServletContextAttributeListener listener)
          Adds a servlet context attribute listener.
 void addServletContextListener(ServletContextListener listener)
          Adds a servlet context listener.
 void addServletRequestAttributeListener(ServletRequestAttributeListener listener)
          Adds a servlet request attribute listener.
 void addServletRequestListener(ServletRequestListener listener)
          Adds a servlet request listener.
 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.
 String getHttpSessionClassName()
          Gets the http session class name.
 int getIdLength()
          Gets the length of session ids.
 int getInitialExpirationTime()
          Gets the initial expiration time for new sessions.
 String getRequestDispatcherClassName()
          Gets the request dispatcher class name.
 ServletContext getServletContext()
          Gets the servlet context.
 AuthenticatedSession getSession(String id)
          Gets the active session with the specified session id.
 Manager.SessionPolicy 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 removeHttpSessionAttributeListener(HttpSessionAttributeListener listener)
          Removes a HTTP session attribute listener.
 void removeHttpSessionListener(HttpSessionListener listener)
          Removes a HTTP session listener.
 void removeServletContextAttributeListener(ServletContextAttributeListener listener)
          Removes a servlet context attribute listener.
 void removeServletContextListener(ServletContextListener listener)
          Removes a servlet context listener.
 void removeServletRequestAttributeListener(ServletRequestAttributeListener listener)
          Removes a servlet request attribute listener.
 void removeServletRequestListener(ServletRequestListener listener)
          Removes a servlet request listener.
 void setDefaultExpirationTime(int t)
          Sets the default expiration time for existing sessions.
 void setDistributable(boolean flag)
          Sets the distributable flag for the sessions.
 void setHttpSessionClassName(String className)
          Sets the http session class name.
 void setIdLength(int l)
          Sets the length of session ids.
 void setInitialExpirationTime(int t)
          Sets the initial expiration time for new sessions.
 void setRequestDispatcherClassName(String className)
          Sets the request dispatcher class name.
 void setSessionExpirationTime(String id, int t)
          Sets the expiration time for a specific session.
 void setUserSessionPolicy(Manager.SessionPolicy policy)
          Sets the policy for multiple sessions of 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<Principal> userPrincipalSet()
          Returns a read-only set of registered user principals.
 
Methods inherited from interface org.norther.tammi.core.config.Configurable
addProperty, addProperty, addPropertyFilePath, addPropertyFilePath, clearProperties, containsProperty, getConfigKey, getProperties, getProperty, getPropertyFilePath, getPropertyFilePaths, indexOfProperty, propertyMap, propertyMap, removeProperty, removeProperty, removePropertyFilePath, setConfigKey, setProperties, setProperty, setPropertyFilePath, setPropertyFilePath, setPropertyFilePaths, setPropertyFilePaths, storeProperties
 
Methods inherited from interface org.norther.tammi.core.base.Startable
isStarted, start, stop
 

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

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

Returns:
the policy to apply.

setUserSessionPolicy

void setUserSessionPolicy(Manager.SessionPolicy policy)
Sets the policy for multiple sessions of the same principal.

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.
NullPointerException - for a missing principal.
IllegalArgumentException - if principals differ.

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<Principal> 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 the servlet context.

Returns:
the servlet context.

getHttpSessionClassName

String getHttpSessionClassName()
Gets the http session class name.

Returns:
the class name or null.

setHttpSessionClassName

void setHttpSessionClassName(String className)
Sets the http session class name.

Parameters:
className - the class name.

getRequestDispatcherClassName

String getRequestDispatcherClassName()
Gets the request dispatcher class name.

Returns:
the class name or null.

setRequestDispatcherClassName

void setRequestDispatcherClassName(String className)
Sets the request dispatcher class name.

Parameters:
className - the class name.

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.

addServletContextListener

void addServletContextListener(ServletContextListener listener)
Adds a servlet context listener.

Parameters:
listener - the listener.

removeServletContextListener

void removeServletContextListener(ServletContextListener listener)
Removes a servlet context listener.

Parameters:
listener - the listener.

addServletContextAttributeListener

void addServletContextAttributeListener(ServletContextAttributeListener listener)
Adds a servlet context attribute listener.

Parameters:
listener - the listener.

removeServletContextAttributeListener

void removeServletContextAttributeListener(ServletContextAttributeListener listener)
Removes a servlet context attribute listener.

Parameters:
listener - the listener.

addHttpSessionListener

void addHttpSessionListener(HttpSessionListener listener)
Adds a HTTP session listener.

Parameters:
listener - the listener.

removeHttpSessionListener

void removeHttpSessionListener(HttpSessionListener listener)
Removes a HTTP session listener.

Parameters:
listener - the listener.

addHttpSessionAttributeListener

void addHttpSessionAttributeListener(HttpSessionAttributeListener listener)
Adds a HTTP session attribute listener.

Parameters:
listener - the listener.

removeHttpSessionAttributeListener

void removeHttpSessionAttributeListener(HttpSessionAttributeListener listener)
Removes a HTTP session attribute listener.

Parameters:
listener - the listener.

addServletRequestListener

void addServletRequestListener(ServletRequestListener listener)
Adds a servlet request listener.

Parameters:
listener - the listener.

removeServletRequestListener

void removeServletRequestListener(ServletRequestListener listener)
Removes a servlet request listener.

Parameters:
listener - the listener.

addServletRequestAttributeListener

void addServletRequestAttributeListener(ServletRequestAttributeListener listener)
Adds a servlet request attribute listener.

Parameters:
listener - the listener.

removeServletRequestAttributeListener

void removeServletRequestAttributeListener(ServletRequestAttributeListener listener)
Removes a servlet request attribute listener.

Parameters:
listener - the listener.


Copyright © 2004 The Norther Organization. All rights reserved.