Package org.dspace.core.service
Interface PluginService
-
- All Known Implementing Classes:
LegacyPluginServiceImpl
public interface PluginServiceA service to manage "plugins". At this point, it's based off of the structure of the legacy PluginManager (5.x or below), until a better plugin definition is created.In DSpace, a "plugin" corresponds simply to a Java interface. Plugin implementations are simply classes which implement that interface (and often they are given unique names by which the plugin implementations are referenced/loaded).
- Author:
- Tim Donohue
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclearNamedPluginClasses()This method has been created to have a way of clearing the cache kept in the PluginServiceString[]getAllPluginNames(Class interfaceClass)Returns all of the names under which a named plugin implementing the interface can be requested (with getNamedPlugin()).ObjectgetNamedPlugin(Class interfaceClass, String name)Returns an instance of a plugin that implements the interface and is bound to a name matching name.Object[]getPluginSequence(Class interfaceClass)Returns instances of all plugins that implement the interface, in an Array.ObjectgetSinglePlugin(Class interfaceClass)Returns an instance of the singleton (single) plugin implementing the given interface.booleanhasNamedPlugin(Class interfaceClass, String name)Returns whether a plugin exists which implements the specified interface and has a specified name.
-
-
-
Method Detail
-
getAllPluginNames
String[] getAllPluginNames(Class interfaceClass)
Returns all of the names under which a named plugin implementing the interface can be requested (with getNamedPlugin()). The array is empty if there are no matches. Use this to populate a menu of plugins for interactive selection, or to document what the possible choices are.NOTE: The names are NOT returned in any deterministic order.
- Parameters:
interfaceClass- plugin interface for which to return names.- Returns:
- an array of strings with every name; if none are available an empty array is returned.
-
getNamedPlugin
Object getNamedPlugin(Class interfaceClass, String name)
Returns an instance of a plugin that implements the interface and is bound to a name matching name. If there is no matching plugin, it returns null. The names are matched by String.equals().- Parameters:
interfaceClass- the interface class of the pluginname- under which the plugin implementation is configured.- Returns:
- instance of plugin implementation, or null if there is no match or an error.
-
hasNamedPlugin
boolean hasNamedPlugin(Class interfaceClass, String name)
Returns whether a plugin exists which implements the specified interface and has a specified name. If a matching plugin is found to be configured, return true. If there is no matching plugin, return false.- Parameters:
interfaceClass- the interface class of the pluginname- under which the plugin implementation is configured.- Returns:
- true if plugin was found to be configured, false otherwise
-
getPluginSequence
Object[] getPluginSequence(Class interfaceClass)
Returns instances of all plugins that implement the interface, in an Array. Returns an empty array if no there are no matching plugins.The order of the plugins in the array is the same as their class names in the configuration's value field.
- Parameters:
interfaceClass- interface for which to find plugins.- Returns:
- an array of plugin instances; if none are available an empty array is returned.
-
getSinglePlugin
Object getSinglePlugin(Class interfaceClass)
Returns an instance of the singleton (single) plugin implementing the given interface. There must be exactly one single plugin configured for this interface, otherwise thePluginConfigurationErroris thrown.Note that this is the only "get plugin" method which throws an exception. It is typically used at initialization time to set up a permanent part of the system so any failure is fatal.
- Parameters:
interfaceClass- interface Class object- Returns:
- instance of plugin
-
clearNamedPluginClasses
void clearNamedPluginClasses()
This method has been created to have a way of clearing the cache kept in the PluginService
-
-