Plugin option for dspace services in spring

git-svn-id: http://scm.dspace.org/svn/repo/modules/dspace-services/trunk@5547 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Ben Bosman
2010-10-22 13:45:41 +00:00
parent 8b21e49228
commit bb508a30c9

View File

@@ -29,7 +29,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* This is the Spring implementation of the service manager. * This is the Spring implementation of the service manager.
* *
* @author Aaron Zeckoski (azeckoski @ gmail.com) * @author Aaron Zeckoski (azeckoski @ gmail.com)
*/ */
public class SpringServiceManager implements ServiceManagerSystem { public class SpringServiceManager implements ServiceManagerSystem {
@@ -37,7 +37,7 @@ public class SpringServiceManager implements ServiceManagerSystem {
private static Logger log = LoggerFactory.getLogger(SpringServiceManager.class); private static Logger log = LoggerFactory.getLogger(SpringServiceManager.class);
private ClassPathXmlApplicationContext applicationContext; private ClassPathXmlApplicationContext applicationContext;
/** /**
* @return the parent core Spring {@link ApplicationContext} * @return the parent core Spring {@link ApplicationContext}
*/ */
@@ -82,10 +82,11 @@ public class SpringServiceManager implements ServiceManagerSystem {
public static final String configPath = "spring/spring-dspace-applicationContext.xml"; public static final String configPath = "spring/spring-dspace-applicationContext.xml";
public static final String corePath = "classpath*:spring/spring-dspace-core-services.xml"; public static final String corePath = "classpath*:spring/spring-dspace-core-services.xml";
public static final String pluginPath = "classpath*:spring/spring-dspace-plugin-*-services.xml";
/** /**
* Spring does not actually allow us to add in new singletons which * Spring does not actually allow us to add in new singletons which
* have bean definitions so we have to track the added singleton * have bean definitions so we have to track the added singleton
* names ourselves manually. * names ourselves manually.
*/ */
private Vector<String> singletonNames = new Vector<String>(); private Vector<String> singletonNames = new Vector<String>();
@@ -94,7 +95,7 @@ public class SpringServiceManager implements ServiceManagerSystem {
public <T> T getServiceByName(String name, Class<T> type) { public <T> T getServiceByName(String name, Class<T> type) {
T bean = null; T bean = null;
// handle special case to return the core AC // handle special case to return the core AC
if (ApplicationContext.class.getName().equals(name) if (ApplicationContext.class.getName().equals(name)
&& ApplicationContext.class.isAssignableFrom(type)) { && ApplicationContext.class.isAssignableFrom(type)) {
bean = (T) getApplicationContext(); bean = (T) getApplicationContext();
} else { } else {
@@ -116,7 +117,7 @@ public class SpringServiceManager implements ServiceManagerSystem {
} }
} }
// if still no luck then try by type only // if still no luck then try by type only
if (name == null if (name == null
&& bean == null) { && bean == null) {
try { try {
Map<String, Object> map = applicationContext.getBeansOfType(type); Map<String, Object> map = applicationContext.getBeansOfType(type);
@@ -170,6 +171,7 @@ public class SpringServiceManager implements ServiceManagerSystem {
// get all spring config paths // get all spring config paths
ArrayList<String> pathList = new ArrayList<String>(); ArrayList<String> pathList = new ArrayList<String>();
pathList.add(configPath); pathList.add(configPath);
pathList.add(pluginPath);
if (testMode) { if (testMode) {
log.warn("TEST Spring Service Manager running in test mode, no core beans will be started"); log.warn("TEST Spring Service Manager running in test mode, no core beans will be started");
} else { } else {
@@ -229,7 +231,7 @@ public class SpringServiceManager implements ServiceManagerSystem {
} }
/** /**
* This handles the common part of the 2 types of service * This handles the common part of the 2 types of service
* registrations. * registrations.
* *
* @param name * @param name