|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.bb.util.SessionManager
public class SessionManager
A SessionManager is used to manage sessions. Sessions are objects which live a distinct time.
Each time a session is used or touched, the livetime of that session is renewed.
If the life time of a session is over, it is removed from the SessionManager.
A session object may implement the Session.Callback interface, and if it does,
its callback function is called before removal.
| Nested Class Summary | |
|---|---|
static interface |
SessionManager.Callback
This interface is used by the SessionManager, which maintains objects which live a distinct time. |
| Constructor Summary | |
|---|---|
SessionManager(int timeoutMilli)
Deprecated. use the constructor with long instead! |
|
SessionManager(long timeoutMilli)
This class is used to maintain sessions, that are objects which live a distinct time. |
|
SessionManager(long timeoutMilli,
int maxCountOfSessions)
This class is used to maintain sessions, that are objects which live a distinct time. |
|
| Method Summary | |
|---|---|
void |
clear()
Clears this SessionManager so that it contains no sessions. |
boolean |
contains(java.lang.Object session)
Tests if some key maps into the specified value in this SessionManager. |
boolean |
containsKey(java.lang.Object key)
Tests whether the specified object is a key in this SessionManager. |
java.util.Iterator |
elements()
Returns an enumeration of the values in this SessionManager. |
java.lang.Object |
get(java.lang.Object key)
Returns the value to which the specified key is mapped in this SessionManager. |
long |
getCreationMillis(java.lang.Object key)
Returns the creation time for the given key. |
long |
getDeathMillis(java.lang.Object key)
Returns the death time for the given key. |
int |
getMaxCount()
Get current max count of sessions. |
long |
getTimeout()
Get current default timout value. |
boolean |
isEmpty()
Tests if this SessionManager maps no keys to values. |
java.util.Iterator |
keys()
Returns an enumeration of the keys in this SessionManager. |
static java.lang.String |
newKey()
Create a new session key. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Maps the specified key to the specified value in this SessionManager. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value,
int timeoutMilli)
Deprecated. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value,
long timeoutMilli)
Maps the specified key to the specified value in this SessionManager, using the SessionManager's timeout. |
java.lang.Object |
remove(java.lang.Object key)
Removes the key (and its corresponding value) from this SessionManager. |
java.lang.Object |
removeButAsk(java.lang.Object key)
Removes the key (and its corresponding value) from this SessionManager. |
void |
setMaxCount(int max)
Set a new maximum size. |
static void |
setRandom(java.util.Random rnd)
Set a new random generator for all SessionManagers. |
void |
setTimeout(long timeoutMilli)
Set a new default timout value. |
int |
size()
Returns the number of keys in this SessionManager. |
java.lang.Object |
touch(java.lang.Object key)
Sets the new timeout for the given key with the default timeout. |
java.lang.Object |
touch(java.lang.Object key,
long timeoutMilli)
Sets the new timeout for the given key. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SessionManager(long timeoutMilli,
int maxCountOfSessions)
timeoutMilli - an int specifying the timeout in msmaxCountOfSessions - limit the count of used sessions.public SessionManager(long timeoutMilli)
timeoutMilli - an int specifying the timeout in mspublic SessionManager(int timeoutMilli)
timeoutMilli - an int specifying the timeout in ms| Method Detail |
|---|
public static void setRandom(java.util.Random rnd)
rnd - the new random generatorpublic void clear()
public boolean contains(java.lang.Object session)
session - a sessin to search for
public boolean containsKey(java.lang.Object key)
key - possible key.
public java.util.Iterator elements()
public java.lang.Object get(java.lang.Object key)
key - a key in the SessionManager.
public int getMaxCount()
setMaxCount(int)public long getTimeout()
setTimeout(long)public boolean isEmpty()
public java.util.Iterator keys()
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
key - the key or null, then a new key is created.value - the value.
public java.lang.Object put(java.lang.Object key,
java.lang.Object value,
int timeoutMilli)
key - the key or null, then a new key is created.value - the value.timeoutMilli - a distinct timeout value for the given key
public java.lang.Object put(java.lang.Object key,
java.lang.Object value,
long timeoutMilli)
key - the key or null, then a new key is created.value - the value.timeoutMilli - a distinct timeout value for the given key
public long getCreationMillis(java.lang.Object key)
key - the key
public long getDeathMillis(java.lang.Object key)
key - the key
public java.lang.Object removeButAsk(java.lang.Object key)
key - the key that needs to be removed.
public java.lang.Object remove(java.lang.Object key)
key - the key that needs to be removed.
public void setMaxCount(int max)
max - the new max count of sessionsgetMaxCount()public void setTimeout(long timeoutMilli)
timeoutMilli - the new default timout valuegetTimeout()public int size()
public java.lang.Object touch(java.lang.Object key)
key - the key
public java.lang.Object touch(java.lang.Object key,
long timeoutMilli)
key - the keytimeoutMilli - the new timeout to set
public static java.lang.String newKey()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||