org.apache.avalon.framework.component
Interface ComponentManager
- All Known Implementing Classes:
- DefaultComponentManager
- public interface ComponentManager
A ComponentManager selects Components based on a
role. The contract is that all the Components implement the
differing roles and there is one Component per role. If you
need to select on of many Components that implement the same
role, then you need to use a ComponentSelector. Roles are
usually the full interface name.
A role is better understood by the analogy of a play. There are many
different roles in a script. Any actor or actress can play any given part
and you get the same results (phrases said, movements made, etc.). The exact
nuances of the performance is different.
Below is a list of things that might be considered the different roles:
- InputAdaptor and OutputAdaptor
- Store and Spool
The ComponentManager does not specify the methodology of
getting the Component, merely the interface used to get it.
Therefore the ComponentManager can be implemented with a
factory pattern, an object pool, or a simple Hashtable.
- Author:
- Federico Barbieri, Stefano Mazzocchi, Pierpaolo Fumagalli, Berin Loritsch
- See Also:
Component,
Composable,
ComponentSelector
|
Method Summary |
boolean |
hasComponent(java.lang.String role)
Check to see if a Component exists for a role. |
Component |
lookup(java.lang.String role)
Get the Component associated with the given role. |
void |
release(Component component)
Return the Component when you are finished with it. |
lookup
public Component lookup(java.lang.String role)
throws ComponentException
- Get the
Component associated with the given role. For
instance, If the ComponentManager had a
LoggerComponent stored and referenced by role, I would use
the following call:
try
{
MyComponent log;
myComponent = (MyComponent) manager.lookup(MyComponent.ROLE);
}
catch (...)
{
...
}
- Parameters:
name - The role name of the Component to retrieve.- Throws:
ComponentException - if an error occurs
hasComponent
public boolean hasComponent(java.lang.String role)
- Check to see if a
Component exists for a role.
- Parameters:
role - a string identifying the role to check.- Returns:
- True if the component exists, False if it does not.
release
public void release(Component component)
- Return the
Component when you are finished with it. This
allows the ComponentManager to handle the End-Of-Life Lifecycle
events associated with the Component. Please note, that no Exceptions
should be thrown at this point. This is to allow easy use of the
ComponentManager system without having to trap Exceptions on a release.
- Parameters:
component - The Component we are releasing.
"Copyright © 2001 Apache Jakarta Project. All Rights Reserved."