Class DefaultServiceManager

java.lang.Object
org.apache.avalon.framework.service.DefaultServiceManager
All Implemented Interfaces:
org.apache.avalon.framework.service.ServiceManager

public class DefaultServiceManager extends Object implements org.apache.avalon.framework.service.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

    Fields
    Modifier and Type
    Field
    Description
    private final HashMap
     
    private final org.apache.avalon.framework.service.ServiceManager
     
    private boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct ServiceManager with no parent.
    DefaultServiceManager(org.apache.avalon.framework.service.ServiceManager parent)
    Construct ServiceManager with specified parent.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final void
    Checks if this ServiceManager is writeable.
    protected final Map
    Helper method for subclasses to retrieve object map.
    protected final org.apache.avalon.framework.service.ServiceManager
    Helper method for subclasses to retrieve parent.
    boolean
    Check to see if a Object exists for a key.
    Retrieve Object by key from ServiceManager.
    void
    Makes this ServiceManager read-only.
    void
    put(String key, Object object)
    Place Object into ServiceManager.
    void
    release(Object object)
    Release the Object.
    Build a human readable representation of this ServiceManager.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • m_objects

      private final HashMap m_objects
    • m_parent

      private final org.apache.avalon.framework.service.ServiceManager m_parent
    • m_readOnly

      private boolean m_readOnly
  • Constructor Details

    • DefaultServiceManager

      public DefaultServiceManager()
      Construct ServiceManager with no parent.
    • DefaultServiceManager

      public DefaultServiceManager(org.apache.avalon.framework.service.ServiceManager parent)
      Construct ServiceManager with specified parent.
      Parameters:
      parent - this ServiceManager's parent
  • Method Details

    • lookup

      public Object lookup(String key) throws org.apache.avalon.framework.service.ServiceException
      Retrieve Object by key from ServiceManager.
      Specified by:
      lookup in interface org.apache.avalon.framework.service.ServiceManager
      Parameters:
      key - the key
      Returns:
      the Object
      Throws:
      org.apache.avalon.framework.service.ServiceException - if an error occurs
    • hasService

      public boolean hasService(String key)
      Check to see if a Object exists for a key.
      Specified by:
      hasService in interface org.apache.avalon.framework.service.ServiceManager
      Parameters:
      key - a string identifying the key to check.
      Returns:
      True if the object exists, False if it does not.
    • put

      public void put(String key, Object object)
      Place Object into ServiceManager.
      Parameters:
      key - the object's key
      object - an Object value
    • toString

      public String toString()
      Build a human readable representation of this ServiceManager.
      Overrides:
      toString in class Object
      Returns:
      the description of this ServiceManager
    • getParent

      protected final org.apache.avalon.framework.service.ServiceManager getParent()
      Helper method for subclasses to retrieve parent.
      Returns:
      the parent ServiceManager
    • getObjectMap

      protected final Map getObjectMap()
      Helper method for subclasses to retrieve object map.
      Returns:
      the object map
    • makeReadOnly

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

      protected final void checkWriteable() throws IllegalStateException
      Checks if this ServiceManager is writeable.
      Throws:
      IllegalStateException - if this ServiceManager is read-only
    • release

      public void release(Object object)
      Release the Object.
      Specified by:
      release in interface org.apache.avalon.framework.service.ServiceManager
      Parameters:
      object - The Object to release.