Package org.osgi.util.tracker

Examples of org.osgi.util.tracker.ServiceTracker.waitForService()


                } else {
                    LOGGER.debug("Optional resolver '" + resolver + "' not found, using the default resolver");
                    return feature.getBundles();
                }
            } else {
                Resolver r = (Resolver) tracker.waitForService(resolverTimeout);
                if (r == null) {
                    throw new Exception("Unable to find required resolver '" + resolver + "'");
                }
                return r.resolve(feature);
            }
View Full Code Here


            Filter osgiFilter = FrameworkUtil.createFilter(flt);
            tracker = new ServiceTracker(bundleContext, osgiFilter, null);
            tracker.open(true);
            // Note that the tracker is not closed to keep the reference
            // This is buggy, as the service reference may change i think
            Object svc = type.cast(tracker.waitForService(timeout));
            if (svc == null) {
                Dictionary dic = bundleContext.getBundle().getHeaders();
                System.err.println("Test bundle headers: " + explode(dic));

                for (ServiceReference ref : asCollection(bundleContext.getAllServiceReferences(null, null))) {
View Full Code Here

            Filter osgiFilter = FrameworkUtil.createFilter(filter);
            tracker = new ServiceTracker(bundleContext, osgiFilter, null);
            tracker.open(true);
            Object svc = tracker.getService();
            if (timeout >= 0) {
                svc = tracker.waitForService(timeout);
            }
            if (exception && svc == null) {
                throw new TimeoutException("Can not find service '" + service + "' in the OSGi registry");
            }
            return svc != null;
View Full Code Here

                } else {
                    LOGGER.debug("Optional resolver '" + resolver + "' not found, using the default resolver");
                    return feature.getBundles();
                }
            } else {
                Resolver r = (Resolver) tracker.waitForService(resolverTimeout);
                if (r == null) {
                    throw new Exception("Unable to find required resolver '" + resolver + "'");
                }
                return r.resolve(feature);
            }
View Full Code Here

    protected PackageAdmin getPackageAdmin() {
        ServiceTracker packageAdminTracker = activator.getPackageAdminTracker();
        if (packageAdminTracker != null) {
            try {
                return (PackageAdmin)packageAdminTracker.waitForService(5000L);
            } catch (InterruptedException e) {
                // ignore
            }
        }
        return null;
View Full Code Here

   
    try {
      extensionTracker.open();
     
      try {
        extension = (T) extensionTracker.waitForService(30000);
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    } finally {
      extensionTracker.close();
View Full Code Here

        // Else, find the resolver
        String filter = "(&(" + Constants.OBJECTCLASS + "=" + Resolver.class.getName() + ")(name=" + resolver + "))";
        ServiceTracker tracker = new ServiceTracker(bundleContext, FrameworkUtil.createFilter(filter), null);
        tracker.open();
        try {
            Resolver r = (Resolver) tracker.waitForService(resolverTimeout);
            return r.resolve(feature);
        } finally {
            tracker.close();
        }
    }
View Full Code Here

                } else {
                    LOGGER.debug("Optional resolver '" + resolver + "' not found, using the default resolver");
                    return feature.getBundles();
                }
            } else {
                Resolver r = (Resolver) tracker.waitForService(resolverTimeout);
                if (r == null) {
                    throw new Exception("Unable to find required resolver '" + resolver + "'");
                }
                return r.resolve(feature);
            }
View Full Code Here

            tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter, null);
            tracker.open();
           
            // add tracker to the list of trackers we close at tear down
            srs.add(tracker);
            Object svc = type.cast(tracker.waitForService(timeout));
            if (svc == null) {
                throw new RuntimeException("Gave up waiting for service " + flt);
            }
            return type.cast(svc);
        } catch (InvalidSyntaxException e) {
View Full Code Here

   * @return All know implementors
   */
  public <T> T getServiceImpl(Class<T> contract) {
    final ServiceTracker serviceTracker = getServiceTracker( contract.getName() );
    try {
      return (T) serviceTracker.waitForService( 1000 );
    }
    catch (Exception e) {
      LOG.unableToDiscoverOsgiService( contract.getName(), e );
      return null;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.