SpringServiceManager implements ServiceManagerSystem { @Override public void startup() { long startTime = System.currentTimeMillis(); ArrayList<String> pathList = new ArrayList<String>(); pathList.add(configPath); pathList.add(addonResourcePath); if (testMode) { log.warn("TEST Spring Service Manager running in test mode, no core beans will be started"); } else { pathList.add(coreResourcePath); } if (configPaths != null) { pathList.addAll(Arrays.asList(configPaths)); } if(testMode){ log.warn("TEST Spring Service Manager running in test mode, no dspace home spring files will be loaded"); } else { String[] springLoaderClassNames = configurationService.getArrayProperty("spring.springloader.modules"); if(springLoaderClassNames != null){ for(String springLoaderClassName : springLoaderClassNames){ try { Class<SpringLoader> springLoaderClass = (Class<SpringLoader>) Class.forName(springLoaderClassName.trim()); String[] resourcePaths = springLoaderClass.getConstructor().newInstance().getResourcePaths(configurationService); if(resourcePaths != null){ pathList.addAll(Arrays.asList(resourcePaths)); } } catch (ClassNotFoundException e) { } catch (Exception e) { log.error("Error while retrieving spring resource paths for module: " + springLoaderClassName, e); } } } } String[] allPaths = pathList.toArray(new String[pathList.size()]); applicationContext = new ClassPathXmlApplicationContext(allPaths, false); applicationContext.setAllowBeanDefinitionOverriding(true); applicationContext.setAllowCircularReferences(true); applicationContext.addBeanFactoryPostProcessor( new DSpaceBeanFactoryPostProcessor(parent, configurationService, testMode) ); applicationContext.refresh(); if (developmentMode) { log.warn("Spring Service Manager is running in developmentMode, services will be loaded on demand only"); } else { applicationContext.getBeanFactory().preInstantiateSingletons(); applicationContext.getBeanFactory().freezeConfiguration(); } long totalTime = System.currentTimeMillis() - startTime; log.info("Spring Service Manager started up in "+totalTime+" ms with "+applicationContext.getBeanDefinitionCount()+" services..."); } SpringServiceManager(ServiceManagerSystem parent, DSpaceConfigurationService configurationService, boolean testMode, boolean developmentMode, String... configPaths); ClassPathXmlApplicationContext getApplicationContext(); ListableBeanFactory getBeanFactory(); @SuppressWarnings("unchecked") @Override T getServiceByName(String name, Class<T> type); @SuppressWarnings("unchecked") @Override List<T> getServicesByType(Class<T> type); @Override void shutdown(); @Override void startup(); @SuppressWarnings("unchecked") @Override T registerServiceClass(String name, Class<T> type); @Override void registerService(String name, Object service); @Override void registerServiceNoAutowire(String name, Object service); @Override void unregisterService(String name); @Override List<String> getServicesNames(); @Override boolean isServiceExists(String name); @Override Map<String, Object> getServices(); @Override void pushConfig(Map<String, Object> settings); static final String configPath; static final String coreResourcePath; static final String addonResourcePath; }
@Test public void testStartup() { configurationService.clear(); ssm.startup(); }
@Test public void testStartupWithConfig() { ssm.startup(); }