org.apache.avalon.framework.component

Class DefaultComponentManager

public class DefaultComponentManager extends Object implements ComponentManager

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

Deprecated: Use DefaultServiceManager instead.

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

Author: Avalon Development Team

Field Summary
HashMapm_components
ComponentManagerm_parent
booleanm_readOnly
Constructor Summary
DefaultComponentManager()
Construct ComponentManager with no parent.
DefaultComponentManager(ComponentManager parent)
Construct ComponentManager with specified parent.
Method Summary
protected voidcheckWriteable()
Check if this component m_manager is writeable.
protected MapgetComponentMap()
Helper method for subclasses to retrieve component map.
protected ComponentManagergetParent()
Helper method for subclasses to retrieve parent.
booleanhasComponent(String key)
Returns true if the component m_manager is managing a component with the specified key, false otherwise.
Componentlookup(String key)
Retrieve Component by key from ComponentManager.
voidmakeReadOnly()
Make this component m_manager read only.
voidput(String key, Component component)
Place Component into ComponentManager.
voidrelease(Component component)
Release component.
StringtoString()
Build a human readable representation of ComponentManager.

Field Detail

m_components

private final HashMap m_components

m_parent

private final ComponentManager m_parent

m_readOnly

private boolean m_readOnly

Constructor Detail

DefaultComponentManager

public DefaultComponentManager()
Construct ComponentManager with no parent.

DefaultComponentManager

public DefaultComponentManager(ComponentManager parent)
Construct ComponentManager with specified parent.

Parameters: parent the ComponentManagers parent

Method Detail

checkWriteable

protected final void checkWriteable()
Check if this component m_manager is writeable.

Throws: IllegalStateException if this component m_manager is read-only

getComponentMap

protected final Map getComponentMap()
Helper method for subclasses to retrieve component map.

Returns: the component map

getParent

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

Returns: the parent ComponentManager

hasComponent

public boolean hasComponent(String key)
Returns true if the component m_manager is managing a component with the specified key, false otherwise.

Parameters: key key of the component you are lokking for

Returns: true if the component m_manager has a component with that key

lookup

public Component lookup(String key)
Retrieve Component by key from ComponentManager.

Parameters: key the key

Returns: the Component

Throws: ComponentException if an error occurs

makeReadOnly

public void makeReadOnly()
Make this component m_manager read only.

put

public void put(String key, Component component)
Place Component into ComponentManager.

Parameters: key the components key component the component

release

public void release(Component component)
Release component.

Parameters: component the component

toString

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

Returns: the description of ComponentManager