Interface IScope

  • All Superinterfaces:
    com.helger.commons.id.IHasID<String>
    All Known Subinterfaces:
    IGlobalScope, IRequestScope, ISessionScope
    All Known Implementing Classes:
    AbstractScope, GlobalScope, RequestScope, SessionScope

    public interface IScope
    extends com.helger.commons.id.IHasID<String>
    This interface is used for all the common stuff of a scope. The following types of scopes are present:
    • Global scope - once and only once
    • Application context - scope for an application (e.g. public and secure application in one web application)
    • Session scope - for each user created session
    • Session application context - scope for an application within a session
    • Request scope - for each user request
    IMPORTANT: implementations of IScope must be thread safe!
    Author:
    Philip Helger
    • Method Detail

      • initScope

        void initScope()
        Init the scope. In contrast to the constructor of a scope, this happens after the scope has been registered in the scope manager.
      • getID

        String getID()
        Get the ID of this scope. Each scope retrieves a unique ID within its type of scope (request, session, application). This method needs to be callable anytime and should not throw any exception!
        Specified by:
        getID in interface com.helger.commons.id.IHasID<String>
        Returns:
        the non-null ID of this context.
      • isInDestruction

        boolean isInDestruction()
        Returns:
        true if the scope is currently in the process of destruction.
      • isDestroyed

        boolean isDestroyed()
        Returns:
        true if the scope was already destroyed. This is especially important for long running scopes.
      • destroyScope

        void destroyScope()
        Destroys the scopes and all child scopes. This method is only automatically called, when a scope goes out of scope.
      • runAtomic

        void runAtomic​(@Nonnull
                       Consumer<? super IScope> aConsumer)
        Perform stuff as a single action. All actions are executed in a write-lock!
        Parameters:
        aConsumer - The consumer to be executed. May not be null. The parameter to the runnable is this scope.
      • runAtomic

        @Nullable
        <T> T runAtomic​(@Nonnull
                        Function<? super IScope,​? extends T> aFunction)
        Perform stuff as a single action. All actions are executed in a write-lock!
        Type Parameters:
        T - The return type of the callable
        Parameters:
        aFunction - The function to be executed. May not be null. The parameter to the callable is this scope.
        Returns:
        The result from the callable. May be null.
      • attrs

        @Nonnull
        @ReturnsMutableObject
        com.helger.commons.collection.attr.IAttributeContainerAny<String> attrs()
        Returns:
        The mutable scope attributes. Never null.
      • getAllScopeRenewalAwareAttributes

        @Nonnull
        @ReturnsMutableCopy
        default com.helger.commons.collection.impl.ICommonsMap<String,​IScopeRenewalAware> getAllScopeRenewalAwareAttributes()
        Returns:
        The non-null map with all contained attributes that implement the IScopeRenewalAware interface. May be empty.