Class 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 a ScopeResolver which manages a map of instances per scope.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void destroyScope​(S scope)
      Destroys the given scope.
      CreationalContext<?> find​(java.lang.Object key)
      Find an existing CreationalContext by key in the current active scope, or return null if no context was found in the given scope with the given key.
      protected abstract S getCurrentScope()
      Returns the current scope, or null if there is no current scope.
      boolean isActive()
      Returns true when this scope is currently active, otherwise false.
      void put​(java.lang.Object key, CreationalContext<?> creationalContext)
      Adds a CreationalContext to this scope resolver under the given key.
      void remove​(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
    • Constructor Detail

      • AbstractScopeResolver

        public AbstractScopeResolver()
    • Method Detail

      • isActive

        public final boolean isActive()
        Description copied from interface: ScopeResolver
        Returns true when this scope is currently active, otherwise false.
        Specified by:
        isActive in interface ScopeResolver
        Returns:
        true when this scope is currently active, otherwise false
      • find

        public final CreationalContext<?> find​(java.lang.Object key)
        Description copied from interface: ScopeResolver
        Find an existing CreationalContext by key in the current active scope, or return null if no context was found in the given scope with the given key.
        Specified by:
        find in interface ScopeResolver
        Parameters:
        key - an object suitable as a key for use in a map, cannot be null
        Returns:
        a CreationalContext if found, otherwise null
      • remove

        public final void remove​(java.lang.Object key)
        Description copied from interface: ScopeResolver
        Removes the given key from this scope resolver.
        Specified by:
        remove in interface ScopeResolver
        Parameters:
        key - an object suitable as a key for use in a map, cannot be null
      • getCurrentScope

        protected abstract S getCurrentScope()
        Returns the current scope, or null if there is no current scope.
        Returns:
        the current scope, or null if 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 associated CreationalContexts. Does nothing if the scope does not exist.
        Parameters:
        scope - a scope, cannot be null