Package com.helger.scope.mgr
Class ScopeSessionManager
- java.lang.Object
-
- com.helger.scope.singleton.AbstractSingleton
-
- com.helger.scope.singleton.AbstractGlobalSingleton
-
- com.helger.scope.mgr.ScopeSessionManager
-
- All Implemented Interfaces:
IScopeDestructionAware
@ThreadSafe @Singleton public class ScopeSessionManager extends AbstractGlobalSingleton
Internal manager class for session scopes.
This class is only non-final so that the WebScopeSessionManager can be used for web scopes!- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_DESTROY_ALL_SESSIONS_ON_SCOPE_ENDstatic booleanDEFAULT_END_ALL_SESSIONS_ON_SCOPE_END-
Fields inherited from class com.helger.scope.singleton.AbstractSingleton
m_aRWLock
-
-
Constructor Summary
Constructors Constructor Description ScopeSessionManager()Deprecated.Do not call explicitly
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsAnySession()voiddestroyAllSessions()Destroy all known session scopes.com.helger.commons.collection.impl.ICommonsList<ISessionScope>getAllSessionScopes()static ScopeSessionManagergetInstance()intgetSessionCount()ISessionScopegetSessionScopeOfID(String sScopeID)Get the session scope with the specified ID.booleanisDestroyAllSessionsOnScopeEnd()booleanisEndAllSessionsOnScopeEnd()protected voidonDestroy(IScope aScopeInDestruction)Called when this singleton is destroyed.voidonScopeBegin(ISessionScope aSessionScope)Register the passed session scope in the internal map, call the#initScope()method and finally invoke the SPIs for the new scope.voidonScopeEnd(ISessionScope aSessionScope)Close the passed session scope gracefully.com.helger.commons.state.EChangesetDestroyAllSessionsOnScopeEnd(boolean bDestroyAllSessionsOnScopeEnd)com.helger.commons.state.EChangesetEndAllSessionsOnScopeEnd(boolean bEndAllSessionsOnScopeEnd)-
Methods inherited from class com.helger.scope.singleton.AbstractGlobalSingleton
getAllGlobalSingletons, getGlobalSingleton, getGlobalSingletonIfInstantiated, isGlobalSingletonInstantiated
-
Methods inherited from class com.helger.scope.singleton.AbstractSingleton
getAllSingletons, getSingleton, getSingletonIfInstantiated, getSingletonScopeKey, isDestroyed, isInDestruction, isInInstantiation, isInPreDestruction, isInstantiated, isSingletonInstantiated, isUsableObject, onAfterInstantiation, onBeforeDestroy, onBeforeScopeDestruction, onScopeDestruction, readAbstractSingletonFields, setDestroyed, setInDestruction, setInInstantiation, setInPreDestruction, setInstantiated, toString, writeAbstractSingletonFields
-
-
-
-
Field Detail
-
DEFAULT_DESTROY_ALL_SESSIONS_ON_SCOPE_END
public static final boolean DEFAULT_DESTROY_ALL_SESSIONS_ON_SCOPE_END
- See Also:
- Constant Field Values
-
DEFAULT_END_ALL_SESSIONS_ON_SCOPE_END
public static final boolean DEFAULT_END_ALL_SESSIONS_ON_SCOPE_END
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ScopeSessionManager
@Deprecated @UsedViaReflection public ScopeSessionManager()
Deprecated.Do not call explicitlyInvoked internally.
-
-
Method Detail
-
getInstance
@Nonnull public static ScopeSessionManager getInstance()
-
getSessionScopeOfID
@Nullable public ISessionScope getSessionScopeOfID(@Nullable String sScopeID)
Get the session scope with the specified ID. If no such scope exists, no further actions are taken.- Parameters:
sScopeID- The ID to be resolved. May benull.- Returns:
nullif no such scope exists.
-
onScopeBegin
public void onScopeBegin(@Nonnull ISessionScope aSessionScope)
Register the passed session scope in the internal map, call the#initScope()method and finally invoke the SPIs for the new scope.- Parameters:
aSessionScope- The session scope that was just created. May not benull.
-
onScopeEnd
public void onScopeEnd(@Nonnull ISessionScope aSessionScope)
Close the passed session scope gracefully. Each managed scope is guaranteed to be destroyed only once. First the SPI manager is invoked, and afterwards the scope is destroyed.- Parameters:
aSessionScope- The session scope to be ended. May not benull.
-
containsAnySession
public boolean containsAnySession()
- Returns:
trueif at least one session is present,falseotherwise
-
getSessionCount
@Nonnegative public int getSessionCount()
- Returns:
- The number of managed session scopes. Always ≥ 0.
-
getAllSessionScopes
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<ISessionScope> getAllSessionScopes()
- Returns:
- A non-
null, mutable copy of all managed session scopes.
-
destroyAllSessions
public void destroyAllSessions()
Destroy all known session scopes. After this method it is ensured that the internal session map is empty.
-
isDestroyAllSessionsOnScopeEnd
public final boolean isDestroyAllSessionsOnScopeEnd()
-
setDestroyAllSessionsOnScopeEnd
@Nonnull public final com.helger.commons.state.EChange setDestroyAllSessionsOnScopeEnd(boolean bDestroyAllSessionsOnScopeEnd)
-
isEndAllSessionsOnScopeEnd
public final boolean isEndAllSessionsOnScopeEnd()
-
setEndAllSessionsOnScopeEnd
@Nonnull public final com.helger.commons.state.EChange setEndAllSessionsOnScopeEnd(boolean bEndAllSessionsOnScopeEnd)
-
onDestroy
protected void onDestroy(@Nonnull IScope aScopeInDestruction)
Description copied from class:AbstractSingletonCalled when this singleton is destroyed. Perform all cleanup in this method. This method is called when "inPreDestruction" isfalse, "inDestruction" istrueand "isDestroyed" isfalse.- Overrides:
onDestroyin classAbstractSingleton- Parameters:
aScopeInDestruction- The scope in destruction. Nevernull.
-
-