org.apache.avalon.framework.service
Interface ServiceManager
- All Known Implementing Classes:
- DefaultServiceManager
- public interface ServiceManager
A ServiceManager
selects Object
s based on a
role. The contract is that all the Object
s implement the
differing roles and there is one Object
per role. If you
need to select on of many Object
s that implement the same
role, then you need to use a ServiceSelector
. Roles are
usually the full interface name.
A role is better understood by the analogy of a play. There are many
different roles in a script. Any actor or actress can play any given part
and you get the same results (phrases said, movements made, etc.). The exact
nuances of the performance is different.
Below is a list of things that might be considered the different roles:
- InputAdaptor and OutputAdaptor
- Store and Spool
The ServiceManager
does not specify the methodology of
getting the Object
, merely the interface used to get it.
Therefore the ServiceManager
can be implemented with a
factory pattern, an object pool, or a simple Hashtable.
- Version:
- 1.0
- Author:
- Federico Barbieri, Stefano Mazzocchi, Pierpaolo Fumagalli, Berin Loritsch, Stephen McConnell
- See Also:
Serviceable
,
ServiceSelector
Method Summary |
boolean |
hasService(java.lang.String role)
Check to see if a Object exists for a role. |
java.lang.Object |
lookup(java.lang.String role)
Get the Object associated with the given role. |
void |
release(java.lang.Object object)
Return the Object when you are finished with it. |
lookup
public java.lang.Object lookup(java.lang.String role)
throws ServiceException
- Get the
Object
associated with the given role. For
instance, If the ServiceManager
had a
LoggerComponent
stored and referenced by role, I would use
the following call:
try
{
MyComponent log;
myComponent = (MyComponent) manager.lookup(MyComponent.ROLE);
}
catch (...)
{
...
}
- Parameters:
role
- The role name of the Object
to retrieve.- Returns:
- an
Object
value - Throws:
ServiceException
- if an error occurs
hasService
public boolean hasService(java.lang.String role)
- Check to see if a
Object
exists for a role.
- Parameters:
role
- a string identifying the role to check.- Returns:
- True if the object exists, False if it does not.
release
public void release(java.lang.Object object)
- Return the
Object
when you are finished with it. This
allows the ServiceManager
to handle the End-Of-Life Lifecycle
events associated with the Object
. Please note, that no
Exception should be thrown at this point. This is to allow easy use of the
ServiceManager system without having to trap Exceptions on a release.
- Parameters:
object
- The Object
we are releasing.
Copyright © 2001 Apache Jakarta Project. All Rights Reserved.