@Test @SuppressWarnings("unchecked") public void testStartTracking() throws Exception { OsgiServiceCollection collection = createCollection("(a=b)"); assertThat(collection.isEmpty(), equalTo(true)); assertThat(collection.size(), equalTo(0)); registry.registerService( Collection.class.getName(), new ArrayList<Object>(), new Hashtable(Collections.singletonMap("a", "b"))); assertThat(collection.isEmpty(), equalTo(true)); assertThat(collection.size(), equalTo(0)); collection.startTracking(); assertThat(collection.isEmpty(), equalTo(false)); assertThat(collection.size(), equalTo(1)); registry.registerService( Collection.class.getName(), new ArrayList<Object>(), new Hashtable(Collections.singletonMap("a", "b"))); assertThat(collection.isEmpty(), equalTo(false)); assertThat(collection.size(), equalTo(2)); }
public void startTracking() { try { bundleContext.addServiceListener(listener, filter); ServiceReference[] alreadyDefined = bundleContext.getServiceReferences(null, filter); if(alreadyDefined != null) { for(ServiceReference ref : alreadyDefined) { listener.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, ref)); } } } catch (InvalidSyntaxException e) { throw new IllegalStateException(e); } }
OsgiServiceCollection implements Collection<E> { public void startTracking() { try { bundleContext.addServiceListener(listener, filter); ServiceReference[] alreadyDefined = bundleContext.getServiceReferences(null, filter); if(alreadyDefined != null) { for(ServiceReference ref : alreadyDefined) { listener.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, ref)); } } } catch (InvalidSyntaxException e) { throw new IllegalStateException(e); } } }
OsgiServiceCollection implements Collection<E> { public void startTracking() { try { bundleContext.addServiceListener(listener, filter); ServiceReference[] alreadyDefined = bundleContext.getServiceReferences(null, filter); if(alreadyDefined != null) { for(ServiceReference ref : alreadyDefined) { listener.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, ref)); } } } catch (InvalidSyntaxException e) { throw new IllegalStateException(e); } } OsgiServiceCollection(BundleContext bundleContext, String filter, ClassLoader fallbackClassLoader,
             OsgiProxyCreator proxyCreator);  OsgiServiceCollection(BundleContext bundleContext, String filter, ClassLoader fallbackClassLoader,
             OsgiProxyCreator proxyCreator, DynamicCollection<E> backed); }
OsgiServiceCollection implements Collection<E> { public void startTracking() { try { bundleContext.addServiceListener(listener, filter); ServiceReference[] alreadyDefined = bundleContext.getServiceReferences(null, filter); if(alreadyDefined != null) { for(ServiceReference ref : alreadyDefined) { listener.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, ref)); } } } catch (InvalidSyntaxException e) { throw new IllegalStateException(e); } } OsgiServiceCollection(BundleContext bundleContext, String filter, ClassLoader fallbackClassLoader,
             OsgiProxyCreator proxyCreator);  OsgiServiceCollection(BundleContext bundleContext, String filter, ClassLoader fallbackClassLoader,
             OsgiProxyCreator proxyCreator, DynamicCollection<E> backed); void startTracking(); void stopTracking(); @Override Iterator<E> iterator(); @Override int size(); @Override String toString(); @Override boolean remove(Object o); @Override boolean removeAll(Collection c); @Override boolean add(Object o); @Override boolean addAll(Collection c); @Override void clear(); @Override boolean retainAll(Collection c); @Override boolean contains(Object o); @Override boolean containsAll(Collection c); @Override boolean isEmpty(); @Override Object[] toArray(); @SuppressWarnings("SuspiciousToArrayCall") @Override T[] toArray(T[] array); }
OsgiServiceCollection implements Collection<E> { public void startTracking() { try { bundleContext.addServiceListener(listener, filter); ServiceReference[] alreadyDefined = bundleContext.getServiceReferences(null, filter); if(alreadyDefined != null) { for(ServiceReference ref : alreadyDefined) { listener.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, ref)); } } } catch (InvalidSyntaxException e) { throw new IllegalStateException(e); } } OsgiServiceCollection(BundleContext bundleContext, String filter, ClassLoader fallbackClassLoader,
             OsgiProxyCreator proxyCreator);  OsgiServiceCollection(BundleContext bundleContext, String filter, ClassLoader fallbackClassLoader,
             OsgiProxyCreator proxyCreator, DynamicCollection<E> backed); void startTracking(); void stopTracking(); @Override Iterator<E> iterator(); @Override int size(); @Override String toString(); @Override boolean remove(Object o); @Override boolean removeAll(Collection c); @Override boolean add(Object o); @Override boolean addAll(Collection c); @Override void clear(); @Override boolean retainAll(Collection c); @Override boolean contains(Object o); @Override boolean containsAll(Collection c); @Override boolean isEmpty(); @Override Object[] toArray(); @SuppressWarnings("SuspiciousToArrayCall") @Override T[] toArray(T[] array);  }