public class ServiceRegistry extends Object
At startup, the ServiceLoader is used to load all available ServiceProviders and register them to the default registry.
Constructor and Description |
---|
ServiceRegistry() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes all registered services using
Service.close() . |
Service |
findService(String name)
Returns the service given the name.
|
ServiceMethod |
findServiceMethod(String fullName)
Finds a service method using a lookup string of the format "service/method".
|
ServiceMethod |
findServiceMethod(String serviceName,
String methodName)
Finds the service method given by the name of the service and the method.
|
static ServiceRegistry |
getDefault()
Returns the default service registry.
|
Set<String> |
getRegisteredServiceNames()
Returns the names of all the registered services.
|
void |
registerService(Service service)
Registers a single service.
|
void |
registerServices(ServiceProvider serviceProvider)
Registers all the services from the given service provider.
|
public static ServiceRegistry getDefault()
public void registerService(Service service)
service
- a new service, can't be nullpublic void registerServices(ServiceProvider serviceProvider)
serviceProvider
- a service provider, can't be nullpublic Set<String> getRegisteredServiceNames()
public Service findService(String name)
name
- the name of the service to look uppublic ServiceMethod findServiceMethod(String serviceName, String methodName)
serviceName
- the name of the service to look upmethodName
- the name of the method to look uppublic ServiceMethod findServiceMethod(String fullName)
Currently, this method throws an exception if the service is not found. It is not clear whether returning null would be more appropriate in that case.
fullName
- the service and method name for the lookuppublic void close()
Service.close()
.Copyright © 2015. All rights reserved.