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, wait
of, putAll, putAll
asMap, asMap, asProperties, contains, empty, forEach, getValue, getValueType, isEmpty, iterator, subMap, subMap, subMap
get, get, get
forEach, spliterator
protected 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()
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(Duration duration)
Session
setMaxInactiveInterval
in interface Session
duration
- A duration specifying the max inactive intervalpublic Session setLastAccessedTime(Instant instant)
Session
setLastAccessedTime
in interface Session
instant
- The instant that represents the last accessed timepublic 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 Instant getCreationTime()
Session
getCreationTime
in interface Session
Instant
instancepublic MutableConvertibleValues<Object> put(CharSequence key, Object value)
MutableConvertibleValues
put
in interface MutableConvertibleValues<Object>
key
- The keyvalue
- The valuepublic MutableConvertibleValues<Object> remove(CharSequence key)
MutableConvertibleValues
remove
in interface MutableConvertibleValues<Object>
key
- The keypublic MutableConvertibleValues<Object> clear()
MutableConvertibleValues
clear
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)
ValueResolver
get
in interface ValueResolver<CharSequence>
T
- The concrete typename
- The nameconversionContext
- The conversion contextpublic void setNew(boolean aNew)
aNew
- Set is new