@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 IApplicationScope |
getApplicationScope()
Get or create the current application scope using the application ID
present in the request scope.
|
static IApplicationScope |
getApplicationScope(boolean bCreateIfNotExisting)
Get or create the current application scope using the application ID
present in the request scope.
|
static IApplicationScope |
getApplicationScope(String sApplicationID)
Get or create an application scope.
|
static IApplicationScope |
getApplicationScope(String sApplicationID,
boolean bCreateIfNotExisting)
Get or create an application scope.
|
static IGlobalScope |
getGlobalScope() |
static IGlobalScope |
getGlobalScopeOrNull() |
static String |
getRequestApplicationID()
Get the application ID associated to the current request scope
|
static String |
getRequestApplicationID(IRequestScope aRequestScope)
Get the application ID associated to the passed request scope
|
static IRequestScope |
getRequestScope() |
static IRequestScope |
getRequestScopeOrNull() |
static ISessionApplicationScope |
getSessionApplicationScope() |
static ISessionApplicationScope |
getSessionApplicationScope(boolean bCreateIfNotExisting) |
static ISessionApplicationScope |
getSessionApplicationScope(String sApplicationID) |
static ISessionApplicationScope |
getSessionApplicationScope(String sApplicationID,
boolean bCreateIfNotExisting) |
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 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 void |
onGlobalEnd()
To be called when the singleton global context is to be destroyed.
|
static IRequestScope |
onRequestBegin(String sApplicationID,
String sScopeID,
String sSessionID) |
static void |
onRequestEnd()
To be called after a request finished.
|
static void |
setAndInitRequestScope(String sApplicationID,
IRequestScope aRequestScope)
This method is only to be called by this class and the web scope manager!
|
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.@Nullable public static IGlobalScope getGlobalScopeOrNull()
public static boolean isGlobalScopePresent()
@Nonnull public static IGlobalScope getGlobalScope()
public static void onGlobalEnd()
@Nullable public static String getRequestApplicationID(@Nonnull IRequestScope aRequestScope)
aRequestScope - The request scope to use. May not be null.null if no application ID is present@Nonnull public static String getRequestApplicationID()
nullIllegalStateException - if no application ID is present@Nonnull public static IApplicationScope getApplicationScope()
null.@Nullable public static IApplicationScope getApplicationScope(boolean bCreateIfNotExisting)
bCreateIfNotExisting - if false an no application scope is present, none will
be creatednull if bCreateIfNotExisting is false and
no such scope is present@Nonnull public static IApplicationScope getApplicationScope(@Nonnull @Nonempty String sApplicationID)
sApplicationID - The ID of the application scope be retrieved or created. May neither
be null nor empty.null.@Nullable public static IApplicationScope getApplicationScope(@Nonnull @Nonempty String sApplicationID, boolean bCreateIfNotExisting)
sApplicationID - The ID of the application scope be retrieved or created. May neither
be null nor empty.bCreateIfNotExisting - if false an no application scope is present, none will
be creatednull if bCreateIfNotExisting is false and
no such scope is present@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.public static void destroySessionScope(@Nonnull ISessionScope aSessionScope)
aSessionScope - The session scope to be destroyed. May not be null.@Nonnull public static ISessionApplicationScope getSessionApplicationScope()
@Nullable public static ISessionApplicationScope getSessionApplicationScope(boolean bCreateIfNotExisting)
@Nonnull public static ISessionApplicationScope getSessionApplicationScope(@Nonnull @Nonempty String sApplicationID)
@Nullable public static ISessionApplicationScope getSessionApplicationScope(@Nonnull @Nonempty String sApplicationID, boolean bCreateIfNotExisting)
public static void setAndInitRequestScope(@Nonnull @Nonempty String sApplicationID, @Nonnull IRequestScope aRequestScope)
sApplicationID - The application ID to use. May neither be null nor
empty.aRequestScope - The request scope to use. May not be null.@Nonnull public static IRequestScope onRequestBegin(@Nonnull @Nonempty String sApplicationID, @Nonnull @Nonempty String sScopeID, @Nonnull @Nonempty String sSessionID)
@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 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 © 2014–2015 Philip Helger. All rights reserved.