@Override public void run() { while (!stop) { ServiceObjects<String> serviceObjects = ctx.getServiceObjects(ref); try { String svc = serviceObjects.getService(); if (!"bar".equals(svc)) System.out.println("Bad Service!"); else counter++; // serviceObjects.ungetService(svc); } finally { ctx.ungetService(ref); } } System.out.println("Thread done (" + getClass().getSimpleName() + ")"); }
public MultiplePrototypeRefPair(BundleContext context, ServiceReference<T> ref) { super(ref); this.serviceObjects = context.getServiceObjects(ref); }