Package org.alfresco.traitextender
Class Extender
java.lang.Object
org.alfresco.traitextender.Extender
- Direct Known Subclasses:
ExtenderImpl
Trait-extender central extension registry and life cycle handler.
Implementors must handle:
Implementors must handle:
ExtensionBundlelife cycle operations that start and stop bundles of extension points implementations at runtime.
See also:start(ExtensionBundle),stop(ExtensionBundle)andstopAll()).- 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)andunregister(ExtensionPoint) - The creation of extension for a given extensible trait.
See:getExtension(Extensible, ExtensionPoint)
- Author:
- Bogdan Horje
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract <E,M extends Trait>
EgetExtension(Extensible anExtensible, ExtensionPoint<E, M> point) Creates and returns a unique perExtensibleTraitobject ornullif no extension-point factory is registered for the givenExtensionPoint.
Given thatExtensible.getTrait(Class)is used to obtain theExtendedTraitthat the returned extension is uniquely associated with, the uniqueness and garbage collection of the returned extension is dependent on how the givenExtensiblehandles itsExtendedTraits.static Extenderabstract voidregister(ExtensionPoint<?, ?> point, ExtensionFactory<?> factory) Registers an extension-point to factory association to be used in extension creation.abstract voidstart(ExtensionBundle bundle) Start life-cycle phase trigger method.
Upon successful execution the bundle will have all its extension points registered usingregister(ExtensionPoint, ExtensionFactory)and ready to be.abstract voidstop(ExtensionBundle bundle) Start life-cycle phase trigger method.
Upon successful execution the bundle will have all its extension points unregistered usingunregister(ExtensionPoint).abstract voidstopAll()Stops all previously registeredExtensionBundles.abstract voidunregister(ExtensionPoint<?, ?> point) Unregisters an extension-point to factory association of the given extension point.
-
Constructor Details
-
Extender
public Extender()
-
-
Method Details
-
getInstance
- Returns:
- singleton
ExtenderImplinstance
-
start
Start life-cycle phase trigger method.
Upon successful execution the bundle will have all its extension points registered usingregister(ExtensionPoint, ExtensionFactory)and ready to be.- Parameters:
bundle- to be started
-
stop
Start life-cycle phase trigger method.
Upon successful execution the bundle will have all its extension points unregistered usingunregister(ExtensionPoint).- Parameters:
bundle- to be stopped
-
stopAll
public abstract void stopAll()Stops all previously registeredExtensionBundles. -
getExtension
public abstract <E,M extends Trait> E getExtension(Extensible anExtensible, ExtensionPoint<E, M> point) Creates and returns a unique perExtensibleTraitobject ornullif no extension-point factory is registered for the givenExtensionPoint.
Given thatExtensible.getTrait(Class)is used to obtain theExtendedTraitthat the returned extension is uniquely associated with, the uniqueness and garbage collection of the returned extension is dependent on how the givenExtensiblehandles itsExtendedTraits.- Parameters:
anExtensible-point-- Returns:
- a unique per
ExtensibleTraitextension object ornullif no extension-point factory is registered for the givenExtensionPoint
-
register
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 perExtensibleTraitextension is returned bygetExtension(Extensible, ExtensionPoint).- Parameters:
point- the extension point to be associated with the given extension factory during extension retrieval usinggetExtension(Extensible, ExtensionPoint)factory-
-
unregister
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 bygetExtension(Extensible, ExtensionPoint).
Unregistering extension points does not force the garbage collection of the already created extensions.- Parameters:
point-
-