@Test public void testEventHookNoFilter() throws Exception { BundleContext hookBC = mockBundleContext(5L); GuardProxyCatalog gpc = new GuardProxyCatalog(hookBC); GuardingEventHook geh = new GuardingEventHook(hookBC, gpc, null); geh.event(null, null); }
@Override public void event(ServiceEvent event, Map<BundleContext, Collection<ListenerHook.ListenerInfo>> listeners) { if (servicesFilter == null) { return; } ServiceReference<?> sr = event.getServiceReference(); if (!servicesFilter.match(sr)) { return; } boolean proxificationDone = false; BundleContext system = bundleContext.getBundle(0).getBundleContext(); for (Iterator<BundleContext> i = listeners.keySet().iterator(); i.hasNext(); ) { BundleContext bc = i.next(); if (bc == bundleContext || bc == system) { continue; } if (proxificationDone || (proxificationDone = guardProxyCatalog.handleProxificationForHook(sr))) { i.remove(); } } }
GuardingEventHook implements EventListenerHook { @Override public void event(ServiceEvent event, Map<BundleContext, Collection<ListenerHook.ListenerInfo>> listeners) { if (servicesFilter == null) { return; } ServiceReference<?> sr = event.getServiceReference(); if (!servicesFilter.match(sr)) { return; } boolean proxificationDone = false; BundleContext system = bundleContext.getBundle(0).getBundleContext(); for (Iterator<BundleContext> i = listeners.keySet().iterator(); i.hasNext(); ) { BundleContext bc = i.next(); if (bc == bundleContext || bc == system) { continue; } if (proxificationDone || (proxificationDone = guardProxyCatalog.handleProxificationForHook(sr))) { i.remove(); } } } }
GuardingEventHook implements EventListenerHook { @Override public void event(ServiceEvent event, Map<BundleContext, Collection<ListenerHook.ListenerInfo>> listeners) { if (servicesFilter == null) { return; } ServiceReference<?> sr = event.getServiceReference(); if (!servicesFilter.match(sr)) { return; } boolean proxificationDone = false; BundleContext system = bundleContext.getBundle(0).getBundleContext(); for (Iterator<BundleContext> i = listeners.keySet().iterator(); i.hasNext(); ) { BundleContext bc = i.next(); if (bc == bundleContext || bc == system) { continue; } if (proxificationDone || (proxificationDone = guardProxyCatalog.handleProxificationForHook(sr))) { i.remove(); } } } GuardingEventHook(BundleContext bundleContext, GuardProxyCatalog guardProxyCatalog, Filter securedServicesFilter); }
GuardingEventHook implements EventListenerHook { @Override public void event(ServiceEvent event, Map<BundleContext, Collection<ListenerHook.ListenerInfo>> listeners) { if (servicesFilter == null) { return; } ServiceReference<?> sr = event.getServiceReference(); if (!servicesFilter.match(sr)) { return; } boolean proxificationDone = false; BundleContext system = bundleContext.getBundle(0).getBundleContext(); for (Iterator<BundleContext> i = listeners.keySet().iterator(); i.hasNext(); ) { BundleContext bc = i.next(); if (bc == bundleContext || bc == system) { continue; } if (proxificationDone || (proxificationDone = guardProxyCatalog.handleProxificationForHook(sr))) { i.remove(); } } } GuardingEventHook(BundleContext bundleContext, GuardProxyCatalog guardProxyCatalog, Filter securedServicesFilter); @Override void event(ServiceEvent event, Map<BundleContext, Collection<ListenerHook.ListenerInfo>> listeners); }
GuardingEventHook implements EventListenerHook { @Override public void event(ServiceEvent event, Map<BundleContext, Collection<ListenerHook.ListenerInfo>> listeners) { if (servicesFilter == null) { return; } ServiceReference<?> sr = event.getServiceReference(); if (!servicesFilter.match(sr)) { return; } boolean proxificationDone = false; BundleContext system = bundleContext.getBundle(0).getBundleContext(); for (Iterator<BundleContext> i = listeners.keySet().iterator(); i.hasNext(); ) { BundleContext bc = i.next(); if (bc == bundleContext || bc == system) { continue; } if (proxificationDone || (proxificationDone = guardProxyCatalog.handleProxificationForHook(sr))) { i.remove(); } } } GuardingEventHook(BundleContext bundleContext, GuardProxyCatalog guardProxyCatalog, Filter securedServicesFilter); @Override void event(ServiceEvent event, Map<BundleContext, Collection<ListenerHook.ListenerInfo>> listeners);  }