DSpaceServiceManager implements ServiceManagerSystem { public <T> T registerServiceClass(String name, Class<T> type) { checkRunning(); if (name == null || type == null) { throw new IllegalArgumentException("name and type cannot be null"); } return primaryServiceManager.registerServiceClass(name, type); } DSpaceServiceManager(DSpaceConfigurationService configurationService); protected  DSpaceServiceManager(DSpaceConfigurationService configurationService, String... springXmlConfigFiles); boolean isRunning(); void notifyServiceManagerReady(); @Override void shutdown(); @Override void startup(); void registerService(String name, Object service); @Override void registerServiceNoAutowire(String name, Object service); T registerServiceClass(String name, Class<T> type); void unregisterService(String name); T getServiceByName(String name, Class<T> type); List<T> getServicesByType(Class<T> type); List<String> getServicesNames(); boolean isServiceExists(String name); Map<String, Object> getServices(); void pushConfig(Map<String, Object> properties); static void configureService(String serviceName, Object service, ConfigurationService config); static void initService(Object service); static void shutdownService(Object service);  }
@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()); } }