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

public Interface ComponentSelector

extends Component

A ComponentSelector selects Components based on a hint. The contract is that all the Components implement the same role.

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 same role:

The ComponentSelector does not specify the methodology of getting the Component, merely the interface used to get it. Therefore the ComponentSelector can be implemented with a factory pattern, an object pool, or a simple Hashtable.

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

Author
Avalon Development Team
Version
$Id: ComponentSelector.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.ComponentManager

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

True if the component exists, False if it does not.
hasComponent
(Object
a string identifying the role to check.
hint
)

Check to see if a Component exists for a hint.

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

Return the Component when you are finished with it.

public Component

Returns:

the desired component
select
(Object
A hint to retrieve the correct Component.
hint
)

Select the Component associated with the given hint.

Method Detail

hasComponentback to summary
public boolean hasComponent(Object hint)

Check to see if a Component exists for a hint.

Parameters
hint:Object

a string identifying the role to check.

Returns:boolean

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

releaseback to summary
public void release(Component component)

Return the Component when you are finished with it. This allows the ComponentSelector 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 ComponentSelector system without having to trap Exceptions on a release.

Parameters
component:Component

The Component we are releasing.

selectback to summary
public Component select(Object hint) throws ComponentException

Select the Component associated with the given hint. For instance, If the ComponentSelector has a Generator stored and referenced by a URL, I would use the following call:

try
{
    Generator input;
    input = (Generator)selector.select( new URL("foo://demo/url") );
}
catch (...)
{
    ...
}
Parameters
hint:Object

A hint to retrieve the correct Component.

Returns:Component

the desired component

Exceptions
ComponentException:
If the given role is not associated with a Component, or a Component instance cannot be created.