org.apache.avalon.framework.service

Class DefaultServiceManager

public class DefaultServiceManager extends Object implements ServiceManager

This class is a static implementation of a ServiceManager. Allow ineritance and extension so you can generate a tree of ServiceManager each defining Object scope.

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

Author: Avalon Development Team

Field Summary
HashMapm_objects
ServiceManagerm_parent
booleanm_readOnly
Constructor Summary
DefaultServiceManager()
Construct ServiceManager with no parent.
DefaultServiceManager(ServiceManager parent)
Construct ServiceManager with specified parent.
Method Summary
protected voidcheckWriteable()
Checks if this ServiceManager is writeable.
protected MapgetObjectMap()
Helper method for subclasses to retrieve object map.
protected ServiceManagergetParent()
Helper method for subclasses to retrieve parent.
booleanhasService(String key)
Check to see if a Object exists for a key.
Objectlookup(String key)
Retrieve Object by key from ServiceManager.
voidmakeReadOnly()
Makes this ServiceManager read-only.
voidput(String key, Object object)
Place Object into ServiceManager.
voidrelease(Object object)
Release the Object.
StringtoString()
Build a human readable representation of this ServiceManager.

Field Detail

m_objects

private final HashMap m_objects

m_parent

private final ServiceManager m_parent

m_readOnly

private boolean m_readOnly

Constructor Detail

DefaultServiceManager

public DefaultServiceManager()
Construct ServiceManager with no parent.

DefaultServiceManager

public DefaultServiceManager(ServiceManager parent)
Construct ServiceManager with specified parent.

Parameters: parent this ServiceManager's parent

Method Detail

checkWriteable

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

Throws: IllegalStateException if this ServiceManager is read-only

getObjectMap

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

Returns: the object map

getParent

protected final ServiceManager getParent()
Helper method for subclasses to retrieve parent.

Returns: the parent ServiceManager

hasService

public boolean hasService(String key)
Check to see if a Object exists for a key.

Parameters: key a string identifying the key to check.

Returns: True if the object exists, False if it does not.

lookup

public Object lookup(String key)
Retrieve Object by key from ServiceManager.

Parameters: key the key

Returns: the Object

Throws: ServiceException if an error occurs

makeReadOnly

public void makeReadOnly()
Makes this ServiceManager read-only.

put

public void put(String key, Object object)
Place Object into ServiceManager.

Parameters: key the object's key object an Object value

release

public void release(Object object)
Release the Object.

Parameters: object The Object to release.

toString

public String toString()
Build a human readable representation of this ServiceManager.

Returns: the description of this ServiceManager