Package org.osgi.util.tracker

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


    try {
      BundleContext bc = b.getBundleContext();
        String bsn = b.getSymbolicName();
      ServiceTracker st = new ServiceTracker(bc, sclass, null);
        st.open();
        Object bac = st.waitForService(DEFAULT_TIMEOUT);
      /* Uncomment for debug */
      /*
      if(bac == null) {
        System.out.println("SERVICE NOTFOUND " + bsn);
      } else {
View Full Code Here


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


    private static ServiceTracker getServiceManager(BundleContext context) throws InterruptedException {
        ServiceTracker serviceManagerTracker = new ServiceTracker(context, SERVICE_MANAGER_NAME, null);
        serviceManagerTracker.open();
        serviceManagerTracker.waitForService(TRACKER_TIMEOUT);
        return serviceManagerTracker;
    }

    public void stop(BundleContext context) throws Exception {
        LOGGER.info("Stopping OpenEJB");
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

        log.info(bundle.getLocation() + ": " + getBundleStateDescription(bundle.getState()));
      }
      ServiceTracker tracker1 = new ServiceTracker(bundleContext,
          Handler.class.getName(), null);
      tracker1.open();
      System.out.println("Handler: " + tracker1.waitForService(15000));
      ServiceTracker tracker = new ServiceTracker(bundleContext,
          GeneratorService.class.getName(), null);
      tracker.open();
      Object rendererFactoryObj = tracker.waitForService(15000);
View Full Code Here

      tracker1.open();
      System.out.println("Handler: " + tracker1.waitForService(15000));
      ServiceTracker tracker = new ServiceTracker(bundleContext,
          GeneratorService.class.getName(), null);
      tracker.open();
      Object rendererFactoryObj = tracker.waitForService(15000);

      log.debug(GeneratorService.class + " service : " + rendererFactoryObj);
      log.debug(GeneratorService.class + " service : " + rendererFactoryObj.getClass());
      GeneratorService generatorService = (GeneratorService) rendererFactoryObj;
      final File baseDir = new File(baseDirName);
View Full Code Here

      throws InterruptedException {
    System.out.println("waiting for a " + aClass);
    ServiceTracker tracker = new ServiceTracker(bundleContext,
        aClass.getName(), null);
    tracker.open();
    Object service = tracker.waitForService(timeout);
    return service;
  }

  private boolean waitForWebserver() throws InterruptedException {
    int j = 0;
View Full Code Here

  private void waitFor(Class<?> aClass) throws InterruptedException {
    System.out.println("waiting for a " + aClass);
    ServiceTracker tracker = new ServiceTracker(bundleContext,
        aClass.getName(), null);
    tracker.open();
    Object service = tracker.waitForService(10000);
  }

  private void waitForWebserver() {
    try {
      URL serverURL = new URL("http://localhost:" + testHttpPort + "/");
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

      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 = 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

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.