public class InMemorySession extends Object implements Session
Session that is help in-memory.| Modifier and Type | Field and Description |
|---|---|
protected Map<CharSequence,Object> |
attributeMap |
protected MutableConvertibleValues<Object> |
attributes |
protected Instant |
lastAccessTime |
EMPTY| Modifier | Constructor and Description |
|---|---|
protected |
InMemorySession(String id,
Duration maxInactiveInterval)
Constructor.
|
protected |
InMemorySession(String id,
Instant creationTime,
Duration maxInactiveInterval)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
MutableConvertibleValues<Object> |
clear()
Clear all values.
|
<T> Optional<T> |
get(CharSequence name,
ArgumentConversionContext<T> conversionContext)
Resolve the given property for the given name.
|
Instant |
getCreationTime()
Returns the time when this session was created.
|
String |
getId()
A unique identifier for the session.
|
Instant |
getLastAccessedTime()
Returns the last time the client sent a request associated with this session as an
Instant. |
Duration |
getMaxInactiveInterval()
Returns the maximum time interval as a
Duration that sessions will be kept open between client accesses. |
boolean |
isModified() |
boolean |
isNew() |
Set<String> |
names() |
MutableConvertibleValues<Object> |
put(CharSequence key,
Object value)
Insert a value for the given key and value.
|
MutableConvertibleValues<Object> |
remove(CharSequence key)
Remove a value for the given key.
|
Session |
setLastAccessedTime(Instant instant)
Sets the last accessed time on the session.
|
Session |
setMaxInactiveInterval(Duration duration)
Specifies the duration between client requests before session should be invalidated.
|
void |
setNew(boolean aNew) |
Collection<Object> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitof, putAll, putAllasMap, asMap, asProperties, contains, empty, forEach, getValueType, isEmpty, iterator, subMap, subMap, subMapget, get, getforEach, spliteratorprotected final Map<CharSequence,Object> attributeMap
protected final MutableConvertibleValues<Object> attributes
protected Instant lastAccessTime
protected InMemorySession(String id, Duration maxInactiveInterval)
id - The session idmaxInactiveInterval - The max inactive interval@Nonnull public String getId()
Session@Nonnull public Instant getLastAccessedTime()
SessionInstant.
Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.
getLastAccessedTime in interface SessionInstant representing the time the session was last accessedpublic Session setMaxInactiveInterval(Duration duration)
SessionsetMaxInactiveInterval in interface Sessionduration - A duration specifying the max inactive intervalpublic Session setLastAccessedTime(Instant instant)
SessionsetLastAccessedTime in interface Sessioninstant - The instant that represents the last accessed timepublic Duration getMaxInactiveInterval()
SessionDuration that sessions will be kept open between client accesses.
After this interval, the servlet container will invalidate the session. The maximum time interval can be set
with the setMaxInactiveInterval method.getMaxInactiveInterval in interface SessionSession.setMaxInactiveInterval(java.time.Duration)public boolean isNew()
public boolean isModified()
isModified in interface Session@Nonnull public Instant getCreationTime()
SessiongetCreationTime in interface SessionInstant instancepublic MutableConvertibleValues<Object> put(CharSequence key, Object value)
MutableConvertibleValuesput in interface MutableConvertibleValues<Object>key - The keyvalue - The valuepublic MutableConvertibleValues<Object> remove(CharSequence key)
MutableConvertibleValuesremove in interface MutableConvertibleValues<Object>key - The keypublic MutableConvertibleValues<Object> clear()
MutableConvertibleValuesclear in interface MutableConvertibleValues<Object>public Set<String> names()
names in interface ConvertibleValues<Object>public Collection<Object> values()
values in interface ConvertibleValues<Object>public <T> Optional<T> get(CharSequence name, ArgumentConversionContext<T> conversionContext)
ValueResolverget in interface ValueResolver<CharSequence>T - The concrete typename - The nameconversionContext - The conversion contextpublic void setNew(boolean aNew)
aNew - Set is new