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.ServiceManager
This class is a static implementation of aServiceManager
. Allow ineritance and extension so you can generate a tree ofServiceManager
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()
ConstructServiceManager
with no parent.DefaultServiceManager(org.apache.avalon.framework.service.ServiceManager parent)
ConstructServiceManager
with specified parent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkWriteable()
Checks if thisServiceManager
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 aObject
exists for a key.java.lang.Object
lookup(java.lang.String key)
RetrieveObject
by key fromServiceManager
.void
makeReadOnly()
Makes thisServiceManager
read-only.void
put(java.lang.String key, java.lang.Object object)
PlaceObject
intoServiceManager
.void
release(java.lang.Object object)
Release theObject
.java.lang.String
toString()
Build a human readable representation of thisServiceManager
.
-
-
-
Constructor Detail
-
DefaultServiceManager
public DefaultServiceManager()
ConstructServiceManager
with no parent.
-
DefaultServiceManager
public DefaultServiceManager(org.apache.avalon.framework.service.ServiceManager parent)
ConstructServiceManager
with 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.ServiceException
RetrieveObject
by key fromServiceManager
.- Specified by:
lookup
in 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 aObject
exists for a key.- Specified by:
hasService
in 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)
PlaceObject
intoServiceManager
.- Parameters:
key
- the object's keyobject
- anObject
value
-
toString
public java.lang.String toString()
Build a human readable representation of thisServiceManager
.- Overrides:
toString
in 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 thisServiceManager
read-only.
-
checkWriteable
protected final void checkWriteable() throws java.lang.IllegalStateException
Checks if thisServiceManager
is writeable.- Throws:
java.lang.IllegalStateException
- if thisServiceManager
is read-only
-
release
public void release(java.lang.Object object)
Release theObject
.- Specified by:
release
in interfaceorg.apache.avalon.framework.service.ServiceManager
- Parameters:
object
- TheObject
to release.
-
-