public final class SessionManager extends java.lang.Object implements SessionCookieConfig, AlarmListener
Constructor and Description |
---|
SessionManager(WebApp webApp)
Creates and initializes a new session manager
|
Modifier and Type | Method and Description |
---|---|
void |
addActivationListener(HttpSessionActivationListener listener)
Adds a new HttpSessionActivationListener.
|
void |
addAttributeListener(HttpSessionAttributeListener listener)
Adds a new HttpSessionAttributeListener.
|
void |
addListener(HttpSessionListener listener)
Adds a new HttpSessionListener.
|
void |
close()
Cleans up the sessions when the WebApp shuts down gracefully.
|
boolean |
containsSession(java.lang.String id)
Returns true if the session exists in this manager.
|
SessionCookieConfig |
createCookieConfig() |
java.lang.String |
createCookieValue() |
protected java.lang.String |
createCookieValue(java.lang.Object owner) |
SessionImpl |
createSession(boolean isCreate,
HttpServletRequest request,
java.lang.String sessionId,
long now,
boolean fromCookie)
Finds a session in the session store, creating one if 'create' is true
|
SessionImpl |
createSession(java.lang.String oldId,
long now,
HttpServletRequest request,
boolean fromCookie)
Create a new session.
|
SessionDeserializer |
createSessionDeserializer(java.io.InputStream is) |
java.lang.String |
createSessionId(HttpServletRequest request)
Creates a pseudo-random session id.
|
java.lang.String |
createSessionId(HttpServletRequest request,
boolean create)
Creates a pseudo-random session id.
|
java.lang.String |
createSessionIdImpl(HttpServletRequest request) |
SessionSerializer |
createSessionSerializer(java.io.OutputStream os) |
boolean |
enableSessionCookies()
Returns true if sessions use the cookie header.
|
boolean |
enableSessionUrls()
Returns true if sessions can use the session rewriting.
|
int |
getActiveSessionCount()
Returns the current number of active sessions.
|
SessionManagerMXBean |
getAdmin()
Returns the admin.
|
java.lang.String |
getAlternateSessionPrefix()
Returns the alternate session prefix, before the URL for wap.
|
java.lang.String |
getComment() |
java.lang.String |
getCookieDomain()
Returns the default session cookie domain.
|
java.lang.String |
getCookieDomainRegexp() |
long |
getCookieLength()
Returns the cookie length.
|
long |
getCookieMaxAge()
Returns the max-age of the session cookie.
|
java.lang.String |
getCookieName()
Returns the default cookie name.
|
java.lang.String |
getCookiePort()
Gets the cookie ports.
|
int |
getCookieVersion()
Returns the cookie version.
|
java.util.logging.Logger |
getDebug()
Returns the debug log
|
java.lang.String |
getDistributionId() |
java.lang.String |
getDomain() |
long |
getEstimatedMemorySize() |
int |
getMaxAge() |
long |
getMaxIdleTime()
Returns the idle time.
|
java.lang.String |
getName() |
java.lang.String |
getPath() |
int |
getReuseSessionId()
True if the server should reuse the current session id if the
session doesn't exist.
|
java.lang.String |
getSaveMode()
Returns the string value of the save-mode.
|
SessionImpl |
getSession(java.lang.String key) |
SessionImpl |
getSession(java.lang.String key,
long now,
boolean create,
boolean fromCookie)
Returns a session from the session store, returning null if there's
no cached session.
|
int |
getSessionActiveCount()
Returns the active sessions.
|
java.lang.String |
getSessionAsJsonString(java.lang.String id) |
long |
getSessionCreateCount()
Returns the created sessions.
|
long |
getSessionInvalidateCount()
Returns the invalidate sessions.
|
int |
getSessionMax()
Returns the maximum number of sessions.
|
java.lang.String |
getSessionPrefix()
Returns the session prefix, ie..
|
java.lang.String |
getSessionsAsJsonString() |
java.lang.String |
getSessionSerializationDebug(java.lang.String id)
Returns a debug string for the session
|
ByteStreamCache |
getSessionStore()
Returns the session store.
|
long |
getSessionTimeout()
Returns the default session timeout in milliseconds.
|
long |
getSessionTimeoutCount()
Returns the timeout sessions.
|
java.lang.String |
getSSLCookieName()
Returns the SSL cookie name.
|
void |
handleAlarm(Alarm alarm)
Timeout for reaping old sessions
|
void |
init() |
boolean |
isClosed()
Returns true if the sessions are closed.
|
boolean |
isCookieAppendServerIndex()
Sets module session id generation.
|
boolean |
isCookieHttpOnly()
Returns the http-only of the session cookie.
|
boolean |
isCookieSecure()
Returns the secure of the session cookie.
|
boolean |
isDestroyOnLru() |
boolean |
isHessianSerialization()
Returns true for Hessian serialization.
|
boolean |
isHttpOnly() |
boolean |
isInvalidateAfterListener()
True if the session should be invalidated after the listener.
|
boolean |
isOwner(java.lang.String id) |
boolean |
isPersistenceEnabled() |
boolean |
isSaveAfterRequest()
True if sessions should be saved after the request.
|
boolean |
isSaveBeforeFlush()
True if sessions should be saved before each flush.
|
boolean |
isSaveBeforeHeaders()
True if sessions should be saved before the HTTP headers.
|
boolean |
isSaveOnlyOnShutdown()
True if sessions should only be saved on shutdown.
|
boolean |
isSaveOnShutdown()
True if sessions should be saved on shutdown.
|
boolean |
isSecure() |
boolean |
isUsePersistentStore() |
void |
notifyRemove(java.lang.String id)
Notification from the cluster.
|
boolean |
reuseSessionId(boolean fromCookie)
True if the server should reuse the current session id if the
session doesn't exist.
|
java.lang.String[] |
sessionIdList() |
void |
setAlwaysLoadSession(boolean load)
True if sessions should always be loadd.
|
void |
setAlwaysSaveSession(boolean save)
True if sessions should always be saved.
|
void |
setComment(java.lang.String comment) |
void |
setCookieAppendServerIndex(boolean isAppend)
Sets module session id generation.
|
void |
setCookieDomain(java.lang.String domain)
Sets the default session cookie domain.
|
void |
setCookieDomainRegexp(java.lang.String regexp) |
void |
setCookieHttpOnly(boolean httpOnly)
Sets the http-only of the session cookie.
|
void |
setCookieLength(int cookieLength)
Sets the cookie length
|
void |
setCookieMaxAge(Period maxAge)
Sets the max-age of the session cookie.
|
void |
setCookieModuloCluster(boolean isModulo)
Sets module session id generation.
|
void |
setCookieName(java.lang.String cookieName) |
void |
setCookiePath(java.lang.String path)
Sets the default session cookie domain.
|
void |
setCookiePort(java.lang.String port)
Sets the cookie ports.
|
void |
setCookieSecure(boolean isSecure)
Sets the secure of the session cookie.
|
void |
setCookieUseContextPath(boolean isCookieUseContextPath)
Sets the cookie ports.
|
void |
setCookieVersion(int cookieVersion)
Sets the cookie version.
|
void |
setDestroyOnLru(boolean isDestroy) |
void |
setDistributionId(java.lang.String distributionId) |
void |
setDomain(java.lang.String domain) |
void |
setEnableCookies(boolean enableCookies)
Returns true if sessions use the cookie header.
|
void |
setEnableUrlRewriting(boolean enableUrls)
Returns true if sessions can use the session rewriting.
|
void |
setHttpOnly(boolean httpOnly) |
void |
setIgnoreSerializationErrors(boolean ignore)
True if serialization errors should just fail silently.
|
void |
setInvalidateAfterListener(boolean inv)
True if the session should be invalidated after the listener.
|
void |
setMaxAge(int maxAge) |
void |
setName(java.lang.String name) |
void |
setPath(java.lang.String path) |
void |
setReuseSessionId(java.lang.String reuse)
True if the server should reuse the current session id if the
session doesn't exist.
|
void |
setSaveMode(java.lang.String mode)
Sets the save-mode: before-flush, before-headers, after-request,
on-shutdown
|
void |
setSaveOnlyOnShutdown(boolean save)
True if sessions should only be saved on shutdown.
|
void |
setSaveOnShutdown(boolean save)
True if sessions should only be saved on shutdown.
|
void |
setSecure(boolean secure) |
void |
setSerializationType(java.lang.String type)
Sets the serialization type.
|
void |
setSerializeCollectionType(boolean isEnable) |
void |
setSessionMax(int max)
Returns the maximum number of sessions.
|
void |
setSessionTimeout(long timeout)
Set the default session timeout in minutes
|
void |
setTrackingMode(SessionTrackingMode mode) |
void |
setUsePersistentStore(boolean enable)
Sets the cluster store.
|
void |
start() |
java.lang.String |
toString() |
public SessionManager(WebApp webApp) throws java.lang.Exception
webApp
- the web-webApp webAppjava.lang.Exception
public SessionManagerMXBean getAdmin()
public java.lang.String getSessionPrefix()
public java.lang.String getAlternateSessionPrefix()
public int getCookieVersion()
public void setCookieVersion(int cookieVersion)
public void setCookiePort(java.lang.String port)
public void setCookieUseContextPath(boolean isCookieUseContextPath)
public java.lang.String getCookiePort()
public java.util.logging.Logger getDebug()
public void setAlwaysLoadSession(boolean load)
public void setAlwaysSaveSession(boolean save)
public boolean isSaveOnShutdown()
public boolean isSaveOnlyOnShutdown()
public boolean isSaveBeforeHeaders()
public boolean isSaveBeforeFlush()
public boolean isSaveAfterRequest()
public void setSaveMode(java.lang.String mode) throws ConfigException
ConfigException
public java.lang.String getSaveMode()
public void setSaveOnlyOnShutdown(boolean save)
public void setSaveOnShutdown(boolean save)
public void setSerializationType(java.lang.String type)
public void setSerializeCollectionType(boolean isEnable)
public boolean isHessianSerialization()
public void setInvalidateAfterListener(boolean inv)
public boolean isInvalidateAfterListener()
public int getActiveSessionCount()
public int getSessionActiveCount()
public long getSessionCreateCount()
public long getSessionTimeoutCount()
public long getSessionInvalidateCount()
public void addListener(HttpSessionListener listener)
public void addActivationListener(HttpSessionActivationListener listener)
public void addAttributeListener(HttpSessionAttributeListener listener)
public void setIgnoreSerializationErrors(boolean ignore)
public int getReuseSessionId()
public boolean reuseSessionId(boolean fromCookie)
public void setReuseSessionId(java.lang.String reuse) throws ConfigException
ConfigException
public boolean isClosed()
public void setUsePersistentStore(boolean enable) throws java.lang.Exception
java.lang.Exception
public boolean isUsePersistentStore()
public boolean isPersistenceEnabled()
public void setDestroyOnLru(boolean isDestroy)
public boolean isDestroyOnLru()
public java.lang.String getDistributionId()
public void setDistributionId(java.lang.String distributionId)
public long getSessionTimeout()
public void setSessionTimeout(long timeout)
public long getMaxIdleTime()
public int getSessionMax()
public void setSessionMax(int max)
public boolean enableSessionCookies()
public void setEnableCookies(boolean enableCookies)
public boolean enableSessionUrls()
public void setEnableUrlRewriting(boolean enableUrls)
public void setName(java.lang.String name)
setName
in interface SessionCookieConfig
public java.lang.String getName()
getName
in interface SessionCookieConfig
public void setDomain(java.lang.String domain)
setDomain
in interface SessionCookieConfig
public java.lang.String getDomain()
getDomain
in interface SessionCookieConfig
public void setPath(java.lang.String path)
setPath
in interface SessionCookieConfig
public java.lang.String getPath()
getPath
in interface SessionCookieConfig
public void setComment(java.lang.String comment)
setComment
in interface SessionCookieConfig
public java.lang.String getComment()
getComment
in interface SessionCookieConfig
public void setHttpOnly(boolean httpOnly)
setHttpOnly
in interface SessionCookieConfig
public boolean isHttpOnly()
isHttpOnly
in interface SessionCookieConfig
public void setSecure(boolean secure)
setSecure
in interface SessionCookieConfig
public boolean isSecure()
isSecure
in interface SessionCookieConfig
public void setMaxAge(int maxAge)
setMaxAge
in interface SessionCookieConfig
public int getMaxAge()
getMaxAge
in interface SessionCookieConfig
@Configurable public SessionCookieConfig createCookieConfig()
public void setCookieName(java.lang.String cookieName)
public void setTrackingMode(SessionTrackingMode mode)
public java.lang.String getCookieName()
public java.lang.String getSSLCookieName()
public java.lang.String getCookieDomain()
public void setCookieDomain(java.lang.String domain)
public java.lang.String getCookieDomainRegexp()
public void setCookieDomainRegexp(java.lang.String regexp)
public void setCookiePath(java.lang.String path)
public long getCookieMaxAge()
public void setCookieMaxAge(Period maxAge)
public boolean isCookieSecure()
public void setCookieSecure(boolean isSecure)
public boolean isCookieHttpOnly()
public void setCookieHttpOnly(boolean httpOnly)
public void setCookieLength(int cookieLength)
public long getCookieLength()
public void setCookieModuloCluster(boolean isModulo)
public void setCookieAppendServerIndex(boolean isAppend)
public boolean isCookieAppendServerIndex()
public void init()
public void start() throws java.lang.Exception
java.lang.Exception
public ByteStreamCache getSessionStore()
public SessionSerializer createSessionSerializer(java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public SessionDeserializer createSessionDeserializer(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public boolean containsSession(java.lang.String id)
public java.lang.String createSessionId(HttpServletRequest request)
request
- current requestpublic java.lang.String createSessionId(HttpServletRequest request, boolean create)
request
- current requestpublic java.lang.String createCookieValue()
public java.lang.String createSessionIdImpl(HttpServletRequest request)
public boolean isOwner(java.lang.String id)
protected java.lang.String createCookieValue(java.lang.Object owner)
public SessionImpl createSession(boolean isCreate, HttpServletRequest request, java.lang.String sessionId, long now, boolean fromCookie)
isCreate
- if the session doesn't exist, create itrequest
- current requestnow
- the time in millisecondsfromCookie
- true if the session id comes from a cookiepublic SessionImpl getSession(java.lang.String key, long now, boolean create, boolean fromCookie)
key
- the session idnow
- the time in millisecondspublic SessionImpl getSession(java.lang.String key)
public SessionImpl createSession(java.lang.String oldId, long now, HttpServletRequest request, boolean fromCookie)
oldId
- the id passed to the request. Reuse if possible.request
- - current HttpServletRequestfromCookie
- public void notifyRemove(java.lang.String id)
public java.lang.String getSessionSerializationDebug(java.lang.String id)
public java.lang.String getSessionAsJsonString(java.lang.String id)
public java.lang.String[] sessionIdList()
public java.lang.String getSessionsAsJsonString()
public long getEstimatedMemorySize()
public void handleAlarm(Alarm alarm)
handleAlarm
in interface AlarmListener
public void close()
public java.lang.String toString()
toString
in class java.lang.Object