Package com.helger.scope
Class AbstractScope
- java.lang.Object
-
- com.helger.scope.AbstractScope
-
- 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 Summary
Fields Modifier and Type Field Description protected com.helger.commons.concurrent.SimpleReadWriteLockm_aRWLock
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractScope(String sScopeID)Ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.helger.commons.collection.attr.IAttributeContainerAny<String>attrs()voiddestroyScope()Destroys the scopes and all child scopes.booleanequals(Object o)StringgetID()Get the ID of this scope.inthashCode()booleanisDestroyed()booleanisInDestruction()booleanisInPreDestruction()booleanisValid()protected voidpostDestroy()Override this method to perform further actions AFTER the scope was destroyed.protected voidpreDestroy()Override this method to perform further actions BEFORE the scope is destroyed.voidrunAtomic(Consumer<? super IScope> aConsumer)Perform stuff as a single action.<T> TrunAtomic(Function<? super IScope,? extends T> aFunction)Perform stuff as a single action.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.scope.IScope
getAllScopeRenewalAwareAttributes, initScope
-
-
-
-
Method Detail
-
getID
@Nonnull @Nonempty public final String getID()
Description copied from interface:IScopeGet 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!
-
isValid
public final boolean isValid()
- Specified by:
isValidin interfaceIScope- Returns:
trueif this scope is neither in destruction nor destroyed.- See Also:
IScope.isInDestruction(),IScope.isDestroyed()
-
isInPreDestruction
public final boolean isInPreDestruction()
-
isInDestruction
public final boolean isInDestruction()
- Specified by:
isInDestructionin interfaceIScope- Returns:
trueif the scope is currently in the process of destruction.
-
isDestroyed
public final boolean isDestroyed()
- Specified by:
isDestroyedin interfaceIScope- Returns:
trueif 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:IScopeDestroys the scopes and all child scopes. This method is only automatically called, when a scope goes out of scope.- Specified by:
destroyScopein interfaceIScope
-
runAtomic
@Nullable public final <T> T runAtomic(@Nonnull Function<? super IScope,? extends T> aFunction)
Description copied from interface:IScopePerform stuff as a single action. All actions are executed in a write-lock!
-
runAtomic
public final void runAtomic(@Nonnull Consumer<? super IScope> aConsumer)
Description copied from interface:IScopePerform stuff as a single action. All actions are executed in a write-lock!
-
attrs
@Nonnull @ReturnsMutableObject public final com.helger.commons.collection.attr.IAttributeContainerAny<String> attrs()
-
-