Package io.micronaut.session
Class InMemorySession
java.lang.Object
io.micronaut.session.InMemorySession
- All Implemented Interfaces:
io.micronaut.core.convert.ConversionServiceProvider
,io.micronaut.core.convert.value.ConvertibleValues<Object>
,io.micronaut.core.convert.value.MutableConvertibleValues<Object>
,io.micronaut.core.value.ValueResolver<CharSequence>
,Session
,Iterable<Map.Entry<String,
Object>>
A
Session
that is help in-memory.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Map<CharSequence,
Object> protected final io.micronaut.core.convert.value.MutableConvertibleValues<Object>
protected Instant
Fields inherited from interface io.micronaut.core.convert.value.ConvertibleValues
EMPTY
-
Constructor Summary
ModifierConstructorDescriptionprotected
InMemorySession
(String id, Duration maxInactiveInterval) Constructor.protected
InMemorySession
(String id, Instant creationTime, Duration maxInactiveInterval) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.core.convert.value.MutableConvertibleValues<Object>
clear()
<T> Optional<T>
get
(CharSequence name, io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext) @NonNull Instant
Returns the time when this session was created.@NonNull String
getId()
A unique identifier for the session.@NonNull Instant
Returns the last time the client sent a request associated with this session as anInstant
.Returns the maximum time interval as aDuration
that sessions will be kept open between client accesses.boolean
boolean
isNew()
names()
io.micronaut.core.convert.value.MutableConvertibleValues<Object>
put
(CharSequence key, Object value) io.micronaut.core.convert.value.MutableConvertibleValues<Object>
remove
(CharSequence key) setLastAccessedTime
(Instant instant) Sets the last accessed time on the session.setMaxInactiveInterval
(Duration duration) Specifies the duration between client requests before session should be invalidated.void
setNew
(boolean aNew) values()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.convert.value.ConvertibleValues
asMap, asMap, asProperties, contains, forEach, getConversionService, getValue, getValueType, isEmpty, iterator, subMap, subMap, subMap
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface io.micronaut.core.convert.value.MutableConvertibleValues
putAll, putAll
Methods inherited from interface io.micronaut.core.value.ValueResolver
get, get, get
-
Field Details
-
attributeMap
-
attributes
-
lastAccessTime
-
-
Constructor Details
-
InMemorySession
Constructor.- Parameters:
id
- The session idmaxInactiveInterval
- The max inactive interval
-
InMemorySession
Constructor.- Parameters:
id
- The session idcreationTime
- The creation timemaxInactiveInterval
- The max inactive interval
-
-
Method Details
-
getId
Description copied from interface:Session
A unique identifier for the session. -
getLastAccessedTime
Description copied from interface:Session
Returns the last time the client sent a request associated with this session as anInstant
.Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.
- Specified by:
getLastAccessedTime
in interfaceSession
- Returns:
- An
Instant
representing the time the session was last accessed
-
setMaxInactiveInterval
Description copied from interface:Session
Specifies the duration between client requests before session should be invalidated.- Specified by:
setMaxInactiveInterval
in interfaceSession
- Parameters:
duration
- A duration specifying the max inactive interval- Returns:
- The session
-
setLastAccessedTime
Description copied from interface:Session
Sets the last accessed time on the session.- Specified by:
setLastAccessedTime
in interfaceSession
- Parameters:
instant
- The instant that represents the last accessed time- Returns:
- The session
-
getMaxInactiveInterval
Description copied from interface:Session
Returns the maximum time interval as aDuration
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 thesetMaxInactiveInterval
method.- Specified by:
getMaxInactiveInterval
in interfaceSession
- Returns:
- A duration specifying the time should session should remain open between client requests
- See Also:
-
isNew
public boolean isNew() -
isModified
public boolean isModified()- Specified by:
isModified
in interfaceSession
- Returns:
- Has the session been modified
-
getCreationTime
Description copied from interface:Session
Returns the time when this session was created.- Specified by:
getCreationTime
in interfaceSession
- Returns:
- An
Instant
instance
-
put
public io.micronaut.core.convert.value.MutableConvertibleValues<Object> put(CharSequence key, Object value) - Specified by:
put
in interfaceio.micronaut.core.convert.value.MutableConvertibleValues<Object>
-
remove
- Specified by:
remove
in interfaceio.micronaut.core.convert.value.MutableConvertibleValues<Object>
-
clear
- Specified by:
clear
in interfaceio.micronaut.core.convert.value.MutableConvertibleValues<Object>
-
names
- Specified by:
names
in interfaceio.micronaut.core.convert.value.ConvertibleValues<Object>
-
values
- Specified by:
values
in interfaceio.micronaut.core.convert.value.ConvertibleValues<Object>
-
get
public <T> Optional<T> get(CharSequence name, io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext) - Specified by:
get
in interfaceio.micronaut.core.value.ValueResolver<CharSequence>
-
setNew
public void setNew(boolean aNew) - Parameters:
aNew
- Set is new
-