com.wutka.util
Class ServiceRegistry
java.lang.Object
|
+--com.wutka.util.ServiceRegistry
- public class ServiceRegistry
- extends java.lang.Object
Provides a central location for application-wide services to
be located by name. If a service is requested that hasn't been
registered, the service registry attempts to load the service
dynamically.
To dynamically load a service, the service registry looks for
a config item of the form xxxService where xxx is the name of
the service requested. It expects the config item to be a
fully-qualified class name (i.e. the package name is included)
and will attempt to create a new instance of the class.
|
Field Summary |
protected static java.util.Hashtable |
services
The table of registered services |
|
Method Summary |
static java.lang.Object |
locateService(java.lang.String serviceName)
Returns the registered service corresponding to serviceName. |
static java.lang.Object |
locateService(java.lang.String serviceName,
boolean waitForService)
Returns the registered service corresponding to serviceName. |
static void |
registerService(java.lang.String serviceName,
java.lang.Object service)
Registers a service |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
services
protected static java.util.Hashtable services
- The table of registered services
ServiceRegistry
public ServiceRegistry()
locateService
public static java.lang.Object locateService(java.lang.String serviceName)
- Returns the registered service corresponding to serviceName.
If the service has not been registered, locateService attempts
to dynamically load the service.
- Parameters:
serviceName - The name of the service to search for- Returns:
- The registered service, or null if none exists
locateService
public static java.lang.Object locateService(java.lang.String serviceName,
boolean waitForService)
- Returns the registered service corresponding to serviceName.
If the service has not been registered, locateService attempts
to dynamically load the service.
- Parameters:
serviceName - The name of the service to search forwaitForService - If true, don't return until the service has been
registered- Returns:
- The registered service, or null if none exists
registerService
public static void registerService(java.lang.String serviceName,
java.lang.Object service)
- Registers a service
- Parameters:
serviceName - The name of the service to registerservice - The service to register