Top Description Methods
org.apache.avalon.framework.component

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:

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.

Deprecated: Use org.apache.avalon.framework.service.ServiceManager instead.

Author
Avalon Development Team
Version
$Id: ComponentManager.java 506231 2007-02-12 02:36:54Z crossley $
See Also
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.component.ComponentSelector

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

True if the component exists, False if it does not.
hasComponent
(String
a string identifying the key to check.
key
)

Check to see if a Component exists for a key.

public Component

Returns:

the desired component
lookup
(String
The key name of the Component to retrieve.
key
)

Get the Component associated with the given key.

public void
release(Component
The Component we are releasing.
component
)

Return the Component when you are finished with it.

Method Detail

hasComponentback to summary
public boolean hasComponent(String key)

Check to see if a Component exists for a key.

Parameters
key:String

a string identifying the key to check.

Returns:boolean

True if the component exists, False if it does not.

lookupback to summary
public Component lookup(String key) throws ComponentException

Get the Component associated with the given key. For instance, If the ComponentManager had a LoggerComponent stored and referenced by key, I would use the following call:

try
{
    LoggerComponent log;
    myComponent = (LoggerComponent) m_manager.lookup(LoggerComponent.ROLE);
}
catch (...)
{
    ...
}
Parameters
key:String

The key name of the Component to retrieve.

Returns:Component

the desired component

Exceptions
ComponentException:
if an error occurs
releaseback to summary
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:Component

The Component we are releasing.