Top Description Inners Fields Constructors Methods
org.mortbay.jetty.servlet

public Class HashSessionManager

extends AbstractSessionManager
Class Inheritance
Imports
java.io.DataInputStream, .DataOutputStream, .File, .FileInputStream, .FileOutputStream, .IOException, .InputStream, .ObjectInputStream, .ObjectOutputStream, .OutputStream, java.util.ArrayList, .Collections, .HashMap, .Iterator, .Map, .Timer, .TimerTask, java.util.concurrent.ConcurrentHashMap, javax.servlet.http.HttpServletRequest, org.mortbay.log.Log, org.mortbay.util.LazyList

An in-memory implementation of SessionManager.
Author
Greg Wilkins (gregw)

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
protected class

Field Summary

Modifier and TypeField and Description
private static int
private int
private TimerTask
private int
protected Map<K, V>
private File
private TimerTask
private Timer
Inherited from org.mortbay.jetty.servlet.AbstractSessionManager:
__distantFuture_context_dftMaxIdleSecs_httpOnly_loader_maxCookieAge_maxSessions_minSessions_nodeIdInSessionId_refreshCookieAge_secureCookies_sessionAttributeListeners_sessionCookie_sessionDomain_sessionHandler_sessionIdManager_sessionIdPathParameterName_sessionIdPathParameterNamePrefix_sessionListeners_sessionPath

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
public void
public void
public int
public int

Returns:

seconds
getScavengePeriod
()

public AbstractSessionManager.Session
getSession(String
The session ID in the cluster, stripped of any worker name.
idInCluster
)

Implements abstract org.mortbay.jetty.servlet.AbstractSessionManager.getSession.

Get a known existingsession
public Map<K, V>
public int
public File
protected void
protected AbstractSessionManager.Session
newSession(HttpServletRequest request)

Implements abstract org.mortbay.jetty.servlet.AbstractSessionManager.newSession.

Create a new session instance
protected AbstractSessionManager.Session
newSession(long created, String clusterId)

protected void
public HashSessionManager.Session
public void
public void
private void
scavenge()

Find sessions that have timed out and invalidate them.

public void
setMaxInactiveInterval(int seconds)

Overrides org.mortbay.jetty.servlet.AbstractSessionManager.setMaxInactiveInterval.

Implements org.mortbay.jetty.SessionManager.setMaxInactiveInterval.

Sets the max period of inactivity, after which the session is invalidated, in seconds.
public void
setSavePeriod(int seconds)

public void
setScavengePeriod(int seconds)

public void
Inherited from org.mortbay.jetty.servlet.AbstractSessionManager:
accessaddEventListeneraddSessionclearEventListenerscompletegetClusterIdgetHttpOnlygetHttpSessiongetIdManagergetMaxCookieAgegetMaxInactiveIntervalgetMaxSessionsgetMetaManagergetMinSessionsgetNodeIdgetRefreshCookieAgegetSecureCookiesgetSessionCookiegetSessionCookiegetSessionDomaingetSessionHandlergetSessionIdPathParameterNamegetSessionIdPathParameterNamePrefixgetSessionPathisNodeIdInSessionIdisUsingCookiesisValidnewHttpSessionremoveEventListenerremoveSessionremoveSessionresetStatssetHttpOnlysetIdManagersetMaxCookieAgesetMetaManagersetNodeIdInSessionIdsetRefreshCookieAgesetSecureCookiessetSessionCookiesetSessionDomainsetSessionHandlersetSessionIdPathParameterNamesetSessionPathsetUsingCookies

Field Detail

__idback to summary
private static int __id
_savePeriodMsback to summary
private int _savePeriodMs
_saveTaskback to summary
private TimerTask _saveTask
_scavengePeriodMsback to summary
private int _scavengePeriodMs
_sessionsback to summary
protected Map<K, V> _sessions
_storeDirback to summary
private File _storeDir
_taskback to summary
private TimerTask _task
_timerback to summary
private Timer _timer

Constructor Detail

HashSessionManagerback to summary
public HashSessionManager()

Method Detail

addSessionback to summary
protected void addSession(AbstractSessionManager.Session session)

Implements abstract org.mortbay.jetty.servlet.AbstractSessionManager.addSession.

doStartback to summary
public void doStart() throws Exception

