public class ServiceLocator extends Object implements ServiceRegistry
| Modifier and Type | Class and Description |
|---|---|
static class |
ServiceLocator.ServiceFactory<T> |
| Constructor and Description |
|---|
ServiceLocator(ClassLoader classLoader) |
| Modifier and Type | Method and Description |
|---|---|
<T> ServiceLocator.ServiceFactory<T> |
findFactory(Class<T> serviceType)
Locates a factory for a given service.
|
<T> T |
get(Class<T> serviceType)
Locates the service of the given type.
|
<T> ServiceLocator.ServiceFactory<T> |
getFactory(Class<T> serviceType)
Locates a factory which can create services of the given type.
|
<T> T |
newInstance(Class<T> type)
Creates a new service instance of the given type.
|
public ServiceLocator(ClassLoader classLoader)
public <T> T get(Class<T> serviceType) throws UnknownServiceException
ServiceRegistryget in interface ServiceRegistryT - The service type.serviceType - The service type.UnknownServiceException - When there is no service of the given type available.public <T> ServiceLocator.ServiceFactory<T> getFactory(Class<T> serviceType) throws UnknownServiceException
ServiceRegistrygetFactory in interface ServiceRegistryT - The service type that the factory should create.serviceType - The service type that the factory should create.UnknownServiceException - When there is no factory available for services of the given type.public <T> ServiceLocator.ServiceFactory<T> findFactory(Class<T> serviceType)
public <T> T newInstance(Class<T> type) throws UnknownServiceException
ServiceRegistrynewInstance in interface ServiceRegistryT - The service type.type - The service typeUnknownServiceException - When there is no factory available for services of the given type.Copyright © 2013. All rights reserved