org.apache.avalon.framework.service

Class DefaultServiceSelector

public class DefaultServiceSelector extends Object implements ServiceSelector

This is the default implementation of the ServiceSelector

Version: $Id: DefaultServiceSelector.java 30977 2004-07-30 03:57:54 -0500 (Fri, 30 Jul 2004) niclas $

Author: Avalon Development Team

Field Summary
HashMapm_objects
booleanm_readOnly
Stringm_role
Constructor Summary
DefaultServiceSelector()
Create a DefaultServiceSelector with a default empty role.
DefaultServiceSelector(String role)
Create a DefaultServiceSelector with a role for debug purposes.
Method Summary
protected voidcheckWriteable()
Checks if this service selector is writeable.
protected MapgetObjectMap()
Helper method for subclasses to retrieve object map.
booleanisSelectable(Object hint)
Returns whether a Object exists or not
voidmakeReadOnly()
Makes this service selector read-only.
voidput(Object hint, Object object)
Populate the ServiceSelector.
voidrelease(Object object)
Release object.
Objectselect(Object hint)
Select the desired object.

Field Detail

m_objects

private final HashMap m_objects

m_readOnly

private boolean m_readOnly

m_role

private final String m_role

Constructor Detail

DefaultServiceSelector

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

DefaultServiceSelector

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

Parameters: role The role for this selector.

Throws: NullPointerException if the role is null.

Method Detail

checkWriteable

protected final void checkWriteable()
Checks if this service selector is writeable.

Throws: IllegalStateException if this service selector is read-only

getObjectMap

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

Returns: the object map

isSelectable

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

Parameters: hint the hint to retrieve Object

Returns: true if the Object exists

makeReadOnly

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

put

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

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

release

public void release(Object object)
Release object.

Parameters: object the Object to release

select

public Object select(Object hint)
Select the desired object.

Parameters: hint the hint to retrieve Object

Returns: the Object

Throws: ServiceException if an error occurs