org.apache.avalon.framework.service
Class DefaultServiceSelector

java.lang.Object
  extended byorg.apache.avalon.framework.service.DefaultServiceSelector
All Implemented Interfaces:
ServiceSelector

public class DefaultServiceSelector
extends java.lang.Object
implements ServiceSelector

This is the default implementation of the ServiceSelector

Version:
$Id: DefaultServiceSelector.java 30977 2004-07-30 08:57:54Z niclas $
Author:
Avalon Development Team

Constructor Summary
DefaultServiceSelector()
          Create a DefaultServiceSelector with a default empty role.
DefaultServiceSelector(java.lang.String role)
          Create a DefaultServiceSelector with a role for debug purposes.
 
Method Summary
protected  void checkWriteable()
          Checks if this service selector is writeable.
protected  java.util.Map getObjectMap()
          Helper method for subclasses to retrieve object map.
 boolean isSelectable(java.lang.Object hint)
          Returns whether a Object exists or not
 void makeReadOnly()
          Makes this service selector read-only.
 void put(java.lang.Object hint, java.lang.Object object)
          Populate the ServiceSelector.
 void release(java.lang.Object object)
          Release object.
 java.lang.Object select(java.lang.Object hint)
          Select the desired object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultServiceSelector

public DefaultServiceSelector()
Create a DefaultServiceSelector with a default empty role.


DefaultServiceSelector

public DefaultServiceSelector(java.lang.String role)
Create a DefaultServiceSelector with a role for debug purposes.

Parameters:
role - The role for this selector.
Throws:
java.lang.NullPointerException - if the role is null.
Method Detail

select

public java.lang.Object select(java.lang.Object hint)
                        throws ServiceException
Select the desired object.

Specified by:
select in interface ServiceSelector
Parameters:
hint - the hint to retrieve Object
Returns:
the Object
Throws:
ServiceException - if an error occurs

isSelectable

public boolean isSelectable(java.lang.Object hint)
Returns whether a Object exists or not

Specified by:
isSelectable in interface ServiceSelector
Parameters:
hint - the hint to retrieve Object
Returns:
true if the Object exists

release

public void release(java.lang.Object object)
Release object.

Specified by:
release in interface ServiceSelector
Parameters:
object - the Object to release

put

public void put(java.lang.Object hint,
                java.lang.Object object)
Populate the ServiceSelector.

Parameters:
hint - the hint to be used to retrieve the Object later
object - the Object to hold

getObjectMap

protected final java.util.Map getObjectMap()
Helper method for subclasses to retrieve object map.

Returns:
the object map

makeReadOnly

public void makeReadOnly()
Makes this service selector read-only.


checkWriteable

protected final void checkWriteable()
                             throws java.lang.IllegalStateException
Checks if this service selector is writeable.

Throws:
java.lang.IllegalStateException - if this service selector is read-only


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