Overrides org.mortbay.jetty.servlet.AbstractSessionManager.doStart.

doStopback to summary
public void doStop() throws Exception

Overrides org.mortbay.jetty.servlet.AbstractSessionManager.doStop.

getSavePeriodback to summary
public int getSavePeriod()
getScavengePeriodback to summary
public int getScavengePeriod()
Returns:int

seconds

getSessionback to summary
public AbstractSessionManager.Session getSession(String idInCluster)

Implements abstract org.mortbay.jetty.servlet.AbstractSessionManager.getSession.

Doc from org.mortbay.jetty.servlet.AbstractSessionManager.getSession.

Get a known existingsession

Parameters
idInCluster:String

The session ID in the cluster, stripped of any worker name.

Returns:AbstractSessionManager.Session

A Session or null if none exists.

getSessionMapback to summary
public Map<K, V> getSessionMap()

Implements abstract org.mortbay.jetty.servlet.AbstractSessionManager.getSessionMap.

getSessionsback to summary
public int getSessions()

Implements abstract org.mortbay.jetty.servlet.AbstractSessionManager.getSessions.

getStoreDirectoryback to summary
public File getStoreDirectory()
invalidateSessionsback to summary
protected void invalidateSessions()

Implements abstract org.mortbay.jetty.servlet.AbstractSessionManager.invalidateSessions.

newSessionback to summary
protected AbstractSessionManager.Session newSession(HttpServletRequest request)

Implements abstract org.mortbay.jetty.servlet.AbstractSessionManager.newSession.

Doc from org.mortbay.jetty.servlet.AbstractSessionManager.newSession.

Create a new session instance

newSessionback to summary
protected AbstractSessionManager.Session newSession(long created, String clusterId)
removeSessionback to summary
protected void removeSession(String clusterId)

Implements abstract org.mortbay.jetty.servlet.AbstractSessionManager.removeSession.

restoreSessionback to summary
public HashSessionManager.Session restoreSession(InputStream is) throws Exception
restoreSessionsback to summary
public void restoreSessions() throws Exception
saveSessionsback to summary
public void saveSessions() throws Exception
scavengeback to summary
private void scavenge()

Find sessions that have timed out and invalidate them. This runs in the SessionScavenger thread.

setMaxInactiveIntervalback to summary
public void setMaxInactiveInterval(int seconds)

Overrides org.mortbay.jetty.servlet.AbstractSessionManager.setMaxInactiveInterval.

Implements org.mortbay.jetty.SessionManager.setMaxInactiveInterval.

Doc from org.mortbay.jetty.SessionManager.setMaxInactiveInterval.

Sets the max period of inactivity, after which the session is invalidated, in seconds.

setSavePeriodback to summary
public void setSavePeriod(int seconds)
setScavengePeriodback to summary
public void setScavengePeriod(int seconds)
setStoreDirectoryback to summary
public void setStoreDirectory(File dir)
org.mortbay.jetty.servlet back to summary

protected Class HashSessionManager.ClassLoadingObjectInputStream

extends ObjectInputStream
Class Inheritance

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public Class<T>
resolveClass(ObjectStreamClass
an instance of class ObjectStreamClass
cl
)

Overrides java.io.ObjectInputStream.resolveClass.

Load the local class equivalent of the specified stream class description.
Inherited from java.io.ObjectInputStream:
availableclosedefaultReadObjectenableResolveObjectgetObjectInputFilterreadreadreadBooleanreadBytereadCharreadClassDescriptorreadDoublereadFieldsreadFloatreadFullyreadFullyreadIntreadLinereadLongreadObjectreadObjectOverridereadShortreadStreamHeaderreadUnsharedreadUnsignedBytereadUnsignedShortreadUTFregisterValidationresolveObjectresolveProxyClasssetObjectInputFilterskipBytes

Constructor Detail

ClassLoadingObjectInputStreamback to summary
public ClassLoadingObjectInputStream(InputStream in) throws IOException
ClassLoadingObjectInputStreamback to summary
public ClassLoadingObjectInputStream() throws IOException

Method Detail

resolveClassback to summary
public Class<T> resolveClass(ObjectStreamClass cl) throws IOException, ClassNotFoundException

Overrides java.io.ObjectInputStream.resolveClass.

Doc from java.io.ObjectInputStream.resolveClass.

