Class AbstractScope

  • All Implemented Interfaces:
    com.helger.commons.id.IHasID<String>, IScope
    Direct Known Subclasses:
    GlobalScope, RequestScope, SessionScope

    @ThreadSafe
    public abstract class AbstractScope
    extends Object
    implements IScope
    Abstract scope implementation based on a Map containing the attribute values.
    Author:
    Philip Helger
    • Field Detail

      • m_aRWLock

        protected final com.helger.commons.concurrent.SimpleReadWriteLock m_aRWLock
    • Constructor Detail

      • AbstractScope

        protected AbstractScope​(@Nonnull @Nonempty
                                String sScopeID)
        Ctor.
        Parameters:
        sScopeID - The scope ID. May neither be null nor empty.
    • Method Detail

      • getID

        @Nonnull
        @Nonempty
        public final String getID()
        Description copied from interface: IScope
        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>
        Specified by:
        getID in interface IScope
        Returns:
        the non-null ID of this context.
      • isInPreDestruction

        public final boolean isInPreDestruction()
      • isInDestruction

        public final boolean isInDestruction()
        Specified by:
        isInDestruction in interface IScope
        Returns:
        true if the scope is currently in the process of destruction.
      • isDestroyed

        public final boolean isDestroyed()
        Specified by:
        isDestroyed in interface IScope
        Returns:
        true if the scope was already destroyed. This is especially important for long running scopes.
      • preDestroy

        @OverrideOnDemand
        protected void preDestroy()
        Override this method to perform further actions BEFORE the scope is destroyed. The state is "in pre destruction".
      • postDestroy

        @OverrideOnDemand
        protected void postDestroy()
        Override this method to perform further actions AFTER the scope was destroyed. The state is "destroyed".
      • destroyScope

        public final void destroyScope()
        Description copied from interface: IScope
        Destroys the scopes and all child scopes. This method is only automatically called, when a scope goes out of scope.
        Specified by:
        destroyScope in interface IScope
      • runAtomic

        @Nullable
        public final <T> T runAtomic​(@Nonnull
                                     Function<? super IScope,​? extends T> aFunction)
        Description copied from interface: IScope
        Perform stuff as a single action. All actions are executed in a write-lock!
        Specified by:
        runAtomic in interface IScope
        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.
      • runAtomic

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

        @Nonnull
        @ReturnsMutableObject
        public final com.helger.commons.collection.attr.IAttributeContainerAny<String> attrs()
        Specified by:
        attrs in interface IScope
        Returns:
        The mutable scope attributes. Never null.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object