DSpace Service Manager

From Dryad wiki
Jump to: navigation, search

The DSpace Service Manager is an abstraction layer that can make development easier, but also obscures the flow of control.

When a class is needed to perform a particular service (e.g., writing content into a search index), it may be called from the ServiceManager. The call will look something like this:

 dspace.getServiceManager().getServiceByName(IndexingService.class.getName(),IndexingService.class);

The confusing thing is that the class mentioned here (IndexingService.class) is an interface, and there is no indication of which implementation of the interface is being used. This is useful because developers can swap the implementation class on the fly. But when debugging, it can be problematic because the code does not indicate which implementation will be used. Luckily, the number of implementing classes is usually low. It is easiest to ensure that all implementations have proper logging defined, so you can tell which class was being used for a given run of the code.

Candidate locations for finding the binding between an interface and its implementing class:

  • applicationContext.xml
  • within the implementing class?

For more information about the Service Manager, see the DSpace documentation on the Services Framework.