|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.norther.tammi.acorn.cache.CachedMapAdapter<K,V> org.norther.tammi.core.cache.DefaultCache<String,AuthenticatedSession> org.norther.tammi.spray.session.DefaultSessionManager
public class DefaultSessionManager
A session manager implementation.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.norther.tammi.acorn.cache.CachedMap |
---|
CachedMap.Value<K,V> |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Nested classes/interfaces inherited from interface org.norther.tammi.spray.session.Manager |
---|
Manager.SessionPolicy |
Field Summary | |
---|---|
static String |
DEFAULT_SESSION_STORE
The default session store path. |
Fields inherited from class org.norther.tammi.core.cache.DefaultCache |
---|
DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR |
Fields inherited from class org.norther.tammi.acorn.cache.CachedMapAdapter |
---|
DEFAULT_EXPIRATION_SLEEP_INTERVAL, DEFAULT_EXPIRATION_TIME |
Constructor Summary | |
---|---|
DefaultSessionManager()
Constructs a new session manager. |
|
DefaultSessionManager(int max)
Constructs a new session cache with max expiration time. |
|
DefaultSessionManager(int max,
int def)
Constructs a new session cache with max and default expiration times. |
|
DefaultSessionManager(int max,
int def,
int sleep)
Constructs a new session cache with max and default expiration times and expiration sleep interval. |
|
DefaultSessionManager(int max,
int def,
int sleep,
int capacity)
Constructs a new session cache with max and default expiration times, an expiration sleep interval and initial capacity. |
|
DefaultSessionManager(int max,
int def,
int sleep,
int capacity,
float loadFactor)
Constructs a new session cache with max and default expiration times, an expiration sleep interval, initial capacity and load factor. |
Method Summary | |
---|---|
void |
addHttpSessionAttributeListener(HttpSessionAttributeListener listener)
Adds a HTTP session attribute listener. |
void |
addHttpSessionListener(HttpSessionListener listener)
Adds a HTTP session listener. |
void |
addProperty(int index,
String key,
String value)
Inserts a multivalued property at the specified index. |
void |
addProperty(String key,
String value)
Adds a multivalued property. |
void |
addPropertyFilePath(String path)
Adds a property file path. |
void |
addPropertyFilePath(String path,
String encoding)
Adds a property file path with an encoding. |
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. |
void |
attributeAdded(HttpSessionBindingEvent event)
|
void |
attributeAdded(ServletContextAttributeEvent event)
|
void |
attributeAdded(ServletRequestAttributeEvent event)
|
void |
attributeRemoved(HttpSessionBindingEvent event)
|
void |
attributeRemoved(ServletContextAttributeEvent event)
|
void |
attributeRemoved(ServletRequestAttributeEvent event)
|
void |
attributeReplaced(HttpSessionBindingEvent event)
|
void |
attributeReplaced(ServletContextAttributeEvent event)
|
void |
attributeReplaced(ServletRequestAttributeEvent event)
|
void |
clearProperties()
Clears all properties. |
boolean |
containsProperty(String key)
Checks whether a property is defined. |
void |
contextDestroyed(ServletContextEvent event)
|
void |
contextInitialized(ServletContextEvent event)
|
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 entries. |
void |
expireSession(String id)
Expires the specified session. |
String |
getConfigKey()
Gets the path finder key for resolving configuration paths. |
protected Configuration |
getConfiguration()
Gets the configuration. |
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. |
protected MBeanDelegate |
getMBeanDelegate()
Gets the delegate to provide access to its methods for subclasses. |
String[] |
getProperties(String key)
Gets a multivalued property. |
String |
getProperty(String key)
Gets a property. |
String |
getPropertyFilePath()
Gets the property file path. |
String[] |
getPropertyFilePaths()
Gets the property file paths. |
String |
getRequestDispatcherClassName()
Gets the request dispatcher class name. |
String |
getSerializedSessionsPath()
Gets the path to store serialized sessions. |
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. |
int |
indexOfProperty(String key,
String value)
Returns the index of a multivalued property value. |
boolean |
isDistributable()
Checks the distributable flag for the sessions. |
boolean |
isStarted()
Checks whether the startable has been started. |
void |
load()
Loads currently active sessions that were previously unloaded to the appropriate persistence mechanism, if any. |
OrderedMap<String,Object> |
propertyMap()
Returns a map of properties. |
OrderedMap<String,Object> |
propertyMap(String prefix)
Returns a map of prefixed properties. |
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. |
Object |
removeProperty(String key)
Removes a property. |
boolean |
removeProperty(String key,
String value)
Removes a multivalued property. |
void |
removePropertyFilePath(String path)
Removes a property file path. |
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 |
requestDestroyed(ServletRequestEvent event)
|
void |
requestInitialized(ServletRequestEvent event)
|
void |
sessionCreated(HttpSessionEvent event)
|
void |
sessionDestroyed(HttpSessionEvent event)
|
void |
setConfigKey(String key)
Sets the path finder key for resolving configuration paths. |
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. |
Object |
setProperties(String key,
String[] values)
Sets a multivalued property. |
Object |
setProperty(String key,
String value)
Sets a property. |
void |
setPropertyFilePath(String path)
Sets the property file path. |
void |
setPropertyFilePath(String path,
String encoding)
Sets the property file path with an encoding. |
void |
setPropertyFilePaths(String[] paths)
Sets the property file paths. |
void |
setPropertyFilePaths(String[] paths,
String... encoding)
Sets the property file paths with encodings. |
void |
setRequestDispatcherClassName(String className)
Sets the request dispatcher class name. |
void |
setSerializedSessionsPath(String path)
Sets the path to store serialized sessions. |
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 |
start()
Starts the MBean. |
void |
stop()
Stops the MBean. |
void |
storeProperties()
Stores properties to the property file. |
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 class org.norther.tammi.core.cache.DefaultCache |
---|
addNotificationListener, getNotificationInfo, postmanaged, premanaged, removeNotificationListener, removeNotificationListener, setAllowExpired, setDefaultExpirationTime, setDiscardOverloaded, setExpirationLimit, setExpirationSleepInterval, setExpirationThreshold, setMaxExpirationTime, toString, unmanaged |
Methods inherited from class org.norther.tammi.acorn.cache.CachedMapAdapter |
---|
add, add, clear, containsKey, containsValue, entrySet, equals, expire, expireFraction, get, get, getDefaultExpirationTime, getExpirationLimit, getExpirationSleepInterval, getExpirationThreshold, getExpirationTimer, getMaxExpirationTime, getSwapOutHandler, hashCode, isAllowExpired, isAutoRefreshDeclined, isDiscardOverloaded, isEmpty, keySet, put, put, putAll, putIfAbsent, putIfAbsent, refresh, refresh, remove, remove, replace, replace, setAutoRefreshDeclined, setExpirationTimer, setSwapOutHandler, size, values |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.norther.tammi.acorn.cache.CachedMap |
---|
add, add, expire, expireFraction, get, getDefaultExpirationTime, getExpirationLimit, getExpirationSleepInterval, getExpirationThreshold, getMaxExpirationTime, isAllowExpired, isAutoRefreshDeclined, isDiscardOverloaded, put, putIfAbsent, refresh, refresh, setAllowExpired, setAutoRefreshDeclined, setDefaultExpirationTime, setDiscardOverloaded, setExpirationLimit, setExpirationSleepInterval, setExpirationThreshold, setMaxExpirationTime |
Methods inherited from interface java.util.concurrent.ConcurrentMap |
---|
putIfAbsent, remove, replace, replace |
Methods inherited from interface java.util.Map |
---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from interface org.norther.tammi.spray.session.Manager |
---|
getDefaultExpirationTime, setDefaultExpirationTime |
Field Detail |
---|
public static final String DEFAULT_SESSION_STORE
Constructor Detail |
---|
public DefaultSessionManager()
public DefaultSessionManager(int max)
max
- a max expiration time (0 = default, -1 = infinite).public DefaultSessionManager(int max, int def)
max
- a max expiration time in secs (0 = default, -1 = infinite).def
- a default expiration time in secs (0 = default, -1 =
infinite).public DefaultSessionManager(int max, int def, int sleep)
max
- a max expiration time in secs (0 = default, -1 = infinite).def
- a default expiration time in secs (0 = default, -1 =
infinite).sleep
- an expiration sleep interval in secs (0 = default, -1 =
infinite).public DefaultSessionManager(int max, int def, int sleep, int capacity)
max
- a max expiration time in secs (0 = default, -1 = infinite).def
- a default expiration time in secs (0 = default, -1 =
infinite).sleep
- an expiration sleep interval in secs (0 = default, -1 =
infinite).capacity
- an initial capacity.public DefaultSessionManager(int max, int def, int sleep, int capacity, float loadFactor)
max
- a max expiration time in secs (0 = default, -1 = infinite).def
- a default expiration time in secs (0 = default, -1 =
infinite).sleep
- an expiration sleep interval in secs (0 = default, -1 =
infinite).capacity
- an initial capacity.loadFactor
- a load factor.Method Detail |
---|
public int getIdLength()
Manager
getIdLength
in interface Manager
public void setIdLength(int l)
Manager
setIdLength
in interface Manager
l
- the id length.public boolean isDistributable()
Manager
isDistributable
in interface Manager
public void setDistributable(boolean flag)
Manager
setDistributable
in interface Manager
flag
- the distributable flag.public int getInitialExpirationTime()
Manager
getInitialExpirationTime
in interface Manager
public void setInitialExpirationTime(int t)
Manager
setInitialExpirationTime
in interface Manager
t
- the initial expiration time in seconds (0 = default).public void setSessionExpirationTime(String id, int t)
Manager
setSessionExpirationTime
in interface Manager
id
- the id of the session to set.t
- the expiration time in seconds.public Manager.SessionPolicy getUserSessionPolicy()
Manager
getUserSessionPolicy
in interface Manager
public void setUserSessionPolicy(Manager.SessionPolicy policy)
Manager
setUserSessionPolicy
in interface Manager
policy
- the policy to apply.public AuthenticatedSession createSession() throws LogException
Manager
createSession
in interface Manager
LogException
- if a new session cannot be instantiated.public AuthenticatedSession createSession(String id) throws LogException
Manager
createSession
in interface Manager
id
- the session id.
LogException
- if a new session cannot be instantiated.public AuthenticatedSession getSession(String id)
Manager
getSession
in interface Manager
id
- the session id.
public String[] getUserSessions(Principal principal)
Manager
getUserSessions
in interface Manager
principal
- the principal instance.
public String[] getUserSessions(String username)
Manager
getUserSessions
in interface Manager
username
- the named user.
public AuthenticatedSession registerUserPrincipal(Principal principal, String id)
Manager
registerUserPrincipal
in interface Manager
principal
- the user principal.id
- the session id.
public void unregisterUserPrincipal(Principal principal, String id)
Manager
unregisterUserPrincipal
in interface Manager
principal
- the user principal.id
- the session id.public Set<Principal> userPrincipalSet()
Manager
userPrincipalSet
in interface Manager
public void expireSession(String id)
Manager
expireSession
in interface Manager
id
- the id of the session to expire.public void expireAll()
CachedMap
expireAll
in interface CachedMap<String,AuthenticatedSession>
expireAll
in interface Manager
expireAll
in class CachedMapAdapter<String,AuthenticatedSession>
public ServletContext getServletContext()
Manager
getServletContext
in interface Manager
public String getHttpSessionClassName()
Manager
getHttpSessionClassName
in interface Manager
public void setHttpSessionClassName(String className)
Manager
setHttpSessionClassName
in interface Manager
className
- the class name.public String getRequestDispatcherClassName()
Manager
getRequestDispatcherClassName
in interface Manager
public void setRequestDispatcherClassName(String className)
Manager
setRequestDispatcherClassName
in interface Manager
className
- the class name.public void load() throws LogException
Manager
load
in interface Manager
LogException
- for processing errors.public void unload() throws LogException
Manager
unload
in interface Manager
LogException
- for processing errors.public void addServletContextListener(ServletContextListener listener)
Manager
addServletContextListener
in interface Manager
listener
- the listener.public void removeServletContextListener(ServletContextListener listener)
Manager
removeServletContextListener
in interface Manager
listener
- the listener.public void addServletContextAttributeListener(ServletContextAttributeListener listener)
Manager
addServletContextAttributeListener
in interface Manager
listener
- the listener.public void removeServletContextAttributeListener(ServletContextAttributeListener listener)
Manager
removeServletContextAttributeListener
in interface Manager
listener
- the listener.public void addHttpSessionListener(HttpSessionListener listener)
Manager
addHttpSessionListener
in interface Manager
listener
- the listener.public void removeHttpSessionListener(HttpSessionListener listener)
Manager
removeHttpSessionListener
in interface Manager
listener
- the listener.public void addHttpSessionAttributeListener(HttpSessionAttributeListener listener)
Manager
addHttpSessionAttributeListener
in interface Manager
listener
- the listener.public void removeHttpSessionAttributeListener(HttpSessionAttributeListener listener)
Manager
removeHttpSessionAttributeListener
in interface Manager
listener
- the listener.public void addServletRequestListener(ServletRequestListener listener)
Manager
addServletRequestListener
in interface Manager
listener
- the listener.public void removeServletRequestListener(ServletRequestListener listener)
Manager
removeServletRequestListener
in interface Manager
listener
- the listener.public void addServletRequestAttributeListener(ServletRequestAttributeListener listener)
Manager
addServletRequestAttributeListener
in interface Manager
listener
- the listener.public void removeServletRequestAttributeListener(ServletRequestAttributeListener listener)
Manager
removeServletRequestAttributeListener
in interface Manager
listener
- the listener.public String getSerializedSessionsPath()
SessionManager
getSerializedSessionsPath
in interface SessionManager
public void setSerializedSessionsPath(String path)
SessionManager
setSerializedSessionsPath
in interface SessionManager
path
- the session store path.public boolean isStarted()
Startable
isStarted
in interface Startable
public void start()
Startable
start
in interface Startable
public void stop()
Startable
stop
in interface Startable
public String getConfigKey()
Configurable
getConfigKey
in interface Configurable
public void setConfigKey(String key)
Configurable
setConfigKey
in interface Configurable
key
- the path finder key.public String getPropertyFilePath()
Configurable
getPropertyFilePath
in interface Configurable
public void setPropertyFilePath(String path)
Configurable
Note that all previously defined property file paths and properties are cleared.
setPropertyFilePath
in interface Configurable
path
- a property file path.public void setPropertyFilePath(String path, String encoding)
Configurable
setPropertyFilePath
in interface Configurable
path
- a property file path.encoding
- an encoding to use.public String[] getPropertyFilePaths()
Configurable
getPropertyFilePaths
in interface Configurable
public void setPropertyFilePaths(String[] paths)
Configurable
setPropertyFilePaths
in interface Configurable
paths
- property file paths.public void setPropertyFilePaths(String[] paths, String... encoding)
Configurable
setPropertyFilePaths
in interface Configurable
paths
- property file paths.encoding
- encodings to use.public void addPropertyFilePath(String path)
Configurable
addPropertyFilePath
in interface Configurable
path
- a property file path.public void addPropertyFilePath(String path, String encoding)
Configurable
addPropertyFilePath
in interface Configurable
path
- a property file path.encoding
- an encoding to use.public void removePropertyFilePath(String path)
Configurable
removePropertyFilePath
in interface Configurable
path
- the property file path.public boolean containsProperty(String key)
Configurable
containsProperty
in interface Configurable
key
- the key.
public String getProperty(String key)
Configurable
getProperty
in interface Configurable
key
- the key.
public Object setProperty(String key, String value)
Configurable
setProperty
in interface Configurable
key
- the key.value
- the value.
public String[] getProperties(String key)
Configurable
getProperties
in interface Configurable
key
- the key.
public Object setProperties(String key, String[] values)
Configurable
setProperties
in interface Configurable
key
- the key.values
- the values.
public Object removeProperty(String key)
Configurable
removeProperty
in interface Configurable
key
- the key.
public int indexOfProperty(String key, String value)
Configurable
indexOfProperty
in interface Configurable
key
- the key.value
- the value.
public void addProperty(String key, String value)
Configurable
addProperty
in interface Configurable
key
- the key.value
- the property.public void addProperty(int index, String key, String value)
Configurable
addProperty
in interface Configurable
index
- the index.key
- the key.value
- the value.public boolean removeProperty(String key, String value)
Configurable
removeProperty
in interface Configurable
key
- the key.value
- the value.
public void clearProperties()
Configurable
clearProperties
in interface Configurable
public OrderedMap<String,Object> propertyMap()
Configurable
propertyMap
in interface Configurable
public OrderedMap<String,Object> propertyMap(String prefix)
Configurable
propertyMap
in interface Configurable
prefix
- the prefix.
public void storeProperties() throws IOException
Configurable
storeProperties
in interface Configurable
IOException
- on I/O errors.public void contextInitialized(ServletContextEvent event)
contextInitialized
in interface ServletContextListener
public void contextDestroyed(ServletContextEvent event)
contextDestroyed
in interface ServletContextListener
public void attributeAdded(ServletContextAttributeEvent event)
attributeAdded
in interface ServletContextAttributeListener
public void attributeRemoved(ServletContextAttributeEvent event)
attributeRemoved
in interface ServletContextAttributeListener
public void attributeReplaced(ServletContextAttributeEvent event)
attributeReplaced
in interface ServletContextAttributeListener
public void sessionCreated(HttpSessionEvent event)
sessionCreated
in interface HttpSessionListener
public void sessionDestroyed(HttpSessionEvent event)
sessionDestroyed
in interface HttpSessionListener
public void attributeAdded(HttpSessionBindingEvent event)
attributeAdded
in interface HttpSessionAttributeListener
public void attributeRemoved(HttpSessionBindingEvent event)
attributeRemoved
in interface HttpSessionAttributeListener
public void attributeReplaced(HttpSessionBindingEvent event)
attributeReplaced
in interface HttpSessionAttributeListener
public void requestInitialized(ServletRequestEvent event)
requestInitialized
in interface ServletRequestListener
public void requestDestroyed(ServletRequestEvent event)
requestDestroyed
in interface ServletRequestListener
public void attributeAdded(ServletRequestAttributeEvent event)
attributeAdded
in interface ServletRequestAttributeListener
public void attributeRemoved(ServletRequestAttributeEvent event)
attributeRemoved
in interface ServletRequestAttributeListener
public void attributeReplaced(ServletRequestAttributeEvent event)
attributeReplaced
in interface ServletRequestAttributeListener
protected MBeanDelegate getMBeanDelegate()
DefaultCache
getMBeanDelegate
in class DefaultCache<String,AuthenticatedSession>
protected Configuration getConfiguration()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |