@Immutable public final class WebScopeManager extends Object
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_SESSION_PASSIVATION_ALLOWED |
| Modifier and Type | Method and Description |
|---|---|
static IGlobalWebScope |
getGlobalScope() |
static IGlobalWebScope |
getGlobalScopeOrNull() |
static IRequestWebScope |
getRequestScope() |
static IRequestWebScope |
getRequestScopeOrNull() |
static ISessionWebScope |
getSessionScope()
Get or create a session scope based on the current request scope.
|
static ISessionWebScope |
getSessionScope(boolean bCreateIfNotExisting)
Get the session scope from the current request scope.
|
static ISessionWebScope |
internalGetOrCreateSessionScope(javax.servlet.http.HttpSession aHttpSession,
boolean bCreateIfNotExisting,
boolean bItsOkayToCreateANewScope)
Internal method which does the main logic for session web scope creation
|
static ISessionWebScope |
internalGetSessionScope(boolean bCreateIfNotExisting,
boolean bItsOkayToCreateANewSession)
Get the session scope from the current request scope.
|
static ISessionWebScope |
internalGetSessionScope(IRequestWebScope aRequestScope,
boolean bCreateIfNotExisting,
boolean bItsOkayToCreateANewSession)
Get the session scope of the provided request scope.
|
static boolean |
isGlobalScopePresent() |
static boolean |
isRequestScopePresent() |
static boolean |
isSessionPassivationAllowed() |
static IGlobalWebScope |
onGlobalBegin(javax.servlet.ServletContext aServletContext)
To be called, when the global web scope is initialized.
|
static IGlobalWebScope |
onGlobalBegin(javax.servlet.ServletContext aServletContext,
Function<? super javax.servlet.ServletContext,? extends IGlobalWebScope> aFactory) |
static void |
onGlobalEnd()
To be called, when the global web scope is destroyed.
|
static IRequestWebScope |
onRequestBegin(javax.servlet.http.HttpServletRequest aHttpRequest,
javax.servlet.http.HttpServletResponse aHttpResponse) |
static <T extends IRequestWebScope> |
onRequestBegin(javax.servlet.http.HttpServletRequest aHttpRequest,
javax.servlet.http.HttpServletResponse aHttpResponse,
BiFunction<? super javax.servlet.http.HttpServletRequest,? super javax.servlet.http.HttpServletResponse,T> aFactory) |
static void |
onRequestEnd() |
static ISessionWebScope |
onSessionBegin(javax.servlet.http.HttpSession aHttpSession)
To be called, when a session web scope is initialized.
|
static <T extends ISessionWebScope> |
onSessionBegin(javax.servlet.http.HttpSession aHttpSession,
Function<? super javax.servlet.http.HttpSession,T> aFactory) |
static void |
onSessionEnd(javax.servlet.http.HttpSession aHttpSession)
To be called, when a session web scope is destroyed.
|
static void |
setSessionPassivationAllowed(boolean bSessionPassivationAllowed)
Allow or disallow session passivation
|
public static final boolean DEFAULT_SESSION_PASSIVATION_ALLOWED
public static boolean isSessionPassivationAllowed()
true if session passivation is allowed. Default is
DEFAULT_SESSION_PASSIVATION_ALLOWEDpublic static void setSessionPassivationAllowed(boolean bSessionPassivationAllowed)
bSessionPassivationAllowed - true to enable session passivation, false
to disable it@Nonnull public static IGlobalWebScope onGlobalBegin(@Nonnull javax.servlet.ServletContext aServletContext)
ServletContextListener.contextInitialized(javax.servlet.ServletContextEvent)aServletContext - The source servlet context to be used to retrieve the scope ID. May
not be null@Nonnull public static IGlobalWebScope onGlobalBegin(@Nonnull javax.servlet.ServletContext aServletContext, @Nonnull Function<? super javax.servlet.ServletContext,? extends IGlobalWebScope> aFactory)
public static boolean isGlobalScopePresent()
true if a global scope is defined, false
if none is defined@Nullable public static IGlobalWebScope getGlobalScopeOrNull()
null if no global web scope
is present.@Nonnull public static IGlobalWebScope getGlobalScope()
null.IllegalStateException - If no global web scope object is presentpublic static void onGlobalEnd()
ServletContextListener.contextDestroyed(javax.servlet.ServletContextEvent)@Nonnull public static ISessionWebScope onSessionBegin(@Nonnull javax.servlet.http.HttpSession aHttpSession)
HttpSessionListener.sessionCreated(javax.servlet.http.HttpSessionEvent)aHttpSession - The source session to base the scope on. May not be
null@Nonnull public static <T extends ISessionWebScope> T onSessionBegin(@Nonnull javax.servlet.http.HttpSession aHttpSession, @Nonnull Function<? super javax.servlet.http.HttpSession,T> aFactory)
@Nullable @DevelopersNote(value="This is only for project-internal use!") public static ISessionWebScope internalGetOrCreateSessionScope(@Nonnull javax.servlet.http.HttpSession aHttpSession, boolean bCreateIfNotExisting, boolean bItsOkayToCreateANewScope)
aHttpSession - The underlying HTTP sessionbCreateIfNotExisting - if true if a new session web scope is created, if none
is presentbItsOkayToCreateANewScope - if true no warning is emitted, if a new session scope
must be created. This is e.g. used when renewing a session or when
activating a previously passivated session.null if no session scope is present, and
bCreateIfNotExisting is false@Nonnull public static ISessionWebScope getSessionScope()
getSessionScope(ScopeManager.DEFAULT_CREATE_SCOPE)null.@Nullable public static ISessionWebScope getSessionScope(boolean bCreateIfNotExisting)
bCreateIfNotExisting - if true a new session scope (and a new HTTP session if
required) is created if none is existing so far.null if no session scope is present, and none should
be created.@Nullable @DevelopersNote(value="This is only for project-internal use!") public static ISessionWebScope internalGetSessionScope(boolean bCreateIfNotExisting, boolean bItsOkayToCreateANewSession)
bCreateIfNotExisting - if true a new session scope (and a new HTTP session if
required) is created if none is existing so far.bItsOkayToCreateANewSession - if true no warning is emitted, if a new session scope
must be created. This is e.g. used when renewing a session.null if no session scope is present, and none should
be created.@Nullable @DevelopersNote(value="This is only for project-internal use!") public static ISessionWebScope internalGetSessionScope(@Nullable IRequestWebScope aRequestScope, boolean bCreateIfNotExisting, boolean bItsOkayToCreateANewSession)
aRequestScope - The request scope it is about. May be null.bCreateIfNotExisting - if true a new session scope (and a new HTTP session if
required) is created if none is existing so far.bItsOkayToCreateANewSession - if true no warning is emitted, if a new session scope
must be created. This is e.g. used when renewing a session.null if no session scope is present, and none should
be created.public static void onSessionEnd(@Nonnull javax.servlet.http.HttpSession aHttpSession)
HttpSessionListener.sessionDestroyed(javax.servlet.http.HttpSessionEvent)aHttpSession - The source session to destroy the matching scope. May not be
null@Nonnull public static IRequestWebScope onRequestBegin(@Nonnull javax.servlet.http.HttpServletRequest aHttpRequest, @Nonnull javax.servlet.http.HttpServletResponse aHttpResponse)
@Nonnull public static <T extends IRequestWebScope> T onRequestBegin(@Nonnull javax.servlet.http.HttpServletRequest aHttpRequest, @Nonnull javax.servlet.http.HttpServletResponse aHttpResponse, @Nonnull BiFunction<? super javax.servlet.http.HttpServletRequest,? super javax.servlet.http.HttpServletResponse,T> aFactory)
@Nullable public static IRequestWebScope getRequestScopeOrNull()
public static boolean isRequestScopePresent()
@Nonnull public static IRequestWebScope getRequestScope()
public static void onRequestEnd()
Copyright © 2014–2019 Philip Helger. All rights reserved.