@ThreadSafe public final class ScopeManager extends Object
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_CREATE_SCOPE |
static String |
SCOPE_ATTRIBUTE_PREFIX_INTERNAL
The prefix to be used for attribute names in any scope to indicate system
internal attributes
|
| Modifier and Type | Method and Description |
|---|---|
static void |
destroySessionScope(ISessionScope aSessionScope)
Manually destroy the passed session scope.
|
static IGlobalScope |
getGlobalScope() |
static IGlobalScope |
getGlobalScopeOrNull() |
static IRequestScope |
getRequestScope() |
static IRequestScope |
getRequestScopeOrNull() |
static ISessionScope |
getSessionScope()
Get the current session scope, based on the current request scope.
|
static ISessionScope |
getSessionScope(boolean bCreateIfNotExisting)
Get the current session scope, based on the current request scope.
|
static ISessionScope |
getSessionScope(boolean bCreateIfNotExisting,
Function<? super String,? extends ISessionScope> aFactory) |
static void |
internalClearRequestScope()
Internal method to clear request scope thread local.
|
static void |
internalSetAndInitRequestScope(IRequestScope aRequestScope)
This method is only to be called by this class and the web scope manager!
|
static boolean |
isGlobalScopePresent() |
static boolean |
isInternalAttribute(String sAttributeName)
Check if the passed attribute name is an internal attribute.
|
static boolean |
isRequestScopePresent() |
static IGlobalScope |
onGlobalBegin(String sScopeID)
This method is used to set the initial global scope.
|
static <T extends IGlobalScope> |
onGlobalBegin(String sScopeID,
Function<? super String,T> aFactory) |
static void |
onGlobalEnd()
To be called when the singleton global context is to be destroyed.
|
static IRequestScope |
onRequestBegin(String sScopeID,
String sSessionID) |
static <T extends IRequestScope> |
onRequestBegin(String sScopeID,
String sSessionID,
BiFunction<? super String,? super String,T> aFactory) |
static void |
onRequestEnd()
To be called after a request finished.
|
static void |
setGlobalScope(IGlobalScope aGlobalScope)
This method is only to be called by this class and the web scope manager!
|
public static final String SCOPE_ATTRIBUTE_PREFIX_INTERNAL
public static final boolean DEFAULT_CREATE_SCOPE
public static void setGlobalScope(@Nonnull IGlobalScope aGlobalScope)
aGlobalScope - The scope to be set. May not be null.@Nonnull public static IGlobalScope onGlobalBegin(@Nonnull @Nonempty String sScopeID)
sScopeID - The scope ID to usenull.@Nonnull public static <T extends IGlobalScope> T onGlobalBegin(@Nonnull @Nonempty String sScopeID, @Nonnull Function<? super String,T> aFactory)
@Nullable public static IGlobalScope getGlobalScopeOrNull()
public static boolean isGlobalScopePresent()
@Nonnull public static IGlobalScope getGlobalScope()
public static void onGlobalEnd()
@Nonnull public static ISessionScope getSessionScope()
null.IllegalStateException - If no request scope is present or if the underlying request scope
does not have a session ID.@Nullable public static ISessionScope getSessionScope(boolean bCreateIfNotExisting)
bCreateIfNotExisting - true to create a new scope, if none is present yet,
false to return null if either no request
scope or no session scope is present.null if bCreateIfNotExisting is false and
either no request scope or no session scope is present, the
ISessionScope otherwise.IllegalStateException - if bCreateIfNotExisting is true but no request scope
is present. This exception is also thrown if the underlying request
scope does not have a session ID.@Nullable public static ISessionScope getSessionScope(boolean bCreateIfNotExisting, @Nonnull Function<? super String,? extends ISessionScope> aFactory)
public static void destroySessionScope(@Nonnull ISessionScope aSessionScope)
aSessionScope - The session scope to be destroyed. May not be null.public static void internalSetAndInitRequestScope(@Nonnull IRequestScope aRequestScope)
aRequestScope - The request scope to use. May not be null.@Nonnull public static IRequestScope onRequestBegin(@Nonnull @Nonempty String sScopeID, @Nonnull @Nonempty String sSessionID)
@Nonnull public static <T extends IRequestScope> T onRequestBegin(@Nonnull @Nonempty String sScopeID, @Nonnull @Nonempty String sSessionID, @Nonnull BiFunction<? super String,? super String,T> aFactory)
@Nullable public static IRequestScope getRequestScopeOrNull()
null if no request scope
is present.public static boolean isRequestScopePresent()
true if a request scope is present, false
otherwise@Nonnull public static IRequestScope getRequestScope()
null.IllegalStateException - If no request scope is presentpublic static void internalClearRequestScope()
public static void onRequestEnd()
public static boolean isInternalAttribute(@Nullable String sAttributeName)
sAttributeName - The name of the attribute to check. May be null.true if the passed attribute name is not
null and starts with the
SCOPE_ATTRIBUTE_PREFIX_INTERNAL prefix.Copyright © 2016–2019 Philip Helger. All rights reserved.