public class DefaultServiceLocator extends Object implements ServiceLocator
Constructor and Description |
---|
DefaultServiceLocator()
Creates a new service locator that already knows about all service implementations included this library.
|
Modifier and Type | Method and Description |
---|---|
<T> DefaultServiceLocator |
addService(Class<T> type,
Class<? extends T> impl)
Adds the implementation class for a service.
|
<T> T |
getService(Class<T> type)
Gets an instance of the specified service.
|
<T> List<T> |
getServices(Class<T> type)
Gets all available instances of the specified service.
|
protected void |
serviceCreationFailed(Class<?> type,
Class<?> impl,
Throwable exception) |
<T> DefaultServiceLocator |
setService(Class<T> type,
Class<? extends T> impl)
Sets the implementation class for a service.
|
<T> DefaultServiceLocator |
setServices(Class<T> type,
T... services)
Sets the instances for a service.
|
public DefaultServiceLocator()
public <T> DefaultServiceLocator setService(Class<T> type, Class<? extends T> impl)
T
- The service type.type
- The interface describing the service, must not be null
.impl
- The implementation class of the service, must not be null
.null
.public <T> DefaultServiceLocator addService(Class<T> type, Class<? extends T> impl)
T
- The service type.type
- The interface describing the service, must not be null
.impl
- The implementation class of the service, must not be null
.null
.public <T> DefaultServiceLocator setServices(Class<T> type, T... services)
T
- The service type.type
- The interface describing the service, must not be null
.services
- The instances of the service, must not be null
.null
.public <T> T getService(Class<T> type)
ServiceLocator
getService
in interface ServiceLocator
T
- The service type.type
- The interface describing the service, must not be null
.null
if the service could not be located/initialized.public <T> List<T> getServices(Class<T> type)
ServiceLocator
getServices
in interface ServiceLocator
T
- The service type.type
- The interface describing the service, must not be null
.null
.Copyright © 2010-2012 Sonatype, Inc.. All Rights Reserved.