|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ServiceManager
Allows for non-specific access to the core services. No dependency on the underlying mechanism is exposed.
| Method Summary | ||
|---|---|---|
|
getServiceByName(String name,
Class<T> type)
Allows developers to get the desired service singleton by the provided name and type. |
|
|
getServicesByType(Class<T> type)
Allows developers to get the desired service singleton by the provided type. |
|
List<String> |
getServicesNames()
Get the names of all registered service singletons. |
|
boolean |
isServiceExists(String name)
Lookup to see if a service exists with the given name. |
|
void |
pushConfig(Map<String,String> settings)
Allows new configuration settings to be pushed into the core DSpace configuration. |
|
void |
registerService(String name,
Object service)
Allows adding singleton services and providers in at runtime or after the service manager has started up. |
|
|
registerServiceClass(String name,
Class<T> type)
Allows adding singleton services and providers in at runtime or after the service manager has started up. |
|
void |
unregisterService(String name)
Allows a service to be unregistered (which will only work if nothing depends on it). |
|
| Method Detail |
|---|
<T> List<T> getServicesByType(Class<T> type)
T - type - the type for the requested service (this will typically be the interface class but can be concrete as well)
<T> T getServiceByName(String name,
Class<T> type)
null for the name if it is not known, but it is
better to ensure it is set.
NOTE: This also allows special access to the underlying service manager objects. If using Spring this allows access to the underlying ApplicationContext object like so:
T - name - (optional) the unique name for this service.
If null then the bean will be returned if there is only one
service of this type.type - the type for the requested service (this will typically be the interface class but can be concrete as well)
boolean isServiceExists(String name)
name - the unique name for this service
List<String> getServicesNames()
void registerService(String name,
Object service)
NOTE: It is important that you also call
unregisterService(String) if you are shutting
down the context (webapp, etc.) that registered the service so
that the full lifecycle completes correctly.
NOTE: if using Guice it is possible to register a Guice Module as a service, which will not actually register it but will cause anything in the Module to have existing core services injected into it. You can use anything as the name in this case.
name - the name of the service (must be unique)service - the object to register as a singleton service
IllegalArgumentException - if the service cannot be registered
<T> T registerServiceClass(String name,
Class<T> type)
registerService(String, Object)
except that it allows the core service manager to startup your
service for you instead of you providing a service to the core.
In general, it is better if you use your own service manager
(like Spring or Guice) to manage your services and simply
inherit the core service beans from the DSpace core service
manager using the special capabilities of
getServiceByName(String, Class).
name - the name of the service (must be unique)type - the class type of the service (must be in the current classloader)
IllegalArgumentException - if the service cannot be registered because the name is taken or type is invalid or othergetServiceByName(String, Class)void unregisterService(String name)
name - the name of the service (must be unique)
IllegalArgumentException - if the bean cannot be unregisteredvoid pushConfig(Map<String,String> settings)
settings - a map of keys (names) and values
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||