void filterServiceEventReceivers( final ServiceEvent evt, final Collection /*<ServiceListenerEntry>*/ receivers) { ArrayList srl = fwCtx.services.get(EventHook.class.getName()); if (srl != null) { HashSet ctxs = new HashSet(); for (Iterator ir = receivers.iterator(); ir.hasNext(); ) { ctxs.add(((ServiceListenerEntry) ir.next()).getBundleContext()); } int start_size = ctxs.size(); RemoveOnlyCollection filtered = new RemoveOnlyCollection(ctxs); for (Iterator i = srl.iterator(); i.hasNext(); ) { ServiceReferenceImpl sr = ((ServiceRegistrationImpl) i.next()).reference; EventHook eh = (EventHook) sr.getService(fwCtx.systemBundle); if (eh != null) { try { eh.event(evt, filtered); } catch (Exception e) { fwCtx.debug.printStackTrace( "Failed to call event hook #" + sr.getProperty(Constants.SERVICE_ID), e); } } } // NYI, refactor this for speed!? if (start_size != ctxs.size()) { for (Iterator ir = receivers.iterator(); ir.hasNext(); ) { if (!ctxs.contains(((ServiceListenerEntry) ir.next()).getBundleContext())) { ir.remove(); } } } } }
public Iterator iterator() { return org.iterator(); }