DSpaceServiceManager implements ServiceManagerSystem { @SuppressWarnings("unchecked") @Override public <T> T registerServiceClass(String name, Class<T> type) { checkRunning(); if (name == null) { throw new IllegalArgumentException("name cannot be null"); } if (type == null) { throw new IllegalArgumentException("type cannot be null"); } T service; try { service = (T) applicationContext.getBeanFactory() .autowire(type, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true); registerBean(name, service); } catch (BeansException e) { throw new IllegalArgumentException("Invalid service class (" + type + ") with name (" + name + ") registration: " + e.getMessage(), e); } return service; } DSpaceServiceManager(DSpaceConfigurationService configurationService); protected  DSpaceServiceManager(DSpaceConfigurationService configurationService,
            String... springXmlConfigFiles); boolean isRunning(); ListableBeanFactory getBeanFactory(); @Override ClassPathXmlApplicationContext getApplicationContext(); void notifyServiceManagerReady(); @Override void shutdown(); @Override void startup(); @Override void registerService(String name, Object service); @Override void registerServiceNoAutowire(String name, Object service); @SuppressWarnings("unchecked") @Override T registerServiceClass(String name, Class<T> type); @Override void unregisterService(String name); @SuppressWarnings("unchecked") @Override T getServiceByName(String name, Class<T> type); @SuppressWarnings("unchecked") @Override List<T> getServicesByType(Class<T> type); @Override List<String> getServicesNames(); @Override boolean isServiceExists(String name); @Override Map<String, Object> getServices(); @Override void pushConfig(Map<String, Object> properties); static String[] getSpringPaths(boolean testMode, String[] configPaths,
                                          DSpaceConfigurationService configurationService); static final String CONFIG_PATH; static final String CORE_RESOURCE_PATH; static final String ADDON_RESOURCE_PATH; }
@Test public void testRegisterServiceClass() { dsm.startup(); SampleAnnotationBean sab = dsm.registerServiceClass("newAnnote", SampleAnnotationBean.class); assertNotNull(sab); SampleAnnotationBean sampleAnnotationBean = dsm.getServiceByName("newAnnote", SampleAnnotationBean.class); assertNotNull(sampleAnnotationBean); assertEquals(sampleAnnotationBean, sab); sampleAnnotationBean = null; sab = null; try { dsm.registerService("fakey", (Class<?>) null); fail("should have thrown exception"); } catch (IllegalArgumentException e) { assertNotNull(e.getMessage()); } }