Interface SessionContext<A,B extends Session<A>>

Type Parameters:
A - the session data type
B - the session type
All Superinterfaces:
ExchangeContext
All Known Subinterfaces:
BasicSessionContext<A>, BasicSessionContext.Intercepted<A>, BasicSessionSecurityContext<A,B,C,D>, BasicSessionSecurityContext.Intercepted<A,B,C,D>, JWTSessionContext<A,B>, JWTSessionContext.Intercepted<A,B>, JWTSessionSecurityContext<A,B,C,D>, JWTSessionSecurityContext.Intercepted<A,B,C,D>, SessionContext.Intercepted<A,B>

public interface SessionContext<A,B extends Session<A>> extends ExchangeContext

The general session context which exposes the session in the exchange context.

A session may or may not exist when a request is received, isSessionPresent() can be used to determine whether a session is present in the context, in any case getSession() returns either the existing session or creates a new one.

getSessionData() and getSessionData(Supplier) are shortcuts for accessing session data which can be created on the fly when missing using the provided supplier.

Since:
1.13
Author:
Jeremy Kuhn
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    An intercepted session context used by the session interceptor to populate the session context.
  • Method Summary

    Modifier and Type
    Method
    Description
    Resolves or creates the session.
    default Mono<A>
    Resolves the session data.
    default Mono<A>
    Resolves the session data or creates them using the specified supplier if none exist in the session.
    boolean
    Determines whether a session is present in the context.

    Methods inherited from interface io.inverno.mod.http.base.ExchangeContext

    init
  • Method Details

    • isSessionPresent

      boolean isSessionPresent()

      Determines whether a session is present in the context.

      Returns:
      true if a session is present, false otherwise
    • getSession

      Mono<B> getSession()

      Resolves or creates the session.

      Returns:
      a mono emitting the existing session if one has been resolved from the request or a mono emitting a new session
    • getSessionData

      default Mono<A> getSessionData()

      Resolves the session data.

      This is a shortcut for context.getSession().flatMap(Session::getData) and as a result a new session is created when if none is present

      Returns:
      a mono resolving session data or an empty mono if none exist in the session
    • getSessionData

      default Mono<A> getSessionData(Supplier<A> supplier)

      Resolves the session data or creates them using the specified supplier if none exist in the session.

      This is a shortcut for context.getSession().flatMap(session -> session.getData(supplier)) and as a result a new session is created when if none is present.

      Parameters:
      supplier - a session data supplier
      Returns:
      a mono resolving or creating session data