Refactor PluginManager into PluginService and LegacyPluginServiceImpl. Add unit tests.

This commit is contained in:
Tim Donohue
2015-10-15 11:47:12 -05:00
parent 0466184350
commit 3df18c68b8
47 changed files with 507 additions and 426 deletions

View File

@@ -18,6 +18,7 @@ import org.dspace.core.*;
import org.dspace.handle.factory.HandleServiceFactory;
import java.util.*;
import org.dspace.core.factory.CoreServiceFactory;
/**
* MediaFilterManager is the class that invokes the media/format filters over the
@@ -178,7 +179,7 @@ public class MediaFilterCLITool {
for(int i=0; i< filterNames.length; i++)
{
//get filter of this name & add to list of filters
FormatFilter filter = (FormatFilter) PluginManager.getNamedPlugin(FormatFilter.class, filterNames[i]);
FormatFilter filter = (FormatFilter) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(FormatFilter.class, filterNames[i]);
if(filter==null)
{
System.err.println("\nERROR: Unknown MediaFilter specified (either from command-line or in dspace.cfg): '" + filterNames[i] + "'");

View File

@@ -29,7 +29,8 @@ import org.dspace.content.packager.PackageParameters;
import org.dspace.content.packager.PackageIngester;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import org.dspace.eperson.EPerson;
import org.dspace.eperson.factory.EPersonServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory;
@@ -164,6 +165,7 @@ public class Packager
String[] parents = null;
String identifier = null;
PackageParameters pkgParams = new PackageParameters();
PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
//initialize a new packager -- we'll add all our current params as settings
Packager myPackager = new Packager();
@@ -182,7 +184,7 @@ public class Packager
System.out.println("--------------------------------------------------------------");
System.out.println("(These options may be specified using --option as described above)");
PackageIngester sip = (PackageIngester) PluginManager
PackageIngester sip = (PackageIngester) pluginService
.getNamedPlugin(PackageIngester.class, line.getOptionValue('t'));
if (sip != null)
@@ -195,7 +197,7 @@ public class Packager
System.out.println("\nNo valid Submission plugin found for " + line.getOptionValue('t') + " type.");
}
PackageDisseminator dip = (PackageDisseminator) PluginManager
PackageDisseminator dip = (PackageDisseminator) pluginService
.getNamedPlugin(PackageDisseminator.class, line.getOptionValue('t'));
if (dip != null)
@@ -212,7 +214,7 @@ public class Packager
else //otherwise, display list of valid packager types
{
System.out.println("\nAvailable Submission Package (SIP) types:");
String pn[] = PluginManager
String pn[] = pluginService
.getAllPluginNames(PackageIngester.class);
for (int i = 0; i < pn.length; ++i)
{
@@ -220,7 +222,7 @@ public class Packager
}
System.out
.println("\nAvailable Dissemination Package (DIP) types:");
pn = PluginManager.getAllPluginNames(PackageDisseminator.class);
pn = pluginService.getAllPluginNames(PackageDisseminator.class);
for (int i = 0; i < pn.length; ++i)
{
System.out.println(" " + pn[i]);
@@ -329,7 +331,7 @@ public class Packager
//If we are in REPLACE mode
if(pkgParams.replaceModeEnabled())
{
PackageIngester sip = (PackageIngester) PluginManager
PackageIngester sip = (PackageIngester) pluginService
.getNamedPlugin(PackageIngester.class, myPackager.packageType);
if (sip == null)
{
@@ -392,7 +394,7 @@ public class Packager
//else if normal SUBMIT mode (or basic RESTORE mode -- which is a special type of submission)
else if (myPackager.submit || pkgParams.restoreModeEnabled())
{
PackageIngester sip = (PackageIngester) PluginManager
PackageIngester sip = (PackageIngester) pluginService
.getNamedPlugin(PackageIngester.class, myPackager.packageType);
if (sip == null)
{
@@ -444,7 +446,7 @@ public class Packager
else
{
//retrieve specified package disseminator
PackageDisseminator dip = (PackageDisseminator) PluginManager
PackageDisseminator dip = (PackageDisseminator) pluginService
.getNamedPlugin(PackageDisseminator.class, myPackager.packageType);
if (dip == null)
{

View File

@@ -18,7 +18,7 @@ import java.util.List;
import org.dspace.authenticate.service.AuthenticationService;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.eperson.EPerson;
import org.dspace.eperson.Group;
import org.dspace.eperson.service.EPersonService;
@@ -68,7 +68,7 @@ public class AuthenticationServiceImpl implements AuthenticationService, Initial
@Override
public void afterPropertiesSet() throws Exception {
methodStack = Arrays.asList((AuthenticationMethod[])PluginManager.getPluginSequence("authentication", AuthenticationMethod.class));
methodStack = Arrays.asList((AuthenticationMethod[])CoreServiceFactory.getInstance().getPluginService().getPluginSequence(AuthenticationMethod.class));
}
@Override

View File

@@ -8,9 +8,9 @@
package org.dspace.checker;
import org.dspace.content.Bitstream;
import org.dspace.core.PluginManager;
import java.sql.SQLException;
import org.dspace.core.factory.CoreServiceFactory;
/**
* Decorator that dispatches a specified number of bitstreams from a delegate
@@ -30,11 +30,11 @@ public class LimitedCountDispatcher implements BitstreamDispatcher
private BitstreamDispatcher delegate = null;
/**
* Default constructor uses PluginManager
* Default constructor uses LegacyPluginServiceImpl
*/
public LimitedCountDispatcher()
{
this((BitstreamDispatcher) PluginManager
this((BitstreamDispatcher) CoreServiceFactory.getInstance().getPluginService()
.getSinglePlugin(BitstreamDispatcher.class));
}

View File

@@ -10,16 +10,16 @@ package org.dspace.content.authority;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Enumeration;
import java.util.Iterator;
import org.apache.log4j.Logger;
import org.dspace.content.Collection;
import org.dspace.content.MetadataValue;
import org.dspace.content.authority.service.ChoiceAuthorityService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.PluginManager;
import org.springframework.beans.factory.InitializingBean;
import org.dspace.core.service.PluginService;
import org.dspace.services.ConfigurationService;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Broker for ChoiceAuthority plugins, and for other information configured
@@ -40,7 +40,7 @@ import org.springframework.beans.factory.InitializingBean;
* @author Larry Stone
* @see ChoiceAuthority
*/
public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService, InitializingBean
public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService
{
private Logger log = Logger.getLogger(ChoiceAuthorityServiceImpl.class);
@@ -53,22 +53,32 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService,
// map of field key to closed value
protected Map<String,Boolean> closed = new HashMap<String,Boolean>();
@Autowired(required = true)
protected ConfigurationService configurationService;
@Autowired(required = true)
protected PluginService pluginService;
private ChoiceAuthorityServiceImpl() {
}
@Override
public void afterPropertiesSet() throws Exception
/**
* Initialize the bean (after dependency injection has already taken place).
* Ensures the configurationService is injected, so that we can load
* choices from configuration.
* Called by "init-method" in Spring config.
*/
public void init() throws Exception
{
Enumeration pn = ConfigurationManager.propertyNames();
List<String> propKeys = configurationService.getPropertyKeys("choices");
Iterator<String> keyIterator = propKeys.iterator();
final String choicesPrefix = "choices.";
final String choicesPlugin = "choices.plugin.";
final String choicesPresentation = "choices.presentation.";
final String choicesClosed = "choices.closed.";
property:
while (pn.hasMoreElements())
while (keyIterator.hasNext())
{
String key = (String)pn.nextElement();
String key = keyIterator.next();
if (key.startsWith(choicesPrefix))
{
if (key.startsWith(choicesPlugin))
@@ -82,12 +92,11 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService,
// XXX FIXME maybe add sanity check, call
// MetadataField.findByElement to make sure it's a real field.
ChoiceAuthority ma = (ChoiceAuthority)
PluginManager.getNamedPlugin(ChoiceAuthority.class, ConfigurationManager.getProperty(key));
pluginService.getNamedPlugin(ChoiceAuthority.class, configurationService.getProperty(key));
if (ma == null)
{
log.warn("Skipping invalid configuration for "+key+" because named plugin not found: "+ConfigurationManager.getProperty(key));
log.warn("Skipping invalid configuration for "+key+" because named plugin not found: "+configurationService.getProperty(key));
continue property;
}
controller.put(fkey, ma);
@@ -102,7 +111,7 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService,
log.warn("Skipping invalid ChoiceAuthority configuration property: "+key+": does not have schema.element.qualifier");
continue property;
}
presentation.put(fkey, ConfigurationManager.getProperty(key));
presentation.put(fkey, configurationService.getProperty(key));
}
else if (key.startsWith(choicesClosed))
{
@@ -112,7 +121,7 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService,
log.warn("Skipping invalid ChoiceAuthority configuration property: "+key+": does not have schema.element.qualifier");
continue property;
}
closed.put(fkey, Boolean.valueOf(ConfigurationManager.getBooleanProperty(key)));
closed.put(fkey, configurationService.getBooleanProperty(key));
}
else
{

View File

@@ -22,7 +22,7 @@ import org.dspace.content.packager.PackageParameters;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
@@ -101,7 +101,7 @@ public class METSDisseminationCrosswalk
}
PackageDisseminator dip = (PackageDisseminator)
PluginManager.getNamedPlugin(PackageDisseminator.class, METS_PACKAGER_PLUGIN);
CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(PackageDisseminator.class, METS_PACKAGER_PLUGIN);
if (dip == null)
{
throw new CrosswalkInternalException("Cannot find a disseminate plugin for package=" + METS_PACKAGER_PLUGIN);

View File

@@ -23,7 +23,7 @@ import org.dspace.content.packager.RoleDisseminator;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.workflow.WorkflowException;
import org.jdom.Document;
import org.jdom.Element;
@@ -176,7 +176,7 @@ public class RoleCrosswalk
try
{
PackageDisseminator dip = (PackageDisseminator)
PluginManager.getNamedPlugin(PackageDisseminator.class, ROLE_PACKAGER_PLUGIN);
CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(PackageDisseminator.class, ROLE_PACKAGER_PLUGIN);
if (dip == null)
{
throw new CrosswalkInternalException("Cannot find a PackageDisseminator plugin named " + ROLE_PACKAGER_PLUGIN);
@@ -286,7 +286,7 @@ public class RoleCrosswalk
//locate our "DSPACE-ROLES" PackageIngester plugin
PackageIngester sip = (PackageIngester)
PluginManager.getNamedPlugin(PackageIngester.class, ROLE_PACKAGER_PLUGIN);
CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(PackageIngester.class, ROLE_PACKAGER_PLUGIN);
if (sip == null)
{
throw new CrosswalkInternalException("Cannot find a PackageIngester plugin named " + ROLE_PACKAGER_PLUGIN);

View File

@@ -28,7 +28,7 @@ import org.dspace.content.service.ItemService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory;
import org.jdom.Document;
import org.jdom.Element;
@@ -525,7 +525,7 @@ public class XSLTDisseminationCrosswalk
}
}
DisseminationCrosswalk xwalk = (DisseminationCrosswalk)PluginManager.getNamedPlugin(
DisseminationCrosswalk xwalk = (DisseminationCrosswalk) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(
DisseminationCrosswalk.class, xwalkname);
if (xwalk == null)
{

View File

@@ -30,7 +30,7 @@ import org.dspace.content.service.CommunityService;
import org.dspace.content.service.ItemService;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
@@ -287,7 +287,7 @@ public class XSLTIngestionCrosswalk
++i;
list = true;
}
IngestionCrosswalk xwalk = (IngestionCrosswalk)PluginManager.getNamedPlugin(
IngestionCrosswalk xwalk = (IngestionCrosswalk) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(
IngestionCrosswalk.class, argv[i]);
if (xwalk == null)
{

View File

@@ -10,12 +10,12 @@ package org.dspace.content.license;
import java.util.Formattable;
import java.util.Formatter;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
/**
* Wrapper class to make formattable any argument used in the license template.
* The formatter behavior is delegated to a specific class on "type" basis
* using the PluginManager
* using the PluginService
*
* @see Formattable
* @see LicenseArgumentFormatter
@@ -38,7 +38,7 @@ public class FormattableArgument implements Formattable
public void formatTo(Formatter formatter, int flags, int width,
int precision)
{
LicenseArgumentFormatter laf = (LicenseArgumentFormatter) PluginManager
LicenseArgumentFormatter laf = (LicenseArgumentFormatter) CoreServiceFactory.getInstance().getPluginService()
.getNamedPlugin(LicenseArgumentFormatter.class, type);
if (laf != null)
{

View File

@@ -73,8 +73,9 @@ import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.core.PluginManager;
import org.dspace.core.Utils;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import org.dspace.license.factory.LicenseServiceFactory;
import org.dspace.license.service.CreativeCommonsService;
import org.jdom.Element;
@@ -583,14 +584,16 @@ public abstract class AbstractMETSDisseminator
xwalkName = typeSpec;
}
PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
// First, check to see if the crosswalk we are using is a normal DisseminationCrosswalk
boolean xwalkFound = PluginManager.hasNamedPlugin(DisseminationCrosswalk.class, xwalkName);
boolean xwalkFound = pluginService.hasNamedPlugin(DisseminationCrosswalk.class, xwalkName);
if(xwalkFound)
{
// Find the crosswalk we will be using to generate the metadata for this mdSec
DisseminationCrosswalk xwalk = (DisseminationCrosswalk)
PluginManager.getNamedPlugin(DisseminationCrosswalk.class, xwalkName);
pluginService.getNamedPlugin(DisseminationCrosswalk.class, xwalkName);
if (xwalk.canDisseminate(dso))
{
@@ -629,7 +632,7 @@ public abstract class AbstractMETSDisseminator
else
{
StreamDisseminationCrosswalk sxwalk = (StreamDisseminationCrosswalk)
PluginManager.getNamedPlugin(StreamDisseminationCrosswalk.class, xwalkName);
pluginService.getNamedPlugin(StreamDisseminationCrosswalk.class, xwalkName);
if (sxwalk != null)
{
if (sxwalk.canDisseminate(context, dso))

View File

@@ -20,8 +20,9 @@ import org.dspace.content.crosswalk.CrosswalkException;
import org.dspace.content.crosswalk.MetadataValidationException;
import org.dspace.core.Context;
import org.dspace.core.Constants;
import org.dspace.core.PluginManager;
import org.dspace.app.mediafilter.MediaFilter;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import org.jdom.Element;
@@ -199,12 +200,14 @@ public class DSpaceMETSIngester
// only needed when importing a SIP without canonical DSpace derived file naming.
private String makeDerivedFilename(String bundleName, String origName)
{
PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
// get the MediaFilter that would create this bundle:
String mfNames[] = PluginManager.getAllPluginNames(MediaFilter.class);
String mfNames[] = pluginService.getAllPluginNames(MediaFilter.class);
for (int i = 0; i < mfNames.length; ++i)
{
MediaFilter mf = (MediaFilter)PluginManager.getNamedPlugin(MediaFilter.class, mfNames[i]);
MediaFilter mf = (MediaFilter)pluginService.getNamedPlugin(MediaFilter.class, mfNames[i]);
if (bundleName.equals(mf.getBundleName()))
{
return mf.getFilteredName(origName);

View File

@@ -32,7 +32,7 @@ import org.dspace.content.crosswalk.StreamIngestionCrosswalk;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.jdom.Document;
import org.jdom.Content;
import org.jdom.Element;
@@ -989,7 +989,7 @@ public class METSManifest
xwalkName = type;
}
}
return PluginManager.getNamedPlugin(clazz, xwalkName);
return CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(clazz, xwalkName);
}
/**

View File

@@ -13,19 +13,23 @@ import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.dspace.core.service.PluginService;
import org.dspace.services.ConfigurationService;
import org.dspace.utils.DSpace;
import org.springframework.beans.factory.annotation.Autowired;
/**
* The Plugin Manager is a very simple component container. 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
* The Legacy Plugin Service is a very simple component container (based on the
* legacy PluginManager class). It reads defined "plugins" (interfaces) from
* config file(s) and makes them available to the API. (@TODO: Someday, this
* entire "plugin" framework needs to be replaced by Spring Beans.)
* <p>
* 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:
* <p>
@@ -53,12 +57,13 @@ import org.dspace.utils.DSpace;
* names in the configuration entry.
*
* @author Larry Stone
* @author Tim Donohue (turned old PluginManager into a PluginService)
* @see SelfNamedPlugin
*/
public class PluginManager
public class LegacyPluginServiceImpl implements PluginService
{
/** log4j category */
private static Logger log = Logger.getLogger(PluginManager.class);
private static Logger log = Logger.getLogger(LegacyPluginServiceImpl.class);
/**
* Prefixes of names of properties to look for in DSpace Configuration
@@ -78,51 +83,32 @@ public class PluginManager
private static final String SEP = "\034";
/** Paths to search for third-party plugins. */
private static final String[] classPath;
static {
String path = new DSpace().getConfigurationService().getProperty(CLASSPATH);
private String[] classPath;
/** Custom class loader to search for third-party plugins. */
private PathsClassLoader loader;
@Autowired(required = true)
protected ConfigurationService configurationService;
private LegacyPluginServiceImpl() {
}
/**
* Initialize the bean (after dependency injection has already taken place).
* Ensures the configurationService is injected, so that we can load
* plugin classpath info from config.
* Called by "init-method" in Spring config.
*/
void init()
{
String path = configurationService.getProperty(CLASSPATH);
if (null == path)
classPath = new String[0];
else
classPath = path.split(":");
}
/** Custom class loader to search for third-party plugins. */
private static final PathsClassLoader loader
= new PathsClassLoader(PluginManager.class.getClassLoader(), classPath);
// Map of plugin class to "reusable" metric (as Boolean, must be Object)
// Key is Class, value is Boolean (true by default).
private static Map<Class<Object>, Boolean> cacheMeCache = new HashMap<Class<Object>, Boolean>();
/**
* Whether or not to cache instances of this class. Ironically,
* the cacheability information is itself cached.
* <P>
* By default, all plugin class instances ARE cached. To disable instance
* caching for a specific plugin class, you must add a configuration similar
* to this in your dspace.cfg:
* <code>
* plugin.reusable.[full-class-name] = false
* </code>
* @return true if class instances should be cached in memory, false otherwise.
*/
private static boolean cacheMe(String module, Class implClass)
{
if (cacheMeCache.containsKey(implClass))
{
return (cacheMeCache.get(implClass)).booleanValue();
}
else
{
ConfigurationService config = new DSpace().getConfigurationService();
String key = REUSABLE_PREFIX+implClass.getName();
// NOTE: module name is ignored, as reusable plugins configs ALWAYS begin with REUSABLE_PREFIX
boolean reusable = config.getBooleanProperty(key, true);
cacheMeCache.put(implClass, Boolean.valueOf(reusable));
return reusable;
}
loader = new PathsClassLoader(LegacyPluginServiceImpl.class.getClassLoader(), classPath);
}
/**
@@ -139,28 +125,8 @@ public class PluginManager
* @return instance of plugin
* @throws PluginConfigurationError
*/
public static Object getSinglePlugin(Class interfaceClass)
throws PluginConfigurationError, PluginInstantiationException
{
return getSinglePlugin(null, 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 the
* <code>PluginConfigurationError</code> is thrown.
* <p>
* 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.
*
* @param module name of config module, or <code>null</code> for standard location
* @param interfaceClass interface Class object
* @return instance of plugin
* @throws PluginConfigurationError
*/
public static Object getSinglePlugin(String module, Class interfaceClass)
@Override
public Object getSinglePlugin(Class interfaceClass)
throws PluginConfigurationError, PluginInstantiationException
{
String iname = interfaceClass.getName();
@@ -168,11 +134,11 @@ public class PluginManager
// NOTE: module name is ignored, as single plugins ALWAYS begin with SINGLE_PREFIX
String key = SINGLE_PREFIX+iname;
// configuration format is prefix.<interface> = <classname>
String classname = new DSpace().getConfigurationService().getProperty(key);
String classname = configurationService.getProperty(key);
if (classname != null)
{
return getAnonymousPlugin(module, classname.trim());
return getAnonymousPlugin(classname.trim());
}
else
{
@@ -180,58 +146,40 @@ public class PluginManager
}
}
/**
* Returns instances of all plugins that implement the interface,
* in an Array. Returns an empty array if no there are no
* matching plugins.
* <p>
* The order of the plugins in the array is the same as their class
* names in the configuration's value field.
*
* @param interfaceClass interface for which to find plugins.
* @return an array of plugin instances; if none are
* available an empty array is returned.
*/
@Override
public Object[] getPluginSequence(Class interfaceClass)
throws PluginInstantiationException
{
// cache of config data for Sequence Plugins; format its
// <interface-name> -> [ <classname>.. ] (value is Array)
private static Map<String, String[]> sequenceConfig = new HashMap<String, String[]>();
Map<String, String[]> sequenceConfig = new HashMap<String, String[]>();
/**
* Returns instances of all plugins that implement the interface
* intface, in an Array. Returns an empty array if no there are no
* matching plugins.
* <p>
* The order of the plugins in the array is the same as their class
* names in the configuration's value field.
*
* @param intfc interface for which to find plugins.
* @return an array of plugin instances; if none are
* available an empty array is returned.
*/
public static Object[] getPluginSequence(Class intfc)
throws PluginInstantiationException
{
return getPluginSequence(null, intfc);
}
/**
* Returns instances of all plugins that implement the interface
* intface, in an Array. Returns an empty array if no there are no
* matching plugins.
* <p>
* The order of the plugins in the array is the same as their class
* names in the configuration's value field.
*
* @param module name of config module, or <code>null</code> for standard
* @param intfc interface for which to find plugins.
* @return an array of plugin instances; if none are
* available an empty array is returned.
*/
public static Object[] getPluginSequence(String module, Class intfc)
throws PluginInstantiationException
{
// cache the configuration for this interface after grovelling it once:
// format is prefix.<interface> = <classname>
String iname = intfc.getName();
String iname = interfaceClass.getName();
String[] classname = null;
if (!sequenceConfig.containsKey(iname))
{
// NOTE: module name is ignored, as sequence plugins ALWAYS begin with SEQUENCE_PREFIX
String key = SEQUENCE_PREFIX+iname;
classname = new DSpace().getConfigurationService().getArrayProperty(key);
classname = configurationService.getArrayProperty(key);
if (classname == null || classname.length==0)
{
log.warn("No Configuration entry found for Sequence Plugin interface="+iname);
return (Object[]) Array.newInstance(intfc, 0);
return (Object[]) Array.newInstance(interfaceClass, 0);
}
sequenceConfig.put(iname, classname);
}
@@ -240,52 +188,31 @@ public class PluginManager
classname = sequenceConfig.get(iname);
}
Object result[] = (Object[])Array.newInstance(intfc, classname.length);
Object result[] = (Object[])Array.newInstance(interfaceClass, classname.length);
for (int i = 0; i < classname.length; ++i)
{
log.debug("Adding Sequence plugin for interface= "+iname+", class="+classname[i]);
result[i] = getAnonymousPlugin(module, classname[i]);
result[i] = getAnonymousPlugin(classname[i]);
}
return result;
}
// Map of cached (reusable) single plugin instances - class -> instance.
private static Map<Serializable, Object> anonymousInstanceCache = new HashMap<Serializable, Object>();
// Get possibly-cached plugin instance for un-named plugin,
// this is shared by Single and Sequence plugins.
private static Object getAnonymousPlugin(String module, String classname)
private Object getAnonymousPlugin(String classname)
throws PluginInstantiationException
{
try
{
Class pluginClass = Class.forName(classname, true, loader);
if (cacheMe(module, pluginClass))
{
Object cached = anonymousInstanceCache.get(pluginClass);
if (cached == null)
{
cached = pluginClass.newInstance();
anonymousInstanceCache.put(pluginClass, cached);
}
return cached;
}
else
{
return pluginClass.newInstance();
}
}
catch (ClassNotFoundException e)
{
throw new PluginInstantiationException("Cannot load plugin class: " +
e.toString(), e);
}
catch (InstantiationException e)
{
throw new PluginInstantiationException(e);
}
catch (IllegalAccessException e)
catch (InstantiationException|IllegalAccessException e)
{
throw new PluginInstantiationException(e);
}
@@ -293,13 +220,13 @@ public class PluginManager
// Map of named plugin classes, [intfc,name] -> class
// Also contains intfc -> "marker" to mark when interface has been loaded.
private static Map<String, String> namedPluginClasses = new HashMap<String, String>();
private Map<String, String> namedPluginClasses = new HashMap<String, String>();
// Map of cached (reusable) named plugin instances, [class,name] -> instance
private static Map<Serializable, Object> namedInstanceCache = new HashMap<Serializable, Object>();
private Map<Serializable, Object> namedInstanceCache = new HashMap<Serializable, Object>();
// load and cache configuration data for the given interface.
private static void configureNamedPlugin(String module, String iname)
private void configureNamedPlugin(String iname)
throws ClassNotFoundException
{
int found = 0;
@@ -317,7 +244,7 @@ public class PluginManager
// <CLASS> = <name>\, <name> [ ... ]
// NOTE: module name is ignored, as named plugins ALWAYS begin with NAMED_PREFIX
String key = NAMED_PREFIX+iname;
String[] namedVals = new DSpace().getConfigurationService().getArrayProperty(key);
String[] namedVals = configurationService.getArrayProperty(key);
if (namedVals != null && namedVals.length>0)
{
String prevClassName = null;
@@ -356,7 +283,7 @@ public class PluginManager
// format is plugin.selfnamed.<INTF> = <CLASS> , <CLASS> ..
// NOTE: module name is ignored, as self-named plugins ALWAYS begin with SELFNAMED_PREFIX
key = SELFNAMED_PREFIX+iname;
String[] selfNamedVals = new DSpace().getConfigurationService().getArrayProperty(key);
String[] selfNamedVals = configurationService.getArrayProperty(key);
if (selfNamedVals != null && selfNamedVals.length>0)
{
for (String classname : selfNamedVals)
@@ -394,7 +321,7 @@ public class PluginManager
}
// add info for a named plugin to cache, under all its names.
private static int installNamedConfigs(String iname, String classname, String names[])
private int installNamedConfigs(String iname, String classname, String names[])
throws ClassNotFoundException
{
int found = 0;
@@ -418,38 +345,22 @@ public class PluginManager
/**
* Returns an instance of a plugin that implements the interface
* intface and is bound to a name matching name. If there is no
* and is bound to a name matching name. If there is no
* matching plugin, it returns null. The names are matched by
* String.equals().
*
* @param intfc the interface class of the plugin
* @param interfaceClass the interface class of the plugin
* @param name under which the plugin implementation is configured.
* @return instance of plugin implementation, or null if there is no match or an error.
*/
public static Object getNamedPlugin(Class intfc, String name)
throws PluginInstantiationException
{
return getNamedPlugin(null, intfc, name);
}
/**
* Returns an instance of a plugin that implements the interface
* intface and is bound to a name matching name. If there is no
* matching plugin, it returns null. The names are matched by
* String.equals().
*
* @param module config module, or <code>null</code> for standard location
* @param intfc the interface class of the plugin
* @param name under which the plugin implementation is configured.
* @return instance of plugin implementation, or null if there is no match or an error.
*/
public static Object getNamedPlugin(String module, Class intfc, String name)
@Override
public Object getNamedPlugin(Class interfaceClass, String name)
throws PluginInstantiationException
{
try
{
String iname = intfc.getName();
configureNamedPlugin(module, iname);
String iname = interfaceClass.getName();
configureNamedPlugin(iname);
String key = iname + SEP + name;
String cname = namedPluginClasses.get(key);
if (cname == null)
@@ -459,27 +370,7 @@ public class PluginManager
else
{
Class pluginClass = Class.forName(cname, true, loader);
if (cacheMe(module, pluginClass))
{
String nkey = pluginClass.getName() + SEP + name;
Object cached = namedInstanceCache.get(nkey);
if (cached == null)
{
log.debug("Creating cached instance of: " + cname +
" for interface=" + iname +
" pluginName=" + name );
cached = pluginClass.newInstance();
if (cached instanceof SelfNamedPlugin)
{
((SelfNamedPlugin) cached).setPluginInstanceName(name);
}
namedInstanceCache.put(nkey, cached);
}
return cached;
}
else
{
log.debug("Creating UNcached instance of: " + cname +
log.debug("Creating instance of: " + cname +
" for interface=" + iname +
" pluginName=" + name );
Object result = pluginClass.newInstance();
@@ -490,17 +381,12 @@ public class PluginManager
return result;
}
}
}
catch (ClassNotFoundException e)
{
throw new PluginInstantiationException("Cannot load plugin class: " +
e.toString(), e);
}
catch (InstantiationException e)
{
throw new PluginInstantiationException(e);
}
catch (IllegalAccessException e)
catch (InstantiationException|IllegalAccessException e)
{
throw new PluginInstantiationException(e);
}
@@ -513,33 +399,18 @@ public class PluginManager
* and has a specified name. If a matching plugin is found to be configured,
* return true. If there is no matching plugin, return false.
*
* @param intfc the interface class of the plugin
* @param interfaceClass the interface class of the plugin
* @param name under which the plugin implementation is configured.
* @return true if plugin was found to be configured, false otherwise
*/
public static boolean hasNamedPlugin(Class intfc, String name)
throws PluginInstantiationException
{
return hasNamedPlugin(null, intfc, 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.
*
* @param module the config module or <code>null</code> for regular location
* @param intfc the interface class of the plugin
* @param name under which the plugin implementation is configured.
* @return true if plugin was found to be configured, false otherwise
*/
public static boolean hasNamedPlugin(String module, Class intfc, String name)
@Override
public boolean hasNamedPlugin(Class interfaceClass, String name)
throws PluginInstantiationException
{
try
{
String iname = intfc.getName();
configureNamedPlugin(module, iname);
String iname = interfaceClass.getName();
configureNamedPlugin(iname);
String key = iname + SEP + name;
return namedPluginClasses.get(key) != null;
}
@@ -552,42 +423,24 @@ public class PluginManager
/**
* Returns all of the names under which a named plugin implementing
* the interface intface can be requested (with getNamedPlugin()).
* 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.
* <p>
* NOTE: The names are NOT returned in any deterministic order.
*
* @param intfc plugin interface for which to return names.
* @param interfaceClass plugin interface for which to return names.
* @return an array of strings with every name; if none are
* available an empty array is returned.
*/
public static String[] getAllPluginNames(Class intfc)
{
return getAllPluginNames(null, intfc);
}
/**
* Returns all of the names under which a named plugin implementing
* the interface intface 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.
* <p>
* NOTE: The names are NOT returned in any deterministic order.
*
* @param module the module name
* @param intfc plugin interface for which to return names.
* @return an array of strings with every name; if none are
* available an empty array is returned.
*/
public static String[] getAllPluginNames(String module, Class intfc)
@Override
public String[] getAllPluginNames(Class interfaceClass)
{
try
{
String iname = intfc.getName();
configureNamedPlugin(module, iname);
String iname = interfaceClass.getName();
configureNamedPlugin(iname);
String prefix = iname + SEP;
ArrayList<String> result = new ArrayList<String>();
@@ -611,43 +464,13 @@ public class PluginManager
}
}
/**
* Tells the Plugin Manager to let go of any references to a
* reusable plugin, to prevent it from being given out again and to
* allow the object to be garbage-collected. Call this when a
* plugin instance must be taken out of circulation.
*
* @param plugin the object to release, must have been created by
* <code>getNamedPlugin</code> etc.
*/
public static void releasePlugin(Object plugin)
{
forgetInstance(plugin, namedInstanceCache);
forgetInstance(plugin, anonymousInstanceCache);
}
private static void forgetInstance(Object plugin, Map<Serializable, Object> cacheMap)
{
Collection values = cacheMap.values();
Iterator ci = values.iterator();
while (ci.hasNext())
{
// Identity comparison is valid for this usage
Object val = ci.next();
if (val == plugin)
{
values.remove(val);
}
}
}
/* -----------------------------------------------------------------
* Code to check configuration is all below this line
* -----------------------------------------------------------------
*/
// true if classname is valid and loadable.
private static boolean checkClassname(String iname, String msg)
private boolean checkClassname(String iname, String msg)
{
try
{
@@ -664,7 +487,7 @@ public class PluginManager
}
// true if classname is loadable AND is subclass of SelfNamedPlugin
private static boolean checkSelfNamed(String iname)
private boolean checkSelfNamed(String iname)
{
try
{
@@ -681,7 +504,7 @@ public class PluginManager
}
// recursively climb superclass stack until we find SelfNamedPlugin
private static boolean checkSelfNamed(Class cls)
private boolean checkSelfNamed(Class cls)
{
Class sup = cls.getSuperclass();
if (sup == null)
@@ -700,11 +523,11 @@ public class PluginManager
// check named-plugin names by interface -- call the usual
// configuration and let it find missing or duplicate names.
private static void checkNames(String iname)
private void checkNames(String iname)
{
try
{
configureNamedPlugin(null, iname);
configureNamedPlugin(iname);
}
catch (ClassNotFoundException ce)
{
@@ -714,7 +537,7 @@ public class PluginManager
/**
* Validate the entries in the DSpace Configuration relevant to
* PluginManager. Look for inconsistencies, illegal syntax, etc.
LegacyPluginServiceImpl. Look for inconsistencies, illegal syntax, etc.
* Announce violations with "log.error" so they appear in the log
* or in the standard error stream if this is run interactively.
* <ul>
@@ -727,7 +550,7 @@ public class PluginManager
* <li>Named plugin entries lacking names.
* </ul>
*/
public static void checkConfiguration()
public void checkConfiguration()
throws IOException
{
FileReader fr = null;
@@ -745,9 +568,8 @@ public class PluginManager
Map<String, String> reusableKey = new HashMap<String, String>();
HashMap<String, String> keyMap = new HashMap<String, String>();
ConfigurationService config = new DSpace().getConfigurationService();
// Find all property keys starting with "plugin."
List<String> keys = config.getPropertyKeys("plugin.");
List<String> keys = configurationService.getPropertyKeys("plugin.");
for(String key : keys)
{
@@ -803,7 +625,7 @@ public class PluginManager
while (ii.hasNext())
{
String key = ii.next();
String val = config.getProperty(SINGLE_PREFIX+key);
String val = configurationService.getProperty(SINGLE_PREFIX+key);
if (val == null)
{
log.error("Single plugin config not found for: " + SINGLE_PREFIX + key);
@@ -823,7 +645,7 @@ public class PluginManager
while (ii.hasNext())
{
String key = ii.next();
String[] vals = config.getArrayProperty(SEQUENCE_PREFIX+key);
String[] vals = configurationService.getArrayProperty(SEQUENCE_PREFIX+key);
if (vals == null || vals.length==0)
{
log.error("Sequence plugin config not found for: " + SEQUENCE_PREFIX + key);
@@ -846,7 +668,7 @@ public class PluginManager
while (ii.hasNext())
{
String key = ii.next();
String[] vals = config.getArrayProperty(SELFNAMED_PREFIX+key);
String[] vals = configurationService.getArrayProperty(SELFNAMED_PREFIX+key);
if (vals == null || vals.length==0)
{
log.error("Selfnamed plugin config not found for: " + SELFNAMED_PREFIX + key);
@@ -871,7 +693,7 @@ public class PluginManager
while (ii.hasNext())
{
String key = ii.next();
String[] vals =config.getArrayProperty(NAMED_PREFIX+key);
String[] vals = configurationService.getArrayProperty(NAMED_PREFIX+key);
if (vals == null || vals.length==0)
{
log.error("Named plugin config not found for: " + NAMED_PREFIX + key);
@@ -910,7 +732,7 @@ public class PluginManager
* <code>checkConfiguration</code> and shows the results.
* There are no command-line options.
*/
public static void main(String[] argv) throws Exception
public void main(String[] argv) throws Exception
{
checkConfiguration();
}

View File

@@ -9,6 +9,7 @@ package org.dspace.core.factory;
import org.dspace.core.service.LicenseService;
import org.dspace.core.service.NewsService;
import org.dspace.core.service.PluginService;
import org.dspace.utils.DSpace;
/**
@@ -22,6 +23,8 @@ public abstract class CoreServiceFactory {
public abstract NewsService getNewsService();
public abstract PluginService getPluginService();
public static CoreServiceFactory getInstance()
{
return new DSpace().getServiceManager().getServiceByName("coreServiceFactory", CoreServiceFactory.class);

View File

@@ -9,6 +9,7 @@ package org.dspace.core.factory;
import org.dspace.core.service.LicenseService;
import org.dspace.core.service.NewsService;
import org.dspace.core.service.PluginService;
import org.springframework.beans.factory.annotation.Autowired;
/**
@@ -24,6 +25,9 @@ public class CoreServiceFactoryImpl extends CoreServiceFactory {
@Autowired(required = true)
private NewsService newsService;
@Autowired(required = true)
private PluginService pluginService;
@Override
public LicenseService getLicenseService() {
return licenseService;
@@ -33,4 +37,9 @@ public class CoreServiceFactoryImpl extends CoreServiceFactory {
public NewsService getNewsService() {
return newsService;
}
@Override
public PluginService getPluginService() {
return pluginService;
}
}

View File

@@ -0,0 +1,84 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.core.service;
/**
* A service to manage "plugins". At this point, it's based off of the structure
* of the legacy PluginManager, until a better plugin definition is created.
*
* @author Tim Donohue
*/
public interface PluginService
{
/**
* 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.
* <p>
* NOTE: The names are NOT returned in any deterministic order.
*
* @param interfaceClass plugin interface for which to return names.
* @return an array of strings with every name; if none are
* available an empty array is returned.
*/
public String[] getAllPluginNames(Class interfaceClass);
/**
* 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().
*
* @param interfaceClass the interface class of the plugin
* @param name under which the plugin implementation is configured.
* @return instance of plugin implementation, or null if there is no match or an error.
*/
public Object getNamedPlugin(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.
*
* @param interfaceClass the interface class of the plugin
* @param name under which the plugin implementation is configured.
* @return true if plugin was found to be configured, false otherwise
*/
public boolean hasNamedPlugin(Class interfaceClass, String name);
/**
* Returns instances of all plugins that implement the interface,
* in an Array. Returns an empty array if no there are no
* matching plugins.
* <p>
* The order of the plugins in the array is the same as their class
* names in the configuration's value field.
*
* @param interfaceClass interface for which to find plugins.
* @return an array of plugin instances; if none are
* available an empty array is returned.
*/
public Object[] getPluginSequence(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 the
* <code>PluginConfigurationError</code> is thrown.
* <p>
* 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.
*
* @param interfaceClass interface Class object
* @return instance of plugin
*/
public Object getSinglePlugin(Class interfaceClass);
}

View File

@@ -19,7 +19,7 @@ import org.apache.commons.cli.PosixParser;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.curate.factory.CurateServiceFactory;
import org.dspace.eperson.EPerson;
import org.dspace.eperson.factory.EPersonServiceFactory;
@@ -232,7 +232,7 @@ public class CurationCli
else
{
// process the task queue
TaskQueue queue = (TaskQueue)PluginManager.getSinglePlugin("curate", TaskQueue.class);
TaskQueue queue = (TaskQueue) CoreServiceFactory.getInstance().getPluginService().getSinglePlugin(TaskQueue.class);
if (queue == null)
{
System.out.println("No implementation configured for queue");

View File

@@ -20,7 +20,7 @@ import org.dspace.content.service.CommunityService;
import org.dspace.content.service.ItemService;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
@@ -280,7 +280,7 @@ public class Curator
{
if (taskQ == null)
{
taskQ = (TaskQueue)PluginManager.getSinglePlugin("curate", TaskQueue.class);
taskQ = (TaskQueue) CoreServiceFactory.getInstance().getPluginService().getSinglePlugin(TaskQueue.class);
}
if (taskQ != null)
{

View File

@@ -24,12 +24,12 @@ import javax.script.ScriptException;
import org.apache.log4j.Logger;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
/**
* TaskResolver takes a logical name of a curation task and attempts to deliver
* a suitable implementation object. Supported implementation types include:
* (1) Classpath-local Java classes configured and loaded via PluginManager.
* (1) Classpath-local Java classes configured and loaded via PluginService.
* (2) Local script-based tasks, viz. coded in any scripting language whose
* runtimes are accessible via the JSR-223 scripting API. This really amounts
* to the family of dynamic JVM languages: JRuby, Jython, Groovy, Javascript, etc
@@ -195,7 +195,7 @@ public class TaskResolver
*/
public ResolvedTask resolveTask(String taskName)
{
CurationTask ctask = (CurationTask)PluginManager.getNamedPlugin("curate", CurationTask.class, taskName);
CurationTask ctask = (CurationTask)CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(CurationTask.class, taskName);
if (ctask != null)
{
return new ResolvedTask(taskName, ctask);

View File

@@ -42,8 +42,9 @@ import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.Email;
import org.dspace.core.I18nUtil;
import org.dspace.core.PluginManager;
import org.dspace.core.Utils;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
import org.dspace.harvest.factory.HarvestServiceFactory;
@@ -88,7 +89,7 @@ public class OAIHarvester {
protected HandleService handleService;
protected HarvestedItemService harvestedItemService;
protected WorkspaceItemService workspaceItemService;
protected PluginService pluginService;
// The collection this harvester instance is dealing with
Collection targetCollection;
@@ -126,6 +127,7 @@ public class OAIHarvester {
installItemService = ContentServiceFactory.getInstance().getInstallItemService();
workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
pluginService = CoreServiceFactory.getInstance().getPluginService();
if (dso.getType() != Constants.COLLECTION)
{
@@ -451,14 +453,14 @@ public class OAIHarvester {
// If we are only harvesting descriptive metadata, the record should already contain all we need
List<Element> descMD = record.getChild("metadata", OAI_NS).getChildren();
IngestionCrosswalk MDxwalk = (IngestionCrosswalk)PluginManager.getNamedPlugin(IngestionCrosswalk.class, this.metadataKey);
IngestionCrosswalk MDxwalk = (IngestionCrosswalk)pluginService.getNamedPlugin(IngestionCrosswalk.class, this.metadataKey);
// Otherwise, obtain the ORE ReM and initiate the ORE crosswalk
IngestionCrosswalk ORExwalk = null;
Element oreREM = null;
if (harvestRow.getHarvestType() > 1) {
oreREM = getMDrecord(harvestRow.getOaiSource(), itemOaiID, OREPrefix).get(0);
ORExwalk = (IngestionCrosswalk)PluginManager.getNamedPlugin(IngestionCrosswalk.class, this.ORESerialKey);
ORExwalk = (IngestionCrosswalk)pluginService.getNamedPlugin(IngestionCrosswalk.class, this.ORESerialKey);
}
// Ignore authorization

View File

@@ -12,7 +12,7 @@ import org.apache.log4j.Logger;
import org.dspace.content.DSpaceObject;
import org.dspace.content.crosswalk.DisseminationCrosswalk;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.jdom.Element;
import org.jdom.output.XMLOutputter;
@@ -93,7 +93,7 @@ public class DataCiteXMLCreator
if (null != this.xwalk)
return;
this.xwalk = (DisseminationCrosswalk) PluginManager.getNamedPlugin(
this.xwalk = (DisseminationCrosswalk) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(
DisseminationCrosswalk.class, this.CROSSWALK_NAME);
if (this.xwalk == null)

View File

@@ -33,7 +33,7 @@ import org.dspace.content.crosswalk.DisseminationCrosswalk;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.DSpaceObjectService;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
import org.dspace.identifier.DOI;
@@ -198,7 +198,7 @@ implements DOIConnector
if (null != this.xwalk)
return;
this.xwalk = (DisseminationCrosswalk) PluginManager.getNamedPlugin(
this.xwalk = (DisseminationCrosswalk) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(
DisseminationCrosswalk.class, this.CROSSWALK_NAME);
if (this.xwalk == null)

View File

@@ -7,7 +7,7 @@
*/
package org.dspace.sort;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
/**
* Class implementing static helpers for anywhere that interacts with the sort columns
@@ -43,7 +43,7 @@ public class OrderFormat
public static final String AUTHORITY = "authority";
// Array of all available order delegates - avoids excessive calls to plugin manager
private static final String[] delegates = PluginManager.getAllPluginNames(OrderFormatDelegate.class);
private static final String[] delegates = CoreServiceFactory.getInstance().getPluginService().getAllPluginNames(OrderFormatDelegate.class);
private static final OrderFormatDelegate authorDelegate = new OrderFormatAuthor();
private static final OrderFormatDelegate titleDelegate = new OrderFormatTitle();
@@ -116,7 +116,7 @@ public class OrderFormat
{
if (delegates[idx].equals(name))
{
return (OrderFormatDelegate)PluginManager.getNamedPlugin(OrderFormatDelegate.class, name);
return (OrderFormatDelegate)CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(OrderFormatDelegate.class, name);
}
}
}

View File

@@ -1,9 +1,28 @@
# Configure authority control for Unit Testing
# Configure authority control for Unit Testing (in DSpaceControlledVocabularyTest)
# (This overrides default, commented out settings in dspace.cfg)
plugin.selfnamed.org.dspace.content.authority.ChoiceAuthority = \
org.dspace.content.authority.DCInputAuthority, \
org.dspace.content.authority.DSpaceControlledVocabulary
# Configure some more Plugins for PluginTest class
# NOTE: Plugins are just *interfaces*. So, here we are defining some plugins
# based on java.util.List interface and giving them names.
# (These are used by PluginTest)
plugin.named.java.util.List = \
java.util.ArrayList = MyArrayList, \
java.util.LinkedList = MyLinkedList, \
java.util.AttributeList = MyAttributeList
# Define a single Map plugin (used by PluginTest)
plugin.single.java.util.Map = java.util.HashMap
# Define a sequence of Collection plugins (used by PluginTest)
plugin.sequence.java.util.Collection = \
java.util.ArrayList, \
java.util.LinkedList, \
java.util.Stack, \
java.util.TreeSet
# Enable a test authority control on dc.language.iso field
choices.plugin.dc.language.iso = common_iso_languages
choices.presentation.dc.language.iso = select

View File

@@ -11,7 +11,7 @@ import java.io.IOException;
import org.dspace.content.Collection;
import org.dspace.AbstractUnitTest;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.*;
@@ -86,7 +86,7 @@ public class DSpaceControlledVocabularyTest extends AbstractUnitTest
// (under /src/test/data/dspaceFolder/) and it should be auto-loaded
// by test configs in /src/test/data/dspace.cfg.more
DSpaceControlledVocabulary instance = (DSpaceControlledVocabulary)
PluginManager.getNamedPlugin(Class.forName(PLUGIN_INTERFACE), "farm");
CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(Class.forName(PLUGIN_INTERFACE), "farm");
assertNotNull(instance);
Choices result = instance.getMatches(field, text, collection, start,
limit, locale);

View File

@@ -24,6 +24,8 @@ import org.dspace.content.crosswalk.CrosswalkException;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.*;
import org.dspace.core.*;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
@@ -61,6 +63,7 @@ public class ITDSpaceAIP extends AbstractUnitTest
protected WorkspaceItemService workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
protected InstallItemService installItemService = ContentServiceFactory.getInstance().getInstallItemService();
protected HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
protected PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
/** InfoMap multiple value separator (see saveObjectInfo() and assertObject* methods) **/
private static final String valueseparator = "::";
@@ -794,7 +797,7 @@ public class ITDSpaceAIP extends AbstractUnitTest
throws PackageException, CrosswalkException, AuthorizeException, SQLException, IOException
{
// Get a reference to the configured "AIP" package disseminator
PackageDisseminator dip = (PackageDisseminator) PluginManager
PackageDisseminator dip = (PackageDisseminator) pluginService
.getNamedPlugin(PackageDisseminator.class, "AIP");
if (dip == null)
{
@@ -832,7 +835,7 @@ public class ITDSpaceAIP extends AbstractUnitTest
private void restoreFromAIP(DSpaceObject parent, File aipFile, PackageParameters pkgParams, boolean recursive)
throws PackageException, CrosswalkException, AuthorizeException, SQLException, IOException, WorkflowException {
// Get a reference to the configured "AIP" package ingestor
PackageIngester sip = (PackageIngester) PluginManager
PackageIngester sip = (PackageIngester) pluginService
.getNamedPlugin(PackageIngester.class, "AIP");
if(sip == null)
{
@@ -869,7 +872,7 @@ public class ITDSpaceAIP extends AbstractUnitTest
private void replaceFromAIP(DSpaceObject dso, File aipFile, PackageParameters pkgParams, boolean recursive)
throws PackageException, CrosswalkException, AuthorizeException, SQLException, IOException, WorkflowException {
// Get a reference to the configured "AIP" package ingestor
PackageIngester sip = (PackageIngester) PluginManager
PackageIngester sip = (PackageIngester) pluginService
.getNamedPlugin(PackageIngester.class, "AIP");
if (sip == null)
{

View File

@@ -0,0 +1,123 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.core;
import org.dspace.AbstractUnitTest;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Tests for Plugin Service.
* <P>
* NOTE: Plugin definitions/configurations which are used for this test are
* defined in /data/dspaceFolder/dspace.cfg.more (and are added into the
* final test dspace.cfg file)
*
* @author Tim Donohue
*/
public class PluginServiceTest extends AbstractUnitTest
{
// Get our enabled pluginService
private PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
/**
* Test of getAllPluginNames() method
*/
@Test
public void testGetAllPluginNames()
{
// Get all plugins defined from List interface (see dspace.cfg.more)
String[] names = pluginService.getAllPluginNames(java.util.List.class);
// There should be exactly 3 List plugins
assertEquals("Plugin count", 3, names.length);
}
/**
* Test of getNamedPlugin() method
*/
@Test
public void testGetNamedPlugin()
{
// Get the plugin named "MyArrayList"
Object plugin = pluginService.getNamedPlugin(java.util.List.class, "MyArrayList");
assertNotNull("Plugin exists", plugin);
assertTrue("Plugin is List", plugin instanceof java.util.List);
assertTrue("Plugin is ArrayList", plugin instanceof java.util.ArrayList);
// Get a plugin that doesn't exist
plugin = pluginService.getNamedPlugin(java.util.List.class, "MyOtherList");
assertNull("Plugin 2 doesn't exist", plugin);
// Test for one plugin that is "selfnamed"
// The DCInputAuthority plugin enabled in dspace.cfg.more reads all <form-value-pairs> in input-forms.xml
// and defines a self named plugin for each. So, we SHOULD have a "common_types" plugin.
plugin = pluginService.getNamedPlugin(org.dspace.content.authority.ChoiceAuthority.class, "common_types");
assertNotNull("Plugin 3 exists", plugin);
assertTrue("Plugin 3 is ChoiceAuthority", plugin instanceof org.dspace.content.authority.ChoiceAuthority);
assertTrue("Plugin 3 is DCInputAuthority", plugin instanceof org.dspace.content.authority.DCInputAuthority);
// NOTE: Additional "selfnamed" plugins are tested in DSpaceControlledVocabularyTest
}
/**
* Test of hasNamedPlugin() method
*/
@Test
public void testHasNamedPlugin()
{
// Assert there is a plugin named "MyLinkedList"
assertTrue(pluginService.hasNamedPlugin(java.util.List.class, "MyLinkedList"));
// Assert there is NOT a plugin named "MyList"
assertFalse(pluginService.hasNamedPlugin(java.util.List.class, "MyList"));
// Assert existence of a self named plugin
assertTrue(pluginService.hasNamedPlugin(org.dspace.content.authority.ChoiceAuthority.class, "common_types"));
}
/**
* Test of getSinglePlugin() method
*/
@Test
public void testGetSinglePlugin()
{
// There should be a SINGLE Map plugin (unnamed)
Object plugin = pluginService.getSinglePlugin(java.util.Map.class);
assertNotNull("Plugin exists", plugin);
assertTrue("Plugin is Map", plugin instanceof java.util.Map);
assertTrue("Plugin is HashMap", plugin instanceof java.util.HashMap);
}
/**
* Test of getSinglePlugin() method
*/
@Test
public void testGetPluginSequence()
{
// There should be a sequence of Collection plugins
Object[] plugins = pluginService.getPluginSequence(java.util.Collection.class);
// There should be four of them
assertEquals("Plugin count", 4, plugins.length);
// They should be in an EXACT ORDER (as defined in dspace.cfg.more)
assertTrue("Plugin 0 is ArrayList", plugins[0] instanceof java.util.ArrayList);
assertTrue("Plugin 1 is LinkedList", plugins[1] instanceof java.util.LinkedList);
assertTrue("Plugin 2 is Stack", plugins[2] instanceof java.util.Stack);
assertTrue("Plugin 3 is TreeSet", plugins[3] instanceof java.util.TreeSet);
}
}

View File

@@ -52,8 +52,8 @@ import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.I18nUtil;
import org.dspace.core.PluginManager;
import org.dspace.core.Utils;
import org.dspace.core.factory.CoreServiceFactory;
/**
* <P>
@@ -212,7 +212,7 @@ public class ItemTag extends TagSupport
private static final Logger log = Logger.getLogger(ItemTag.class);
private final transient StyleSelection styleSelection
= (StyleSelection) PluginManager.getSinglePlugin(StyleSelection.class);
= (StyleSelection) CoreServiceFactory.getInstance().getPluginService().getSinglePlugin(StyleSelection.class);
/** Hashmap of linked metadata to browse, from dspace.cfg */
private static final Map<String,String> linkedMetadata;

View File

@@ -21,7 +21,7 @@ import org.dspace.app.webui.search.SearchRequestProcessor;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context;
import org.dspace.core.PluginConfigurationError;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
/**
* Servlet for constructing/processing an advanced search form
@@ -38,7 +38,7 @@ public class AdvancedSearchServlet extends DSpaceServlet
{
try
{
internalLogic = (SearchRequestProcessor) PluginManager
internalLogic = (SearchRequestProcessor) CoreServiceFactory.getInstance().getPluginService()
.getSinglePlugin(SearchRequestProcessor.class);
}
catch (PluginConfigurationError e)

View File

@@ -41,7 +41,8 @@ import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import org.dspace.eperson.EPerson;
import org.dspace.eperson.Group;
import org.dspace.eperson.factory.EPersonServiceFactory;
@@ -77,11 +78,6 @@ public class HandleServlet extends DSpaceServlet
/** log4j category */
private static final Logger log = Logger.getLogger(HandleServlet.class);
/** For obtaining &lt;meta&gt; elements to put in the &lt;head&gt; */
private final transient DisseminationCrosswalk xHTMLHeadCrosswalk
= (DisseminationCrosswalk) PluginManager
.getNamedPlugin(DisseminationCrosswalk.class, "XHTML_HEAD_ITEM");
// services API
private final transient HandleService handleService
= HandleServiceFactory.getInstance().getHandleService();
@@ -98,6 +94,14 @@ public class HandleServlet extends DSpaceServlet
private final transient CollectionService collectionService
= ContentServiceFactory.getInstance().getCollectionService();
private final transient PluginService pluginService
= CoreServiceFactory.getInstance().getPluginService();
/** For obtaining &lt;meta&gt; elements to put in the &lt;head&gt; */
private final transient DisseminationCrosswalk xHTMLHeadCrosswalk
= (DisseminationCrosswalk) pluginService
.getNamedPlugin(DisseminationCrosswalk.class, "XHTML_HEAD_ITEM");
@Override
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
@@ -486,7 +490,7 @@ public class HandleServlet extends DSpaceServlet
{
try
{
ItemHomeProcessor[] chp = (ItemHomeProcessor[]) PluginManager.getPluginSequence(ItemHomeProcessor.class);
ItemHomeProcessor[] chp = (ItemHomeProcessor[]) pluginService.getPluginSequence(ItemHomeProcessor.class);
for (int i = 0; i < chp.length; i++)
{
chp[i].process(context, request, response, item);
@@ -576,7 +580,7 @@ public class HandleServlet extends DSpaceServlet
{
try
{
CommunityHomeProcessor[] chp = (CommunityHomeProcessor[]) PluginManager.getPluginSequence(CommunityHomeProcessor.class);
CommunityHomeProcessor[] chp = (CommunityHomeProcessor[]) pluginService.getPluginSequence(CommunityHomeProcessor.class);
for (int i = 0; i < chp.length; i++)
{
chp[i].process(context, request, response, community);
@@ -723,7 +727,7 @@ public class HandleServlet extends DSpaceServlet
{
try
{
CollectionHomeProcessor[] chp = (CollectionHomeProcessor[]) PluginManager.getPluginSequence(CollectionHomeProcessor.class);
CollectionHomeProcessor[] chp = (CollectionHomeProcessor[]) pluginService.getPluginSequence(CollectionHomeProcessor.class);
for (int i = 0; i < chp.length; i++)
{
chp[i].process(context, request, response, collection);

View File

@@ -19,7 +19,7 @@ import org.dspace.app.webui.json.JSONRequest;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
public class JSONServlet extends DSpaceServlet
{
@@ -50,7 +50,7 @@ public class JSONServlet extends DSpaceServlet
pluginName = pluginName.substring(1);
pluginName = pluginName.split("/")[0];
}
JSONRequest jsonReq = (JSONRequest) PluginManager.getNamedPlugin(JSONRequest.class,
JSONRequest jsonReq = (JSONRequest) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(JSONRequest.class,
pluginName);
if (jsonReq == null)

View File

@@ -21,7 +21,7 @@ import org.dspace.app.webui.search.SearchRequestProcessor;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context;
import org.dspace.core.PluginConfigurationError;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
/**
* Servlet for producing OpenSearch-compliant search results, and the OpenSearch
@@ -49,7 +49,7 @@ public class OpenSearchServlet extends DSpaceServlet
try
{
internalLogic = (SearchRequestProcessor) PluginManager
internalLogic = (SearchRequestProcessor) CoreServiceFactory.getInstance().getPluginService()
.getSinglePlugin(SearchRequestProcessor.class);
}
catch (PluginConfigurationError e)

View File

@@ -21,7 +21,7 @@ import org.dspace.app.webui.search.SearchRequestProcessor;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context;
import org.dspace.core.PluginConfigurationError;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
/**
* Servlet for handling a simple search.
@@ -38,7 +38,7 @@ public class SimpleSearchServlet extends DSpaceServlet
{
try
{
internalLogic = (SearchRequestProcessor) PluginManager
internalLogic = (SearchRequestProcessor) CoreServiceFactory.getInstance().getPluginService()
.getSinglePlugin(SearchRequestProcessor.class);
}
catch (PluginConfigurationError e)

View File

@@ -37,7 +37,7 @@ import org.dspace.content.service.ItemService;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.PluginConfigurationError;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
/**
* Servlet for editing and deleting (expunging) items
@@ -61,7 +61,7 @@ public class ItemMapServlet extends DSpaceServlet
{
try
{
internalLogic = (SearchRequestProcessor) PluginManager
internalLogic = (SearchRequestProcessor) CoreServiceFactory.getInstance().getPluginService()
.getSinglePlugin(SearchRequestProcessor.class);
}
catch (PluginConfigurationError e)

View File

@@ -8,10 +8,11 @@
package org.dspace.sword;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Collection;
import org.dspace.content.Item;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import org.purl.sword.base.Deposit;
import org.purl.sword.base.SWORDErrorException;
@@ -44,11 +45,12 @@ public class SWORDIngesterFactory
DSpaceObject dso)
throws DSpaceSWORDException, SWORDErrorException
{
PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
if (dso instanceof Collection)
{
SWORDIngester ingester = (SWORDIngester) PluginManager
.getNamedPlugin("sword-server", SWORDIngester.class,
deposit.getPackaging());
SWORDIngester ingester = (SWORDIngester) pluginService
.getNamedPlugin(SWORDIngester.class, deposit.getPackaging());
if (ingester == null)
{
throw new SWORDErrorException(ErrorCodes.ERROR_CONTENT,
@@ -58,9 +60,8 @@ public class SWORDIngesterFactory
}
else if (dso instanceof Item)
{
SWORDIngester ingester = (SWORDIngester) PluginManager
.getNamedPlugin("sword-server", SWORDIngester.class,
"SimpleFileIngester");
SWORDIngester ingester = (SWORDIngester) pluginService
.getNamedPlugin(SWORDIngester.class, "SimpleFileIngester");
if (ingester == null)
{
throw new DSpaceSWORDException(

View File

@@ -21,7 +21,7 @@ import org.dspace.content.packager.PackageParameters;
import org.dspace.content.service.ItemService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
@@ -73,7 +73,7 @@ public class SWORDMETSIngester implements SWORDIngester
}
swordService.message("Using package manifest format: " + cfg);
PackageIngester pi = (PackageIngester) PluginManager
PackageIngester pi = (PackageIngester) CoreServiceFactory.getInstance().getPluginService()
.getNamedPlugin(PackageIngester.class, cfg);
swordService.message(
"Loaded package ingester: " + pi.getClass().getName());

View File

@@ -16,7 +16,7 @@ import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.BitstreamFormatService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.LegacyPluginServiceImpl;
import org.jaxen.function.FalseFunction;
import org.swordapp.server.SwordConfiguration;
import org.swordapp.server.SwordError;

View File

@@ -7,13 +7,13 @@
*/
package org.dspace.sword2;
import org.dspace.core.PluginManager;
import org.swordapp.server.SwordError;
import org.swordapp.server.SwordServerException;
import org.swordapp.server.UriRegistry;
import java.util.List;
import java.util.Map;
import org.dspace.core.factory.CoreServiceFactory;
public class SwordDisseminatorFactory
{
@@ -36,9 +36,8 @@ public class SwordDisseminatorFactory
"_"); // clean up the string for the plugin manager
format = format.replace("=",
"_"); // clean up the string for the plugin manager
disseminator = (SwordContentDisseminator) PluginManager
.getNamedPlugin("swordv2-server",
SwordContentDisseminator.class, format);
disseminator = (SwordContentDisseminator) CoreServiceFactory.getInstance().getPluginService()
.getNamedPlugin(SwordContentDisseminator.class, format);
if (disseminator == null)
{
continue;
@@ -72,9 +71,8 @@ public class SwordDisseminatorFactory
"_"); // clean up the string for the plugin manager
acceptPackaging = acceptPackaging.replace("=",
"_"); // clean up the string for the plugin manager
disseminator = (SwordContentDisseminator) PluginManager
.getNamedPlugin("swordv2-server",
SwordContentDisseminator.class,
disseminator = (SwordContentDisseminator) CoreServiceFactory.getInstance().getPluginService()
.getNamedPlugin(SwordContentDisseminator.class,
acceptPackaging);
if (disseminator != null)
{
@@ -132,9 +130,8 @@ public class SwordDisseminatorFactory
"_"); // clean up the string for the plugin manager
format = format.replace("=",
"_"); // clean up the string for the plugin manager
disseminator = (SwordStatementDisseminator) PluginManager
.getNamedPlugin("swordv2-server",
SwordStatementDisseminator.class, format);
disseminator = (SwordStatementDisseminator) CoreServiceFactory.getInstance().getPluginService()
.getNamedPlugin(SwordStatementDisseminator.class, format);
if (disseminator != null)
{
break;
@@ -155,9 +152,8 @@ public class SwordDisseminatorFactory
public static SwordEntryDisseminator getEntryInstance()
throws DSpaceSwordException, SwordError
{
SwordEntryDisseminator disseminator = (SwordEntryDisseminator) PluginManager
.getSinglePlugin("swordv2-server",
SwordEntryDisseminator.class);
SwordEntryDisseminator disseminator = (SwordEntryDisseminator) CoreServiceFactory.getInstance().getPluginService()
.getSinglePlugin(SwordEntryDisseminator.class);
if (disseminator == null)
{
throw new SwordError(DSpaceUriRegistry.REPOSITORY_ERROR,

View File

@@ -8,9 +8,9 @@
package org.dspace.sword2;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Collection;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import org.swordapp.server.Deposit;
import org.swordapp.server.SwordError;
import org.swordapp.server.UriRegistry;
@@ -44,10 +44,11 @@ public class SwordIngesterFactory
{
SwordContentIngester ingester = null;
PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
// first look to see if there's an intester for the content type
ingester = (SwordContentIngester) PluginManager
.getNamedPlugin("swordv2-server", SwordContentIngester.class,
deposit.getMimeType());
ingester = (SwordContentIngester) pluginService
.getNamedPlugin(SwordContentIngester.class, deposit.getMimeType());
if (ingester != null)
{
return ingester;
@@ -55,9 +56,8 @@ public class SwordIngesterFactory
// if no ingester, then
// look to see if there's an ingester for the package format
ingester = (SwordContentIngester) PluginManager
.getNamedPlugin("swordv2-server", SwordContentIngester.class,
deposit.getPackaging());
ingester = (SwordContentIngester) pluginService
.getNamedPlugin(SwordContentIngester.class, deposit.getPackaging());
if (ingester == null)
{
throw new SwordError(UriRegistry.ERROR_CONTENT,
@@ -70,8 +70,8 @@ public class SwordIngesterFactory
Deposit deposit, DSpaceObject dso)
throws DSpaceSwordException, SwordError
{
SwordEntryIngester ingester = (SwordEntryIngester) PluginManager
.getSinglePlugin("swordv2-server", SwordEntryIngester.class);
SwordEntryIngester ingester = (SwordEntryIngester) CoreServiceFactory.getInstance().getPluginService()
.getSinglePlugin(SwordEntryIngester.class);
if (ingester == null)
{
throw new SwordError(UriRegistry.ERROR_CONTENT,

View File

@@ -23,7 +23,7 @@ import org.dspace.content.service.CollectionService;
import org.dspace.content.service.WorkspaceItemService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
@@ -104,7 +104,7 @@ public class SwordMETSContentIngester extends AbstractSwordContentIngester
}
verboseDescription.append("Using package manifest format: " + cfg);
PackageIngester pi = (PackageIngester) PluginManager
PackageIngester pi = (PackageIngester) CoreServiceFactory.getInstance().getPluginService()
.getNamedPlugin(PackageIngester.class, cfg);
verboseDescription.append("Loaded package ingester: " +
pi.getClass().getName());
@@ -236,7 +236,7 @@ public class SwordMETSContentIngester extends AbstractSwordContentIngester
}
verboseDescription.append("Using package manifest format: " + cfg);
PackageIngester pi = (PackageIngester) PluginManager
PackageIngester pi = (PackageIngester) CoreServiceFactory.getInstance().getPluginService()
.getNamedPlugin(PackageIngester.class, cfg);
verboseDescription.append("Loaded package ingester: " +
pi.getClass().getName());

View File

@@ -7,7 +7,7 @@
*/
package org.dspace.sword2;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.swordapp.server.SwordError;
public class WorkflowManagerFactory
@@ -15,8 +15,8 @@ public class WorkflowManagerFactory
public static WorkflowManager getInstance()
throws DSpaceSwordException, SwordError
{
WorkflowManager manager = (WorkflowManager) PluginManager
.getSinglePlugin("swordv2-server", WorkflowManager.class);
WorkflowManager manager = (WorkflowManager) CoreServiceFactory.getInstance().getPluginService()
.getSinglePlugin(WorkflowManager.class);
if (manager == null)
{
throw new SwordError(DSpaceUriRegistry.REPOSITORY_ERROR,

View File

@@ -28,7 +28,7 @@ import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.CollectionService;
import org.dspace.content.service.ItemService;
import org.dspace.core.PluginConfigurationError;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
@@ -179,7 +179,7 @@ public class SearchItemForm extends AbstractDSpaceTransformer {
// Which search provider do we use?
SearchRequestProcessor processor = null;
try {
processor = (SearchRequestProcessor) PluginManager
processor = (SearchRequestProcessor) CoreServiceFactory.getInstance().getPluginService()
.getSinglePlugin(SearchRequestProcessor.class);
} catch (PluginConfigurationError e) {
log.warn("{} not properly configured. Please configure the {} plugin. {}",

View File

@@ -25,7 +25,6 @@ import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.http.HttpEnvironment;
import org.apache.cocoon.util.HashUtil;
import org.apache.excalibur.source.SourceValidity;
import org.dspace.app.sfx.SFXFileReaderServiceImpl;
import org.dspace.app.sfx.factory.SfxServiceFactory;
import org.dspace.app.sfx.service.SFXFileReaderService;
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
@@ -48,13 +47,13 @@ import org.dspace.app.util.GoogleMetadata;
import org.dspace.content.crosswalk.CrosswalkException;
import org.dspace.content.crosswalk.DisseminationCrosswalk;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.core.PluginManager;
import org.jdom.Element;
import org.jdom.Text;
import org.jdom.output.XMLOutputter;
import org.xml.sax.SAXException;
import org.dspace.core.ConfigurationManager;
import org.dspace.app.xmlui.wing.element.Metadata;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.utils.DSpace;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -291,7 +290,7 @@ public class ItemViewer extends AbstractDSpaceTransformer implements CacheablePr
// Metadata for <head> element
if (xHTMLHeadCrosswalk == null)
{
xHTMLHeadCrosswalk = (DisseminationCrosswalk) PluginManager.getNamedPlugin(
xHTMLHeadCrosswalk = (DisseminationCrosswalk) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(
DisseminationCrosswalk.class, "XHTML_HEAD_ITEM");
}

View File

@@ -23,8 +23,7 @@ import org.dspace.content.crosswalk.DisseminationCrosswalk;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.ItemService;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.handle.HandleServiceImpl;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
import org.jdom.Element;
@@ -63,7 +62,7 @@ public class DSpaceOREGenerator extends AbstractGenerator
// Instantiate and execute the ORE plugin
SAXOutputter out = new SAXOutputter(contentHandler);
DisseminationCrosswalk xwalk = (DisseminationCrosswalk)PluginManager.getNamedPlugin(DisseminationCrosswalk.class,"ore");
DisseminationCrosswalk xwalk = (DisseminationCrosswalk)CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(DisseminationCrosswalk.class,"ore");
Element ore = xwalk.disseminateElement(context, item);
out.output(ore);

View File

@@ -25,7 +25,7 @@ import org.dspace.content.Item;
import org.dspace.content.crosswalk.CrosswalkException;
import org.dspace.content.crosswalk.DisseminationCrosswalk;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.core.factory.CoreServiceFactory;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler;
@@ -562,7 +562,7 @@ public abstract class AbstractAdapter
public final DisseminationCrosswalk getDisseminationCrosswalk(String crosswalkName) throws WingException
{
// FIXME add some caching here
DisseminationCrosswalk crosswalk = (DisseminationCrosswalk) PluginManager.getNamedPlugin(DisseminationCrosswalk.class, crosswalkName);
DisseminationCrosswalk crosswalk = (DisseminationCrosswalk) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(DisseminationCrosswalk.class, crosswalkName);
if (crosswalk == null)
{

View File

@@ -13,8 +13,6 @@ import org.dspace.content.DSpaceObject;
import org.dspace.content.packager.PackageDisseminator;
import org.dspace.content.packager.PackageParameters;
import org.dspace.core.Context;
import org.dspace.core.PluginManager;
import org.dspace.handle.HandleServiceImpl;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
import org.dspace.sword.client.exceptions.HttpException;
@@ -34,6 +32,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.sql.SQLException;
import java.util.UUID;
import org.dspace.core.factory.CoreServiceFactory;
/**
* User: Robin Taylor
@@ -168,7 +167,7 @@ public class DSpaceSwordClient
{
// Note - in the future we may need to allow for more than zipped up packages.
PackageDisseminator dip = (PackageDisseminator) PluginManager
PackageDisseminator dip = (PackageDisseminator) CoreServiceFactory.getInstance().getPluginService()
.getNamedPlugin(PackageDisseminator.class, packageFormat);
if (dip == null)