Class Extender

java.lang.Object
org.alfresco.traitextender.Extender
Direct Known Subclasses:
ExtenderImpl

public abstract class Extender extends Object
Trait-extender central extension registry and life cycle handler.
Implementors must handle:
  1. ExtensionBundle life cycle operations that start and stop bundles of extension points implementations at runtime.
    See also: start(ExtensionBundle) , stop(ExtensionBundle) and stopAll() ).
  2. The management of the extension point factory registry. At runtime extension point factories can be registered or unregistered. The registered factories will later be used for creating extensions of extensible-traits (see {@link Extender#getExtension(Extensible, ExtensionPoint))}.
    See also:register(ExtensionPoint, ExtensionFactory) and unregister(ExtensionPoint)
  3. The creation of extension for a given extensible trait.
    See: getExtension(Extensible, ExtensionPoint)
Author:
Bogdan Horje
  • Constructor Details

    • Extender

      public Extender()
  • Method Details

    • getInstance

      public static Extender getInstance()
      Returns:
      singleton ExtenderImpl instance
    • start

      public abstract void start(ExtensionBundle bundle)
      Start life-cycle phase trigger method.
      Upon successful execution the bundle will have all its extension points registered using register(ExtensionPoint, ExtensionFactory) and ready to be.
      Parameters:
      bundle - to be started
    • stop

      public abstract void stop(ExtensionBundle bundle)
      Start life-cycle phase trigger method.
      Upon successful execution the bundle will have all its extension points unregistered using unregister(ExtensionPoint).
      Parameters:
      bundle - to be stopped
    • stopAll

      public abstract void stopAll()
      Stops all previously registered ExtensionBundles.
    • getExtension

      public abstract <E, M extends Trait> E getExtension(Extensible anExtensible, ExtensionPoint<E,M> point)
      Creates and returns a unique per ExtensibleTrait object or null if no extension-point factory is registered for the given ExtensionPoint.
      Given that Extensible.getTrait(Class) is used to obtain the ExtendedTrait that the returned extension is uniquely associated with, the uniqueness and garbage collection of the returned extension is dependent on how the given Extensible handles its ExtendedTraits.
      Parameters:
      anExtensible -
      point -
      Returns:
      a unique per ExtensibleTrait extension object or null if no extension-point factory is registered for the given ExtensionPoint
    • register

      public abstract void register(ExtensionPoint<?,?> point, ExtensionFactory<?> factory)
      Registers an extension-point to factory association to be used in extension creation. The presence of an association for a given extension point guarantees that, when requested, a unique extension object per ExtensibleTrait extension is returned by getExtension(Extensible, ExtensionPoint).
      Parameters:
      point - the extension point to be associated with the given extension factory during extension retrieval using getExtension(Extensible, ExtensionPoint)
      factory -
    • unregister

      public abstract void unregister(ExtensionPoint<?,?> point)
      Unregisters an extension-point to factory association of the given extension point. The absence of an association for a given extension point guarantees that, when requested, a null is returned by getExtension(Extensible, ExtensionPoint).
      Unregistering extension points does not force the garbage collection of the already created extensions.
      Parameters:
      point -