public class ValueSessionStore<T extends java.lang.Comparable<T>> extends java.lang.Object implements ISessionStore<T>, IValueStore<T>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_EXPIRATION_MILLIS
The default expiration time for session objects is 30 minutes.
|
static int |
DEFAULT_POLLING_MILLIS
The default polling interval to determine expired objects is 1 minute.
|
Constructor and Description |
---|
ValueSessionStore(int expirationMillis,
int pollingIntervalMillis)
Overloaded constructor, initializes session with a session expiration time and polling interval in milliseconds.
|
ValueSessionStore(int expirationMillis,
int pollingIntervalMillis,
java.lang.Class<?> genericTypeParameter)
Overloaded constructor, initializes session with a session expiration time and polling interval in milliseconds.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(T item)
Adds an item to the collection Returns true if successful.
|
void |
clear()
Clears the collection.
|
boolean |
contains(T item)
Returns true if an item is contained in the collection.
|
boolean |
expire(T item)
Expires the time of a session item, i.e.
|
int |
getExpirationMillis()
Gets the duration of a session in milliseconds.
|
java.lang.Class<?> |
getGenericTypeParameter()
Returns the class generic type parameters.
|
int |
getPollingIntervalMillis()
Gets the polling interval in milliseconds.
|
java.util.Iterator<T> |
iterator()
Returns an enumerator for a copy of the collection.
|
void |
lock()
Locks the object
|
boolean |
refresh(T item)
Renews the session expiration time for an item.
|
boolean |
remove(T item)
Removes an item from the collection.
|
int |
size()
Returns the collection size, volatile value.
|
T[] |
toArray()
Puts all elements in an array and returns them.
|
ReifiedList<T> |
toList()
Puts all elements in a list and returns them.
|
java.lang.String |
toString() |
void |
unlock()
Unlocks the object.
|
public static final int DEFAULT_EXPIRATION_MILLIS
public static final int DEFAULT_POLLING_MILLIS
public ValueSessionStore(int expirationMillis, int pollingIntervalMillis)
java.lang.IllegalArgumentException
- When the values provided are out of range.SuperTypeTokenException
- When called without using anonymous class semantics.public ValueSessionStore(int expirationMillis, int pollingIntervalMillis, java.lang.Class<?> genericTypeParameter)
java.lang.IllegalArgumentException
- When the values provided are out of range.java.lang.NullPointerException
- When the generic type parameter is null.public boolean add(T item)
add
in interface IValueStore<T extends java.lang.Comparable<T>>
item
- The item to add.java.lang.NullPointerException
- When the item is null.public void clear()
clear
in interface IValueStore<T extends java.lang.Comparable<T>>
public boolean contains(T item)
contains
in interface IValueStore<T extends java.lang.Comparable<T>>
item
- The item to find.java.lang.NullPointerException
- When the item is null.public boolean expire(T item)
expire
in interface ISessionStore<T extends java.lang.Comparable<T>>
java.lang.NullPointerException
- When the item is null.public int getExpirationMillis()
getExpirationMillis
in interface ISessionStore<T extends java.lang.Comparable<T>>
public int getPollingIntervalMillis()
getPollingIntervalMillis
in interface ISessionStore<T extends java.lang.Comparable<T>>
public java.lang.Class<?> getGenericTypeParameter()
getGenericTypeParameter
in interface ReifiedIterable<T extends java.lang.Comparable<T>>
public java.util.Iterator<T> iterator()
public boolean refresh(T item)
refresh
in interface ISessionStore<T extends java.lang.Comparable<T>>
java.lang.NullPointerException
- When the item is null.public boolean remove(T item)
remove
in interface IValueStore<T extends java.lang.Comparable<T>>
item
- The item to find.java.lang.NullPointerException
- When the item is null.public int size()
size
in interface IValueStore<T extends java.lang.Comparable<T>>
public T[] toArray()
toArray
in interface IValueStore<T extends java.lang.Comparable<T>>
public ReifiedList<T> toList()
toList
in interface IValueStore<T extends java.lang.Comparable<T>>
public void unlock()
public java.lang.String toString()
toString
in class java.lang.Object