public class ServiceFactory extends Object
Modifier and Type | Field and Description |
---|---|
private static Map<Class<? extends Service>,Constructor<? extends Service>> |
constructorCache
Constructor cache.
|
private static String |
DEFAULT_PROPERTIES_FILE
Default service properties file.
|
private static ServiceFactory |
defaultFactory
Default service factory.
|
private static org.slf4j.Logger |
LOGGER
Logger for this class.
|
private Map<Class<? extends Service>,Class<? extends Service>> |
services
Set of available services.
|
Constructor and Description |
---|
ServiceFactory()
Constructor loading service configuration from the default location.
|
ServiceFactory(String path)
Constructor loading service configuration from a given location.
|
Modifier and Type | Method and Description |
---|---|
private <T extends Service> |
getConstructor(Class<T> klass)
Retrieves a constructor for a given class from the constructor cache if
possible.
|
<T extends Service> |
getInstance(Class<T> type)
Retrieves an instance of a given service.
|
private static final org.slf4j.Logger LOGGER
private static final String DEFAULT_PROPERTIES_FILE
private static Map<Class<? extends Service>,Constructor<? extends Service>> constructorCache
private Map<Class<? extends Service>,Class<? extends Service>> services
private static ServiceFactory defaultFactory
public ServiceFactory() throws DependencyException
DependencyException
- If there is an error locating or reading from
the default configuration location.public ServiceFactory(String path) throws DependencyException
path
- Location to load service configuration from.DependencyException
- If there is an error locating or reading from
path
.public <T extends Service> T getInstance(Class<T> type) throws DependencyException
type
- Interface type of the service.DependencyException
- If there is an error instantiating the
service instance requested.private <T extends Service> Constructor<T> getConstructor(Class<T> klass) throws DependencyException
klass
- Class to retrieve a constructor for.DependencyException
- If there is an error retrieving the
constructor.Copyright © 2016 Open Microscopy Environment