Load the local class equivalent of the specified stream class description. Subclasses may implement this method to allow classes to be fetched from an alternate source.

The corresponding method in ObjectOutputStream is annotateClass. This method will be invoked only once for each unique class in the stream. This method can be implemented by subclasses to use an alternate loading mechanism but must return a Class object. Once returned, if the class is not an array class, its serialVersionUID is compared to the serialVersionUID of the serialized class, and if there is a mismatch, the deserialization fails and an InvalidClassException is thrown.

The default implementation of this method in ObjectInputStream returns the result of calling

Class.forName(desc.getName(), false, loader)
Class.forName(desc.getName(), false, loader)
where loader is the first class loader on the current thread's stack (starting from the currently executing method) that is neither the platform class loader nor its ancestor; otherwise, loader is the platform class loader. If this call results in a ClassNotFoundException and the name of the passed ObjectStreamClass instance is the Java language keyword for a primitive type or void, then the Class object representing that primitive type or void will be returned (e.g., an ObjectStreamClass with the name "int" will be resolved to Integer.TYPE). Otherwise, the ClassNotFoundException will be thrown to the caller of this method.
Parameters
cl:ObjectStreamClass

an instance of class ObjectStreamClass

Returns:Class<T>

a Class object corresponding to desc

Exceptions
IOException:
any of the usual Input/Output exceptions.
ClassNotFoundException:
if class of a serialized object cannot be found.
org.mortbay.jetty.servlet back to summary

protected Class HashSessionManager.Session

extends Session
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long
Inherited from org.mortbay.jetty.servlet.AbstractSessionManager.Session:
_accessed_clusterId_cookieSet_created_doInvalidate_idChanged_invalid_lastAccessed_maxIdleMs_newSession_nodeId_requests_values

Constructor Summary

AccessConstructor and Description
protected
protected
Session(long created, String clusterId)

Method Summary

Modifier and TypeMethod and Description
public void
invalidate()

Overrides org.mortbay.jetty.servlet.AbstractSessionManager.Session.invalidate.

Implements javax.servlet.http.HttpSession.invalidate.

Invalidates this session then unbinds any objects bound to it.
protected Map<K, V>
public void
public void
public void
setMaxInactiveInterval(int
An integer specifying the number of seconds
secs
)

Overrides org.mortbay.jetty.servlet.AbstractSessionManager.Session.setMaxInactiveInterval.

Implements javax.servlet.http.HttpSession.setMaxInactiveInterval.

Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.
Inherited from org.mortbay.jetty.servlet.AbstractSessionManager.Session:
accessbindValuecompletecookieSetdidActivatedoInvalidategetAttributegetAttributeNamesgetClusterIdgetCookieSetTimegetCreationTimegetIdgetLastAccessedTimegetMaxInactiveIntervalgetNodeIdgetServletContextgetSessiongetSessionContextgetValuegetValueNamesinitValuesisIdChangedisNewisValidputValueremoveAttributeremoveValuesetAttributesetIdChangedtimeouttoStringunbindValuewillPassivate

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

Sessionback to summary
protected Session(HttpServletRequest request)
Sessionback to summary
protected Session(long created, String clusterId)

Method Detail

invalidateback to summary
public void invalidate() throws IllegalStateException

Overrides org.mortbay.jetty.servlet.AbstractSessionManager.Session.invalidate.

Implements javax.servlet.http.HttpSession.invalidate.

Doc from javax.servlet.http.HttpSession.invalidate.

Invalidates this session then unbinds any objects bound to it.

Exceptions
IllegalStateException:
if this method is called on an already invalidated session
newAttributeMapback to summary
protected Map<K, V> newAttributeMap()

Implements abstract org.mortbay.jetty.servlet.AbstractSessionManager.Session.newAttributeMap.

removeback to summary
public void remove()
saveback to summary
public void save(OutputStream os) throws IOException
setMaxInactiveIntervalback to summary
public void setMaxInactiveInterval(int secs)

Overrides org.mortbay.jetty.servlet.AbstractSessionManager.Session.setMaxInactiveInterval.

Implements javax.servlet.http.HttpSession.setMaxInactiveInterval.

Doc from javax.servlet.http.HttpSession.setMaxInactiveInterval.

Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.

An interval value of zero or less indicates that the session should never timeout.

Parameters
secs:int

An integer specifying the number of seconds