org.apache.avalon.framework.service
Class DefaultServiceManager

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

public class DefaultServiceManager
extends java.lang.Object
implements 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:
1.0
Author:
Federico Barbieri, Peter Donald, Stephen McConnell

Constructor Summary
DefaultServiceManager()
          Construct ServiceManager with no parent.
DefaultServiceManager(ServiceManager parent)
          Construct ServiceManager with specified parent.
 
Method Summary
protected  void checkWriteable()
          Checks if this ServiceManager is writeable.
protected  java.util.Map getObjectMap()
          Helper method for subclasses to retrieve object map.
protected  ServiceManager getParent()
          Helper method for subclasses to retrieve parent.
 boolean hasService(java.lang.String role)
          Check to see if a Object exists for a role.
 java.lang.Object lookup(java.lang.String role)
          Retrieve Object by role from ServiceManager.
 void makeReadOnly()
          Makes this ServiceManager read-only.
 void put(java.lang.String role, 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
 

Constructor Detail

DefaultServiceManager

public DefaultServiceManager()
Construct ServiceManager with no parent.


DefaultServiceManager

public DefaultServiceManager(ServiceManager parent)
Construct ServiceManager with specified parent.

Parameters:
parent - this ServiceManager's parent
Method Detail

lookup

public java.lang.Object lookup(java.lang.String role)
                        throws ServiceException
Retrieve Object by role from ServiceManager.

Specified by:
lookup in interface ServiceManager
Parameters:
role - the role
Returns:
the Object
Throws:
ServiceException - if an error occurs

hasService

public boolean hasService(java.lang.String role)
Check to see if a Object exists for a role.

Specified by:
hasService in interface ServiceManager
Parameters:
role - a string identifying the role to check.
Returns:
True if the object exists, False if it does not.

put

public void put(java.lang.String role,
                java.lang.Object object)
Place Object into ServiceManager.

Parameters:
role - the object's role
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 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 ServiceManager
Parameters:
object - The Object to release.


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.