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:
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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ThreadSafeComponentManager(boolean allowCircularDependencies) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComponent(String pluginName, String featureName, String role, Class<? extends T> component, Configuration configuration) Add a new component to the manager.voidcontextualize(Context context) Set up the Component Context.voiddispose()Properly dispose of the Child handlers.booleanhasComponent(T component) Tests for existence of a component.booleanTests for existence of a component for a given role.voidProperly initialize of the Child handlers.Return an instance of a component based on a Role.voidservice(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:
servicein interfaceServiceable
-
contextualize
Set up the Component Context.- Specified by:
contextualizein 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 theComponentto 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:
initializein interfaceInitializable- Throws:
Exception
-
dispose
Properly dispose of the Child handlers.- Specified by:
disposein 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.
-