@Test(expected=RuntimeException.class) public void TestRegisterServiceListener(){ ServiceUtil.registerServiceListener(bc, mock(Object.class), "", "", Object.class, Object.class, "dummy filter" , (( List<CyServiceListener>)mock(List.class))); }
public static void registerServiceListener(BundleContext bc, Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass, Class<?> methodClass, String additionalFilter, List<CyServiceListener> serviceListeners) { try { CyServiceListener<?> serviceListener = new CyServiceListener<>(bc, listener, registerMethodName, unregisterMethodName, serviceClass, methodClass, additionalFilter); serviceListener.open(); if (serviceListeners != null) serviceListeners.add( serviceListener ); } catch (Exception e) { throw new RuntimeException("Could not listen to services for object: " + listener + " with methods: " + registerMethodName + ", " + unregisterMethodName + ", service type: " + serviceClass + ", and additional filter: " + additionalFilter, e); } }
ServiceUtil { public static void registerServiceListener(BundleContext bc, Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass, Class<?> methodClass, String additionalFilter, List<CyServiceListener> serviceListeners) { try { CyServiceListener<?> serviceListener = new CyServiceListener<>(bc, listener, registerMethodName, unregisterMethodName, serviceClass, methodClass, additionalFilter); serviceListener.open(); if (serviceListeners != null) serviceListeners.add( serviceListener ); } catch (Exception e) { throw new RuntimeException("Could not listen to services for object: " + listener + " with methods: " + registerMethodName + ", " + unregisterMethodName + ", service type: " + serviceClass + ", and additional filter: " + additionalFilter, e); } } }
ServiceUtil { public static void registerServiceListener(BundleContext bc, Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass, Class<?> methodClass, String additionalFilter, List<CyServiceListener> serviceListeners) { try { CyServiceListener<?> serviceListener = new CyServiceListener<>(bc, listener, registerMethodName, unregisterMethodName, serviceClass, methodClass, additionalFilter); serviceListener.open(); if (serviceListeners != null) serviceListeners.add( serviceListener ); } catch (Exception e) { throw new RuntimeException("Could not listen to services for object: " + listener + " with methods: " + registerMethodName + ", " + unregisterMethodName + ", service type: " + serviceClass + ", and additional filter: " + additionalFilter, e); } } private  ServiceUtil(); }
ServiceUtil { public static void registerServiceListener(BundleContext bc, Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass, Class<?> methodClass, String additionalFilter, List<CyServiceListener> serviceListeners) { try { CyServiceListener<?> serviceListener = new CyServiceListener<>(bc, listener, registerMethodName, unregisterMethodName, serviceClass, methodClass, additionalFilter); serviceListener.open(); if (serviceListeners != null) serviceListeners.add( serviceListener ); } catch (Exception e) { throw new RuntimeException("Could not listen to services for object: " + listener + " with methods: " + registerMethodName + ", " + unregisterMethodName + ", service type: " + serviceClass + ", and additional filter: " + additionalFilter, e); } } 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 registerServiceListener(BundleContext bc, Object listener, String registerMethodName, String unregisterMethodName, Class<?> serviceClass, Class<?> methodClass, String additionalFilter, List<CyServiceListener> serviceListeners) { try { CyServiceListener<?> serviceListener = new CyServiceListener<>(bc, listener, registerMethodName, unregisterMethodName, serviceClass, methodClass, additionalFilter); serviceListener.open(); if (serviceListeners != null) serviceListeners.add( serviceListener ); } catch (Exception e) { throw new RuntimeException("Could not listen to services for object: " + listener + " with methods: " + registerMethodName + ", " + unregisterMethodName + ", service type: " + serviceClass + ", and additional filter: " + additionalFilter, e); } } 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);  }