Class 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 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 explicitly
        Invoked internally.
    • Method Detail

      • 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 be null.
        Returns:
        null if 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 be null.
      • 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 be null.
      • containsAnySession

        public boolean containsAnySession()
        Returns:
        true if at least one session is present, false otherwise
      • 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: AbstractSingleton
        Called when this singleton is destroyed. Perform all cleanup in this method. This method is called when "inPreDestruction" is false , "inDestruction" is true and "isDestroyed" is false.
        Overrides:
        onDestroy in class AbstractSingleton
        Parameters:
        aScopeInDestruction - The scope in destruction. Never null.