org.apache.avalon.framework.component
Class DefaultComponentManager

java.lang.Object
  |
  +--org.apache.avalon.framework.component.DefaultComponentManager
All Implemented Interfaces:
ComponentManager

public class DefaultComponentManager
extends java.lang.Object
implements ComponentManager

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

Author:
Federico Barbieri, Peter Donald

Field Summary
protected  java.util.HashMap m_components
           
protected  ComponentManager m_parent
           
 
Constructor Summary
DefaultComponentManager()
           
DefaultComponentManager(ComponentManager parent)
           
 
Method Summary
 Component lookup(java.lang.String role)
          Get the Component associated with the given role.
 void put(java.lang.String name, Component component)
           
 void release(Component component)
          Return the Component when you are finished with it.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_components

protected final java.util.HashMap m_components

m_parent

protected final ComponentManager m_parent
Constructor Detail

DefaultComponentManager

public DefaultComponentManager()

DefaultComponentManager

public DefaultComponentManager(ComponentManager parent)
Method Detail

lookup

public Component lookup(java.lang.String role)
                 throws ComponentException
Description copied from interface: ComponentManager
Get the Component associated with the given role. For instance, If the ComponentManager had a LoggerComponent stored and referenced by role, I would use the following call:
 try {
     LoggerComponent log;
     log = (LoggerComponent) manager.lookup("org.apache.avalon.framework.blocks.Logger");
 } catch (...) {
     ...
 }
 
Specified by:
lookup in interface ComponentManager
Following copied from interface: org.apache.avalon.framework.component.ComponentManager
Parameters:
name - The role name of the Component to retrieve.
Throws:
ComponentNotFoundException - If the given role is not associated with a Component.
ComponentNotAccessibleException - If a Component instance cannot be created.

put

public void put(java.lang.String name,
                Component component)

release

public void release(Component component)
Description copied from interface: ComponentManager
Return the Component when you are finished with it. This allows the ComponentManager to handle the End-Of-Life Lifecycle events associated with the Component. Please note, that no Exceptions should be thrown at this point. This is to allow easy use of the ComponentManager system without having to trap Exceptions on a release.
Specified by:
release in interface ComponentManager
Following copied from interface: org.apache.avalon.framework.component.ComponentManager
Parameters:
component - The Component we are releasing.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.