Class DefaultServiceManager

  • All Implemented Interfaces:
    org.apache.avalon.framework.service.ServiceManager

    public class DefaultServiceManager
    extends java.lang.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 java.util.HashMap m_objects  
      private org.apache.avalon.framework.service.ServiceManager m_parent  
      private boolean m_readOnly  
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void checkWriteable()
      Checks if this ServiceManager is writeable.
      protected java.util.Map getObjectMap()
      Helper method for subclasses to retrieve object map.
      protected org.apache.avalon.framework.service.ServiceManager getParent()
      Helper method for subclasses to retrieve parent.
      boolean hasService​(java.lang.String key)
      Check to see if a Object exists for a key.
      java.lang.Object lookup​(java.lang.String key)
      Retrieve Object by key from ServiceManager.
      void makeReadOnly()
      Makes this ServiceManager read-only.
      void put​(java.lang.String key, java.lang.Object object)
      Place Object into ServiceManager.
      void release​(java.lang.Object object)
      Release the Object.
      java.lang.String toString()
      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 Detail

      • m_objects

        private final java.util.HashMap m_objects
      • m_parent

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

        private boolean m_readOnly
    • Constructor Detail

      • 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 Detail

      • lookup

        public java.lang.Object lookup​(java.lang.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​(java.lang.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​(java.lang.String key,
                        java.lang.Object object)
        Place Object into ServiceManager.
        Parameters:
        key - the object's key
        object - an Object value
      • toString

        public java.lang.String toString()
        Build a human readable representation of this ServiceManager.
        Overrides:
        toString in class java.lang.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 java.util.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 java.lang.IllegalStateException
        Checks if this ServiceManager is writeable.
        Throws:
        java.lang.IllegalStateException - if this ServiceManager is read-only
      • release

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