org.apache.avalon.framework.service

Interface ServiceSelector

public interface ServiceSelector

A ServiceSelector selects {@link Object}s based on a supplied policy. The contract is that all the {@link Object}s implement the same role.

Version: CVS $Revision: 1.13 $ $Date: 2003/02/11 15:58:42 $

Author: Avalon Development Team

See Also: Serviceable ServiceSelector

Method Summary
booleanisSelectable(Object policy)
Check to see if a {@link Object} exists relative to the supplied policy.
voidrelease(Object object)
Return the {@link Object} when you are finished with it.
Objectselect(Object policy)
Select the {@link Object} associated with the given policy.

Method Detail

isSelectable

public boolean isSelectable(Object policy)
Check to see if a {@link Object} exists relative to the supplied policy.

Parameters: policy a {@link Object} containing the selection criteria

Returns: True if the component is available, False if it not.

release

public void release(Object object)
Return the {@link Object} when you are finished with it. This allows the {@link ServiceSelector} to handle the End-Of-Life Lifecycle events associated with the {@link Object}. Please note, that no Exception should be thrown at this point. This is to allow easy use of the ServiceSelector system without having to trap Exceptions on a release.

Parameters: object The {@link Object} we are releasing.

select

public Object select(Object policy)
Select the {@link Object} associated with the given policy. For instance, If the {@link ServiceSelector} has a Generator stored and referenced by a URL, the following call could be used:
 try
 {
     Generator input;
     input = (Generator)selector.select( new URL("foo://demo/url") );
 }
 catch (...)
 {
     ...
 }
 

Parameters: policy A criteria against which a {@link Object} is selected.

Returns: an {@link Object} value

Throws: ServiceException If the requested {@link Object} cannot be supplied