Interface ServiceManager
-
public interface ServiceManagerAServiceManagerselectsObjects based on a role. The contract is that all theObjects implement the differing roles and there is oneObjectper role. If you need to select on of manyObjects that implement the same role, then you need to use aServiceSelector. 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:- InputAdapter and OutputAdapter
- Store and Spool
ServiceManagerdoes not specify the methodology of getting theObject, merely the interface used to get it. Therefore theServiceManagercan be implemented with a factory pattern, an object pool, or a simple Hashtable.- Version:
- $Id: ServiceManager.java 30977 2004-07-30 03:57:54 -0500 (Fri, 30 Jul 2004) niclas $
- Author:
- Avalon Development Team
- See Also:
Serviceable,ServiceSelector
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanhasService(java.lang.String key)Check to see if aObjectexists for a key.java.lang.Objectlookup(java.lang.String key)Get theObjectassociated with the given key.voidrelease(java.lang.Object object)Return theObjectwhen you are finished with it.
-
-
-
Method Detail
-
lookup
java.lang.Object lookup(java.lang.String key) throws ServiceExceptionGet theObjectassociated with the given key. For instance, If theServiceManagerhad aLoggerComponentstored and referenced by key, the following could be used:try { LoggerComponent log; myComponent = (LoggerComponent) manager.lookup( LoggerComponent.ROLE ); } catch (...) { ... }- Parameters:
key- The lookup key of theObjectto retrieve.- Returns:
- an
Objectvalue - Throws:
ServiceException- if an error occurs
-
hasService
boolean hasService(java.lang.String key)
Check to see if aObjectexists for a key.- Parameters:
key- a string identifying the key to check.- Returns:
- True if the object exists, False if it does not.
-
release
void release(java.lang.Object object)
Return theObjectwhen you are finished with it. This allows theServiceManagerto handle the End-Of-Life Lifecycle events associated with theObject. 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- TheObjectwe are releasing, may also be anullreference
-
-