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>>

public class InMemorySession extends Object implements Session
A Session that is help in-memory.
Since:
1.0
Author:
Graeme Rocher
  • Field Details

    • attributeMap

      protected final Map<CharSequence,Object> attributeMap
    • attributes

      protected final io.micronaut.core.convert.value.MutableConvertibleValues<Object> attributes
    • lastAccessTime

      protected Instant lastAccessTime
  • Constructor Details

    • InMemorySession

      protected InMemorySession(String id, Duration maxInactiveInterval)
      Constructor.
      Parameters:
      id - The session id
      maxInactiveInterval - The max inactive interval
    • InMemorySession

      protected InMemorySession(String id, Instant creationTime, Duration maxInactiveInterval)
      Constructor.
      Parameters:
      id - The session id
      creationTime - The creation time
      maxInactiveInterval - The max inactive interval
  • Method Details

    • getId

      @NonNull public @NonNull String getId()
      Description copied from interface: Session
      A unique identifier for the session.
      Specified by:
      getId in interface Session
      Returns:
      The id of the session
    • getLastAccessedTime

      @NonNull public @NonNull Instant getLastAccessedTime()
      Description copied from interface: Session
      Returns the last time the client sent a request associated with this session as an Instant.

      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 interface Session
      Returns:
      An Instant representing the time the session was last accessed
    • setMaxInactiveInterval

      public Session setMaxInactiveInterval(Duration duration)
      Description copied from interface: Session
      Specifies the duration between client requests before session should be invalidated.
      Specified by:
      setMaxInactiveInterval in interface Session
      Parameters:
      duration - A duration specifying the max inactive interval
      Returns:
      The session
    • setLastAccessedTime

      public Session setLastAccessedTime(Instant instant)
      Description copied from interface: Session
      Sets the last accessed time on the session.
      Specified by:
      setLastAccessedTime in interface Session
      Parameters:
      instant - The instant that represents the last accessed time
      Returns:
      The session
    • getMaxInactiveInterval

      public Duration getMaxInactiveInterval()
      Description copied from interface: Session
      Returns the maximum time interval as a 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.
      Specified by:
      getMaxInactiveInterval in interface Session
      Returns:
      A duration specifying the time should session should remain open between client requests
      See Also:
    • isNew

      public boolean isNew()
      Specified by:
      isNew in interface Session
      Returns:
      Is the session a newly created and unsaved session
    • isModified

      public boolean isModified()
      Specified by:
      isModified in interface Session
      Returns:
      Has the session been modified
    • getCreationTime

      @NonNull public @NonNull Instant getCreationTime()
      Description copied from interface: Session
      Returns the time when this session was created.
      Specified by:
      getCreationTime in interface Session
      Returns:
      An Instant instance
    • put

      public io.micronaut.core.convert.value.MutableConvertibleValues<Object> put(CharSequence key, Object value)
      Specified by:
      put in interface io.micronaut.core.convert.value.MutableConvertibleValues<Object>
    • remove

      public io.micronaut.core.convert.value.MutableConvertibleValues<Object> remove(CharSequence key)
      Specified by:
      remove in interface io.micronaut.core.convert.value.MutableConvertibleValues<Object>
    • clear

      public io.micronaut.core.convert.value.MutableConvertibleValues<Object> clear()
      Specified by:
      clear in interface io.micronaut.core.convert.value.MutableConvertibleValues<Object>
    • names

      public Set<String> names()
      Specified by:
      names in interface io.micronaut.core.convert.value.ConvertibleValues<Object>
    • values

      public Collection<Object> values()
      Specified by:
      values in interface io.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 interface io.micronaut.core.value.ValueResolver<CharSequence>
    • setNew

      public void setNew(boolean aNew)
      Parameters:
      aNew - Set is new