public class InMemorySession extends java.lang.Object implements Session
Session
that is help in-memory.Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.CharSequence,java.lang.Object> |
attributeMap |
protected MutableConvertibleValues<java.lang.Object> |
attributes |
protected java.time.Instant |
lastAccessTime |
EMPTY
Modifier | Constructor and Description |
---|---|
protected |
InMemorySession(java.lang.String id,
java.time.Duration maxInactiveInterval)
Constructor.
|
protected |
InMemorySession(java.lang.String id,
java.time.Instant creationTime,
java.time.Duration maxInactiveInterval)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
MutableConvertibleValues<java.lang.Object> |
clear()
Clear all values.
|
<T> java.util.Optional<T> |
get(java.lang.CharSequence name,
ArgumentConversionContext<T> conversionContext)
Resolve the given property for the given name.
|
java.time.Instant |
getCreationTime()
Returns the time when this session was created.
|
java.lang.String |
getId()
A unique identifier for the session.
|
java.time.Instant |
getLastAccessedTime()
Returns the last time the client sent a request associated with this session as an
Instant . |
java.time.Duration |
getMaxInactiveInterval()
Returns the maximum time interval as a
Duration that sessions will be kept open between client accesses. |
boolean |
isModified() |
boolean |
isNew() |
java.util.Set<java.lang.String> |
names() |
MutableConvertibleValues<java.lang.Object> |
put(java.lang.CharSequence key,
java.lang.Object value)
Insert a value for the given key and value.
|
MutableConvertibleValues<java.lang.Object> |
remove(java.lang.CharSequence key)
Remove a value for the given key.
|
Session |
setLastAccessedTime(java.time.Instant instant)
Sets the last accessed time on the session.
|
Session |
setMaxInactiveInterval(java.time.Duration duration)
Specifies the duration between client requests before session should be invalidated.
|
void |
setNew(boolean aNew) |
java.util.Collection<java.lang.Object> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
of, putAll, putAll
asMap, asMap, asProperties, contains, empty, forEach, getValue, getValueType, isEmpty, iterator, subMap, subMap, subMap
get, get, get
protected final java.util.Map<java.lang.CharSequence,java.lang.Object> attributeMap
protected final MutableConvertibleValues<java.lang.Object> attributes
protected java.time.Instant lastAccessTime
protected InMemorySession(java.lang.String id, java.time.Duration maxInactiveInterval)
id
- The session idmaxInactiveInterval
- The max inactive intervalprotected InMemorySession(java.lang.String id, java.time.Instant creationTime, java.time.Duration maxInactiveInterval)
id
- The session idcreationTime
- The creation timemaxInactiveInterval
- The max inactive interval@NonNull public java.lang.String getId()
Session
@NonNull public java.time.Instant getLastAccessedTime()
Session
Instant
.
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 Session
Instant
representing the time the session was last accessedpublic Session setMaxInactiveInterval(java.time.Duration duration)
Session
setMaxInactiveInterval
in interface Session
duration
- A duration specifying the max inactive intervalpublic Session setLastAccessedTime(java.time.Instant instant)
Session
setLastAccessedTime
in interface Session
instant
- The instant that represents the last accessed timepublic java.time.Duration getMaxInactiveInterval()
Session
Duration
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 Session
Session.setMaxInactiveInterval(java.time.Duration)
public boolean isNew()
public boolean isModified()
isModified
in interface Session
@NonNull public java.time.Instant getCreationTime()
Session
getCreationTime
in interface Session
Instant
instancepublic MutableConvertibleValues<java.lang.Object> put(java.lang.CharSequence key, java.lang.Object value)
MutableConvertibleValues
put
in interface MutableConvertibleValues<java.lang.Object>
key
- The keyvalue
- The valuepublic MutableConvertibleValues<java.lang.Object> remove(java.lang.CharSequence key)
MutableConvertibleValues
remove
in interface MutableConvertibleValues<java.lang.Object>
key
- The keypublic MutableConvertibleValues<java.lang.Object> clear()
MutableConvertibleValues
clear
in interface MutableConvertibleValues<java.lang.Object>
public java.util.Set<java.lang.String> names()
names
in interface ConvertibleValues<java.lang.Object>
public java.util.Collection<java.lang.Object> values()
values
in interface ConvertibleValues<java.lang.Object>
public <T> java.util.Optional<T> get(java.lang.CharSequence name, ArgumentConversionContext<T> conversionContext)
ValueResolver
get
in interface ValueResolver<java.lang.CharSequence>
T
- The concrete typename
- The nameconversionContext
- The conversion contextpublic void setNew(boolean aNew)
aNew
- Set is new