public class SessionManager<T> extends Object
SessionId) to
session holders (SessionHolder), and (optionally)
automatically expires sessions (map entries) which remain unused
for a time interval that exceeds the session lifespan. This
expiration is performed at regular intervals by a reaper thread,
initiated during construction as part of the caller's thread group;
the interval between scans is normally 5% of the session lifespan.| Modifier and Type | Field and Description |
|---|---|
static long |
INFINITE_SESSION_LIFESPAN
A sentinel value for an infinite session lifespan (non-expiring
sessions).
|
static long |
MAX_SCAN_INTERVAL
The maximum sleep interval between reaper scans, in ms.
|
| Constructor and Description |
|---|
SessionManager()
Creates a new session manager whose sessions never expire.
|
SessionManager(long sessionLife)
Creates a new session manager whose sessions have the given
lifespan, in ms.
|
SessionManager(SessionFactory<T> sessionFactory)
Creates a new session manager whose sessions are created by the
given factory, and which never expire.
|
SessionManager(SessionFactory<T> sessionFactory,
long sessionLife)
Creates a new session manager whose sessions are created by the
given factory, and which have the given lifespan, in ms.
|
| Modifier and Type | Method and Description |
|---|---|
SessionHolder<T> |
get(SessionId id)
Returns the holder that the receiver associates with the given
session ID.
|
long |
getLifespan()
Returns the lifespan of the sessions managed by the receiver.
|
NodeId |
getServerId()
Returns the receiver's server ID.
|
SessionFactory<T> |
getSessionFactory()
Returns the receiver's session factory.
|
void |
put(SessionId id,
SessionHolder<T> holder)
Adds the given holder, associated with the given session ID, to
the receiver.
|
void |
remove(SessionId id)
Removes the holder that the receiver associates with the given
session ID.
|
public static final long MAX_SCAN_INTERVAL
public static final long INFINITE_SESSION_LIFESPAN
public SessionManager(SessionFactory<T> sessionFactory, long sessionLife)
sessionFactory - The session factory. It may be null.sessionLife - The lifespan. Use INFINITE_SESSION_LIFESPAN for an infinite lifespan.public SessionManager(long sessionLife)
sessionLife - The lifespan. Use INFINITE_SESSION_LIFESPAN for an infinite lifespan.public SessionManager(SessionFactory<T> sessionFactory)
sessionFactory - The session factory. It may be null.public SessionManager()
public NodeId getServerId()
public SessionFactory<T> getSessionFactory()
public long getLifespan()
public void put(SessionId id, SessionHolder<T> holder)
id - The session ID.holder - The holder.public SessionHolder<T> get(SessionId id)
id - The session ID.public void remove(SessionId id)
id - The session ID.Copyright © 2015. All Rights Reserved.