Class DefaultServiceManager
- java.lang.Object
-
- org.apache.avalon.framework.service.DefaultServiceManager
-
- All Implemented Interfaces:
org.apache.avalon.framework.service.ServiceManager
public class DefaultServiceManager extends java.lang.Object implements org.apache.avalon.framework.service.ServiceManagerThis class is a static implementation of aServiceManager. Allow ineritance and extension so you can generate a tree ofServiceManagereach 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.HashMapm_objectsprivate org.apache.avalon.framework.service.ServiceManagerm_parentprivate booleanm_readOnly
-
Constructor Summary
Constructors Constructor Description DefaultServiceManager()ConstructServiceManagerwith no parent.DefaultServiceManager(org.apache.avalon.framework.service.ServiceManager parent)ConstructServiceManagerwith specified parent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckWriteable()Checks if thisServiceManageris writeable.protected java.util.MapgetObjectMap()Helper method for subclasses to retrieve object map.protected org.apache.avalon.framework.service.ServiceManagergetParent()Helper method for subclasses to retrieve parent.booleanhasService(java.lang.String key)Check to see if aObjectexists for a key.java.lang.Objectlookup(java.lang.String key)RetrieveObjectby key fromServiceManager.voidmakeReadOnly()Makes thisServiceManagerread-only.voidput(java.lang.String key, java.lang.Object object)PlaceObjectintoServiceManager.voidrelease(java.lang.Object object)Release theObject.java.lang.StringtoString()Build a human readable representation of thisServiceManager.
-
-
-
Constructor Detail
-
DefaultServiceManager
public DefaultServiceManager()
ConstructServiceManagerwith no parent.
-
DefaultServiceManager
public DefaultServiceManager(org.apache.avalon.framework.service.ServiceManager parent)
ConstructServiceManagerwith specified parent.- Parameters:
parent- thisServiceManager's parent
-
-
Method Detail
-
lookup
public java.lang.Object lookup(java.lang.String key) throws org.apache.avalon.framework.service.ServiceExceptionRetrieveObjectby key fromServiceManager.- Specified by:
lookupin interfaceorg.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 aObjectexists for a key.- Specified by:
hasServicein interfaceorg.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)PlaceObjectintoServiceManager.- Parameters:
key- the object's keyobject- anObjectvalue
-
toString
public java.lang.String toString()
Build a human readable representation of thisServiceManager.- Overrides:
toStringin classjava.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 thisServiceManagerread-only.
-
checkWriteable
protected final void checkWriteable() throws java.lang.IllegalStateExceptionChecks if thisServiceManageris writeable.- Throws:
java.lang.IllegalStateException- if thisServiceManageris read-only
-
release
public void release(java.lang.Object object)
Release theObject.- Specified by:
releasein interfaceorg.apache.avalon.framework.service.ServiceManager- Parameters:
object- TheObjectto release.
-
-