org.apache.avalon.fortress.impl.lookup
Class FortressServiceSelector

java.lang.Object
  extended byorg.apache.avalon.fortress.impl.lookup.FortressServiceSelector
All Implemented Interfaces:
ServiceSelector

public class FortressServiceSelector
extends java.lang.Object
implements ServiceSelector

This is the Default ServiceSelector for the Container. It provides a very simple abstraction, and makes it easy for the Container to manage the references.

Version:
CVS $Revision: 1.19 $ $Date: 2004/03/13 17:57:59 $
Author:
Avalon Development Team

Constructor Summary
FortressServiceSelector(Container container, java.lang.String key)
          Creation of new service selector.
 
Method Summary
 java.lang.String getKey()
           
 boolean isSelectable(java.lang.Object hint)
          Check to see if a Object exists relative to the supplied policy.
 void release(java.lang.Object component)
          Return the Object when you are finished with it.
 java.lang.Object select(java.lang.Object hint)
          Select the Object associated with the given policy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FortressServiceSelector

public FortressServiceSelector(Container container,
                               java.lang.String key)
Creation of new service selector.

Parameters:
container - the impl
key - a key
Method Detail

select

public java.lang.Object select(java.lang.Object hint)
                        throws ServiceException
Description copied from interface: ServiceSelector
Select the Object associated with the given policy. For instance, If the 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 (...)
 {
     ...
 }
 

Specified by:
select in interface ServiceSelector
Parameters:
hint - A criteria against which a Object is selected.
Returns:
an Object value
Throws:
ServiceException - If the requested Object cannot be supplied

isSelectable

public boolean isSelectable(java.lang.Object hint)
Description copied from interface: ServiceSelector
Check to see if a Object exists relative to the supplied policy.

Specified by:
isSelectable in interface ServiceSelector
Parameters:
hint - a Object containing the selection criteria
Returns:
True if the component is available, False if it not.

release

public void release(java.lang.Object component)
Description copied from interface: ServiceSelector
Return the Object when you are finished with it. This allows the ServiceSelector to handle the End-Of-Life Lifecycle events associated with the 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.

Specified by:
release in interface ServiceSelector
Parameters:
component - The Object we are releasing, may also be a null reference

getKey

public java.lang.String getKey()


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.