Interface ComponentSelector
-
- All Superinterfaces:
Component
- All Known Implementing Classes:
DefaultComponentSelector
,WrapperComponentSelector
public interface ComponentSelector extends Component
AComponentSelector
selectsComponent
s based on a hint. The contract is that all theComponent
s 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:
- XMLInputAdapter and PropertyInputAdapter
- FileGenerator and SQLGenerator
The
ComponentSelector
does not specify the methodology of getting theComponent
, merely the interface used to get it. Therefore theComponentSelector
can be implemented with a factory pattern, an object pool, or a simple Hashtable.Deprecated: Use
ServiceSelector
instead.- Version:
- CVS $Revision: 1.19 $ $Date: 2003/02/11 15:58:38 $
- Author:
- Avalon Development Team
- See Also:
Component
,Composable
,ComponentManager
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
hasComponent(java.lang.Object hint)
Check to see if aComponent
exists for a hint.void
release(Component component)
Return theComponent
when you are finished with it.Component
select(java.lang.Object hint)
Select theComponent
associated with the given hint.
-
-
-
Method Detail
-
select
Component select(java.lang.Object hint) throws ComponentException
Select theComponent
associated with the given hint. For instance, If theComponentSelector
has aGenerator
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
- A hint to retrieve the correctComponent
.- Returns:
- the desired component
- Throws:
ComponentException
- If the given role is not associated with aComponent
, or aComponent
instance cannot be created.
-
hasComponent
boolean hasComponent(java.lang.Object hint)
Check to see if aComponent
exists for a hint.- Parameters:
hint
- a string identifying the role to check.- Returns:
- True if the component exists, False if it does not.
-
release
void release(Component component)
Return theComponent
when you are finished with it. This allows theComponentSelector
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
- The Component we are releasing.
-
-