Class MapBackedScopelet<M extends MapBackedScopelet<M>>

java.lang.Object
org.microbean.scopelet.Scopelet<M>
org.microbean.scopelet.MapBackedScopelet<M>
Type Parameters:
M - the MapBackedScopelet subclass extending this class
All Implemented Interfaces:
AutoCloseable, Constable, Aggregate, Factory<M>
Direct Known Subclasses:
SingletonScopelet

public abstract class MapBackedScopelet<M extends MapBackedScopelet<M>> extends Scopelet<M>
A thread-safe, partial Scopelet implementation backed by ConcurrentMap machinery.
Author:
Laird Nelson
See Also:
  • Constructor Details

  • Method Details

    • close

      public void close()
      Description copied from class: Scopelet
      Irrevocably closes this Scopelet, and, by doing so, notionally makes it irrevocably closed and inactive.

      Overrides of this method must call super.close() as part of their implementation or undefined behavior may result.

      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class Scopelet<M extends MapBackedScopelet<M>>
      See Also:
    • instance

      public <I> I instance(Object beanId, Factory<I> factory, Creation<I> creation)
      Description copied from class: Scopelet
      Checks to see if this Scopelet is active and then returns a pre-existing or created-on-demand contextual instance suitable for the combination of identifier, Factory and Creation, or null
      Specified by:
      instance in class Scopelet<M extends MapBackedScopelet<M>>
      Type Parameters:
      I - the type of contextual instance
      Parameters:
      beanId - an identifier that can identify a contextual instance; may be null
      factory - a Factory; may be null
      creation - a Creation, typically the one in effect that is causing this method to be invoked in the first place; may be null
      Returns:
      a contextual instance, possibly pre-existing, or possibly created just in time, or null
      See Also:
    • remove

      public boolean remove(Object id)
      Description copied from class: Scopelet
      Checks to see if this Scopelet is active and then removes any contextual instance stored under the supplied id, returning true if and only if removal actually took place.

      The default implementation of this method always returns false. Subclasses are encouraged to override it as appropriate.

      Overrides:
      remove in class Scopelet<M extends MapBackedScopelet<M>>
      Parameters:
      id - an identifier; may be null
      Returns:
      true if and only if removal actually occurred