@Test public void testRegisterAllServices(){ DummyClass2 service = new DummyClass2(); Properties props = mock (Properties.class); Map<Class, Map<Object, ServiceRegistration>> sr = new HashMap<Class, Map<Object,ServiceRegistration>>(); ServiceRegistration s = mock(ServiceRegistration.class); ServiceRegistration s2 = mock(ServiceRegistration.class); when(bc.registerService(eq(DummyInterface2.class.getName()), same(service), any(Dictionary.class))).thenReturn(s2); when(bc.registerService(eq(DummyInterface.class.getName()), same(service), any(Dictionary.class))).thenReturn(s); ServiceUtil.registerAllServices(bc, service, props, sr); assertEquals(2,sr.size()); assertTrue(sr.get(DummyInterface2.class).get(service).equals(s2)); assertTrue(sr.get(DummyInterface.class).get(service).equals(s)); }
public static void registerAllServices(final BundleContext bc, final Object service, final Properties props, Map<Class,Map<Object,ServiceRegistration>> serviceRegistrations) { for ( Class c : RegisterUtil.getAllInterfaces(service.getClass()) ) { if ( !c.getName().startsWith("java") ) registerService(bc, service, c, props, serviceRegistrations); } }
ServiceUtil { public static void registerAllServices(final BundleContext bc, final Object service, final Properties props, Map<Class,Map<Object,ServiceRegistration>> serviceRegistrations) { for ( Class c : RegisterUtil.getAllInterfaces(service.getClass()) ) { if ( !c.getName().startsWith("java") ) registerService(bc, service, c, props, serviceRegistrations); } } }
ServiceUtil { public static void registerAllServices(final BundleContext bc, final Object service, final Properties props, Map<Class,Map<Object,ServiceRegistration>> serviceRegistrations) { for ( Class c : RegisterUtil.getAllInterfaces(service.getClass()) ) { if ( !c.getName().startsWith("java") ) registerService(bc, service, c, props, serviceRegistrations); } } private  ServiceUtil(); }
ServiceUtil { public static void registerAllServices(final BundleContext bc, final Object service, final Properties props, Map<Class,Map<Object,ServiceRegistration>> serviceRegistrations) { for ( Class c : RegisterUtil.getAllInterfaces(service.getClass()) ) { if ( !c.getName().startsWith("java") ) registerService(bc, service, c, props, serviceRegistrations); } } private  ServiceUtil(); static S getService(BundleContext bc, Class<S> serviceClass, List<ServiceReference<?>> gottenServices); static S getService(BundleContext bc, Class<S> serviceClass, String filter, List<ServiceReference<?>> gottenServices); static void registerServiceListener(BundleContext bc, Object listener, String registerMethodName, 
			String unregisterMethodName, Class<?> serviceClass, Class<?> methodClass, String additionalFilter, List<CyServiceListener> serviceListeners); static void registerServiceListener(BundleContext bc, BiConsumer<S,Map<String,String>> registerConsumer, 
			BiConsumer<S,Map<String,String>> unregisterConsumer, Class<S> serviceClass, String additionalFilter, List<CyServiceListener> serviceListeners); static void registerService(final BundleContext bc, final Object service, final Class<?> serviceClass, final Properties props, 
			Map<Class,Map<Object,ServiceRegistration>> serviceRegistrations); static Dictionary<String, ?> getDictionary(Properties props); static void registerAllServices(final BundleContext bc, final Object service, final Properties props, 
			Map<Class,Map<Object,ServiceRegistration>> serviceRegistrations); }
ServiceUtil { public static void registerAllServices(final BundleContext bc, final Object service, final Properties props, Map<Class,Map<Object,ServiceRegistration>> serviceRegistrations) { for ( Class c : RegisterUtil.getAllInterfaces(service.getClass()) ) { if ( !c.getName().startsWith("java") ) registerService(bc, service, c, props, serviceRegistrations); } } private  ServiceUtil(); static S getService(BundleContext bc, Class<S> serviceClass, List<ServiceReference<?>> gottenServices); static S getService(BundleContext bc, Class<S> serviceClass, String filter, List<ServiceReference<?>> gottenServices); static void registerServiceListener(BundleContext bc, Object listener, String registerMethodName, 
			String unregisterMethodName, Class<?> serviceClass, Class<?> methodClass, String additionalFilter, List<CyServiceListener> serviceListeners); static void registerServiceListener(BundleContext bc, BiConsumer<S,Map<String,String>> registerConsumer, 
			BiConsumer<S,Map<String,String>> unregisterConsumer, Class<S> serviceClass, String additionalFilter, List<CyServiceListener> serviceListeners); static void registerService(final BundleContext bc, final Object service, final Class<?> serviceClass, final Properties props, 
			Map<Class,Map<Object,ServiceRegistration>> serviceRegistrations); static Dictionary<String, ?> getDictionary(Properties props); static void registerAllServices(final BundleContext bc, final Object service, final Properties props, 
			Map<Class,Map<Object,ServiceRegistration>> serviceRegistrations);  }