Class ThreadSafeComponentManager<T>
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.runtime.plugin.component.ThreadSafeComponentManager<T>
- Type Parameters:
T
- The type of handled extensions
- All Implemented Interfaces:
LogEnabled
,Disposable
,Initializable
,Contextualizable
,Serviceable
- Direct Known Subclasses:
ExtensionPointComponentManager
,PluginsComponentManager
public class ThreadSafeComponentManager<T>
extends AbstractLogEnabled
implements Contextualizable, Initializable, Disposable, Serviceable
Special ServiceManager able to handle extensions.
It does not actually implements the Avalon ServiceManager interface, to be able to use the Java 5 generic parameter.
This class is also intended to be used "locally" : its lookup(role) method does NOT propagate to the parent manager if the component does not exist.
To use the real ServiceManager, use the PluginsServiceManager subclass instead.
It handles the "PluginAware" interface, implemented by extensions.
It handles the following Avalon interfaces :
It does not actually implements the Avalon ServiceManager interface, to be able to use the Java 5 generic parameter.
This class is also intended to be used "locally" : its lookup(role) method does NOT propagate to the parent manager if the component does not exist.
To use the real ServiceManager, use the PluginsServiceManager subclass instead.
It handles the "PluginAware" interface, implemented by extensions.
It handles the following Avalon interfaces :
- LogEnabled
- Contextualizable
- Serviceable
- Configurable
- Parameterizable
- Initializable
- Startable
- Disposable
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefault constructor.ThreadSafeComponentManager
(boolean allowCircularDependencies) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addComponent
(String pluginName, String featureName, String role, Class<? extends T> component, Configuration configuration) Add a new component to the manager.void
contextualize
(Context context) Set up the Component Context.void
dispose()
Properly dispose of the Child handlers.boolean
hasComponent
(T component) Tests for existence of a component.boolean
Tests for existence of a component for a given role.void
Properly initialize of the Child handlers.Return an instance of a component based on a Role.void
service
(ServiceManager manager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
_manager
The Cocoon ServiceManager
-
-
Constructor Details
-
ThreadSafeComponentManager
public ThreadSafeComponentManager()Default constructor. Allow circular dependencies. -
ThreadSafeComponentManager
Constructor.- Parameters:
allowCircularDependencies
- if this manager should allow circular dependencies during initialization
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
-
contextualize
Set up the Component Context.- Specified by:
contextualize
in interfaceContextualizable
-
lookup
Return an instance of a component based on a Role. The Role is usually the Interface Fully Qualified Name(FQN).- Parameters:
role
- The key name of theComponent
to retrieve.- Returns:
- the desired component or null if no component exist for the given role
- Throws:
ComponentException
- if an error occurs
-
hasRole
Tests for existence of a component for a given role.- Parameters:
role
- a string identifying the key to check.- Returns:
- true if there is a component for the given role, false if not.
-
hasComponent
Tests for existence of a component.- Parameters:
component
- to component to check- Returns:
- true if the component exists, false if it does not.
-
initialize
Properly initialize of the Child handlers.- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
dispose
Properly dispose of the Child handlers.- Specified by:
dispose
in interfaceDisposable
-
addComponent
public void addComponent(String pluginName, String featureName, String role, Class<? extends T> component, Configuration configuration) Add a new component to the manager.- Parameters:
pluginName
- the plugin containing the componentfeatureName
- the feature containing the componentrole
- the role name for the new component.component
- the class of this component.configuration
- the configuration for this component.
-