public class LegacyPluginServiceImpl extends Object implements PluginService
It creates and organizes components (plugins), and helps select a plugin in the cases where there are many possible choices. It also gives some limited control over the lifecycle of a plugin. It manages three different types (usage patterns) of plugins:
The name is just a String to be associated with the
combination of implementation class and interface. It may contain
any characters except for comma (,) and equals (=). It may contain
embedded spaces. Comma is a special character used to separate
names in the configuration entry.
SelfNamedPlugin| Modifier and Type | Field and Description |
|---|---|
protected ConfigurationService |
configurationService |
| Modifier | Constructor and Description |
|---|---|
protected |
LegacyPluginServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
checkConfiguration()
Validate the entries in the DSpace Configuration relevant to
LegacyPluginServiceImpl.
|
String[] |
getAllPluginNames(Class interfaceClass)
Returns all of the names under which a named plugin implementing
the interface can be requested (with 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.
|
Object[] |
getPluginSequence(Class interfaceClass)
Returns instances of all plugins that implement the interface,
in an Array.
|
Object |
getSinglePlugin(Class interfaceClass)
Returns an instance of the singleton (single) plugin implementing
the given interface.
|
boolean |
hasNamedPlugin(Class interfaceClass,
String name)
Returns whether a plugin exists which implements the specified interface
and has a specified name.
|
void |
main(String[] argv)
Invoking this class from the command line just runs
checkConfiguration and shows the results. |
@Autowired(required=true) protected ConfigurationService configurationService
public Object getSinglePlugin(Class interfaceClass) throws PluginConfigurationError, PluginInstantiationException
PluginConfigurationError is 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.
getSinglePlugin in interface PluginServiceinterfaceClass - interface Class objectPluginConfigurationErrorPluginInstantiationExceptionpublic Object[] getPluginSequence(Class interfaceClass) throws PluginInstantiationException
The order of the plugins in the array is the same as their class names in the configuration's value field.
getPluginSequence in interface PluginServiceinterfaceClass - interface for which to find plugins.PluginInstantiationExceptionpublic Object getNamedPlugin(Class interfaceClass, String name) throws PluginInstantiationException
getNamedPlugin in interface PluginServiceinterfaceClass - the interface class of the pluginname - under which the plugin implementation is configured.PluginInstantiationExceptionpublic boolean hasNamedPlugin(Class interfaceClass, String name) throws PluginInstantiationException
hasNamedPlugin in interface PluginServiceinterfaceClass - the interface class of the pluginname - under which the plugin implementation is configured.PluginInstantiationExceptionpublic String[] getAllPluginNames(Class interfaceClass)
NOTE: The names are NOT returned in any deterministic order.
getAllPluginNames in interface PluginServiceinterfaceClass - plugin interface for which to return names.public void checkConfiguration()
throws IOException
SelfNamedPlugin
IOException - if IO errorCopyright © 2017 DuraSpace. All rights reserved.