Class InMemorySessionManager
- All Implemented Interfaces:
Iterable<ComponentType>
,Channel
,ComponentType
,Eligible
,Manager
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jgrapes.http.SessionManager
SessionManager.SessionManagerInfo, SessionManager.SessionManagerMXBean, SessionManager.SessionManagerSummaryMXBean
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new session manager with its channel set to itself and the path set to “/”.InMemorySessionManager
(String path) Creates a new session manager with its channel set to itself and the path set to the given path.InMemorySessionManager
(Channel componentChannel) Creates a new session manager with its channel set to the given channel, the path to “/” and the handler’s priority to 1000.InMemorySessionManager
(Channel componentChannel, String path) Creates a new session manager with the given channel and path.InMemorySessionManager
(Channel componentChannel, String pattern, int priority, String path) Creates a new session manager using the given channel and path. -
Method Summary
Modifier and TypeMethodDescriptionprotected Session
createSession
(String sessionId) Creates a new session with the given id.lookupSession
(String sessionId) Lookup the session with the given id.protected void
removeSession
(String sessionId) Removes the given session from the cache.protected int
Return the number of established sessions.startDiscarding
(long absoluteTimeout, long idleTimeout) Start discarding all sessions (generateDiscardSession
events) that have reached their absolute or idle timeout.Methods inherited from class org.jgrapes.http.SessionManager
absoluteTimeout, addSessionCookie, derivePattern, hasTimedOut, idleTimeout, idName, maxSessions, onDiscard, onProtocolSwitchAccepted, onRequest, path, setAbsoluteTimeout, setIdleTimeout, setIdName, setMaxSessions, setSessionSupplier
Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setName
Methods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGenerator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
InMemorySessionManager
public InMemorySessionManager()Creates a new session manager with its channel set to itself and the path set to “/”.The manager handles all
Request
events. -
InMemorySessionManager
Creates a new session manager with its channel set to itself and the path set to the given path.The manager handles all requests that match the given path, using the same rules as browsers do for selecting the cookies that are to be sent.
- Parameters:
path
- the path
-
InMemorySessionManager
Creates a new session manager with its channel set to the given channel, the path to “/” and the handler’s priority to 1000.The manager handles all
Request
events.- Parameters:
componentChannel
- the component channel
-
InMemorySessionManager
Creates a new session manager with the given channel and path.The manager handles all requests that match the given path, using the same rules as browsers do for selecting the cookies that are to be sent. The request handler’s priority is set to 1000.
- Parameters:
componentChannel
- the component channelpath
- the path
-
InMemorySessionManager
Creates a new session manager using the given channel and path.The manager handles only requests that match the given pattern. The
Request
handler is registered with the given priority.This constructor can be used if special handling of top level requests is needed.
- Parameters:
componentChannel
- the component channelpattern
- the path part of aResourcePattern
priority
- the prioritypath
- the path
-
-
Method Details
-
startDiscarding
Description copied from class:SessionManager
Start discarding all sessions (generateDiscardSession
events) that have reached their absolute or idle timeout.Do not make the sessions unavailable yet.
Returns the time when the next timeout occurs. This method is called only if at least one of the timeouts has been specified.
Implementations have to take care that sessions are only discarded once. As they must remain available while the
DiscardSession
event is handled this may require marking them as being discarded.- Specified by:
startDiscarding
in classSessionManager
- Parameters:
absoluteTimeout
- the absolute timeoutidleTimeout
- the idle timeout- Returns:
- the next timeout (empty if no sessions left)
-
createSession
Description copied from class:SessionManager
Creates a new session with the given id.- Specified by:
createSession
in classSessionManager
- Parameters:
sessionId
-- Returns:
- the session
-
lookupSession
Description copied from class:SessionManager
Lookup the session with the given id.Lookup will fail if the session has timed out.
- Specified by:
lookupSession
in classSessionManager
- Parameters:
sessionId
-- Returns:
- the session
-
removeSession
Description copied from class:SessionManager
Removes the given session from the cache.- Specified by:
removeSession
in classSessionManager
- Parameters:
sessionId
- the session id
-
sessionCount
Description copied from class:SessionManager
Return the number of established sessions.- Specified by:
sessionCount
in classSessionManager
- Returns:
- the result
-