Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

represents a "best practice" for new DSpace architecture and implementation of extensions to the DSpace application. DSpace Services are best described as a "Simple Registry" where plugins FIXME. The DS2 (DSpace 2.0) core services are the main services that make up a DS2 system. These includes services for things like user and permissions management and storage and caching. These services can be used by any developer writing DS2 plugins (e.g. statistics), providers (e.g. authentication), or user interfaces (e.g. JSPUI).

The Service Manager

...

Allows for non-specific access to the core services. No dependency on the underlying mechanism is exposed. Allows the developer to register and lookup references to desired Service Objects 

The Service Manager Interface is defined as follows:

Get Service By Type:

Allows developers to get the desired service singleton by the provided type. This should return all instantiated objects of the type specified (may not all be singletons). Accepts a type for the requested service (this will typically be the interface class but can be concrete as well) The return the list of service singletons OR empty list if none is found.

Code Block
public <T> List<T> getServicesByType(Class<T> type);

Get Service By Name:

Allows developers to get the desired service singleton by the provided name and type. 

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: getServiceByName(ApplicationContext.class.getName(), ApplicationContext.class);

Code Block
public <T> T getServiceByName(String name, Class<T> type);

Check If Service Exists
Code Block
public boolean isServiceExists(String name);

Get Service Names:

Get the names of all registered service singletons. By convention, the name typically matches the fully qualified class name.

Code Block
public List<String> getServicesNames();

Register Services

Allows adding singleton services and providers in at runtime or after the service manager has started up.  This is primarily useful for registering providers, filters, and plugins with the DSpace core. In all the DSpace Web and Commandline Applications, calls will register and unregister the Services in the ServiceManager during the application Lifecycle.

Code Block
public void registerService(String name, Object service);

Register a Singleton Service Classes

Allows adding singleton services and providers in at runtime or after the service manager has started up. This is the same as the above method, however,  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 ServiceManager.getServiceByName(String, Class)

Code Block
public <T> T registerServiceClass(String name, Class<T> type);

Unregister a Service

Allows a service to be unregistered (which will only work if nothing depends on it).

This is primarily used for providers, filters, plugins, etc. which were registered but are no longer available because the context they are running in is shutting down or restarting.

WARNING: This should not be used to attempt to unregister core services as that will fail.

...

Code Block
public void unregisterService(String name);

...

Push Configuration

Allows new configuration settings to be pushed into the core DSpace configuration. These will cause a settings refresh action to be called for all services which are listening and will cause any bean properties to be pushed into existing beans.

Code Block
public void pushConfig(Map<String, String> settings);

...

Core Services

Behind APIs

 can be reimplemented without affecting developers who are using the services. 

...