Package org.int4.dirk.spi.scope
Class AbstractScopeResolver<S>
- java.lang.Object
-
- org.int4.dirk.spi.scope.AbstractScopeResolver<S>
-
- Type Parameters:
S- the type of the scope discriminator object
- All Implemented Interfaces:
ScopeResolver
- Direct Known Subclasses:
SingletonScopeResolver
public abstract class AbstractScopeResolver<S> extends java.lang.Object implements ScopeResolver
Abstract base implementation of aScopeResolverwhich manages a map of instances per scope.
-
-
Constructor Summary
Constructors Constructor Description AbstractScopeResolver()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voiddestroyScope(S scope)Destroys the given scope.CreationalContext<?>find(java.lang.Object key)Find an existingCreationalContextby key in the current active scope, or returnnullif no context was found in the given scope with the given key.protected abstract SgetCurrentScope()Returns the current scope, ornullif there is no current scope.booleanisActive()Returnstruewhen this scope is currently active, otherwisefalse.voidput(java.lang.Object key, CreationalContext<?> creationalContext)Adds aCreationalContextto this scope resolver under the given key.voidremove(java.lang.Object key)Removes the given key from this scope resolver.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.int4.dirk.spi.scope.ScopeResolver
getAnnotation
-
-
-
-
Method Detail
-
isActive
public final boolean isActive()
Description copied from interface:ScopeResolverReturnstruewhen this scope is currently active, otherwisefalse.- Specified by:
isActivein interfaceScopeResolver- Returns:
truewhen this scope is currently active, otherwisefalse
-
find
public final CreationalContext<?> find(java.lang.Object key)
Description copied from interface:ScopeResolverFind an existingCreationalContextby key in the current active scope, or returnnullif no context was found in the given scope with the given key.- Specified by:
findin interfaceScopeResolver- Parameters:
key- an object suitable as a key for use in a map, cannot benull- Returns:
- a
CreationalContextif found, otherwisenull
-
put
public final void put(java.lang.Object key, CreationalContext<?> creationalContext)Description copied from interface:ScopeResolverAdds aCreationalContextto this scope resolver under the given key.- Specified by:
putin interfaceScopeResolver- Parameters:
key- an object suitable as a key for use in a map, cannot benullcreationalContext- aCreationalContext, cannot benull
-
remove
public final void remove(java.lang.Object key)
Description copied from interface:ScopeResolverRemoves the given key from this scope resolver.- Specified by:
removein interfaceScopeResolver- Parameters:
key- an object suitable as a key for use in a map, cannot benull
-
getCurrentScope
protected abstract S getCurrentScope()
Returns the current scope, ornullif there is no current scope.- Returns:
- the current scope, or
nullif there is no current scope
-
destroyScope
protected final void destroyScope(S scope)
Destroys the given scope. Removes all references to instance from the given scope and releases their associatedCreationalContexts. Does nothing if the scope does not exist.- Parameters:
scope- a scope, cannot benull
-
-