public synchronized ComputeService waitForComputeService()

in commands/src/main/java/org/jclouds/karaf/commands/compute/ComputeServiceCreateCommand.java [191:217]


   public synchronized ComputeService waitForComputeService(BundleContext bundleContext, String name, String provider, String api) {
      ComputeService computeService = null;
      try {
         for (int r = 0; r < 6; r++) {
            ServiceReference[] references = null;
            if (name != null) {
              references = bundleContext.getAllServiceReferences(ComputeService.class.getName(), "("+Constants.NAME+"="
                      + name + ")");
            }
            else if (provider != null) {
               references = bundleContext.getAllServiceReferences(ComputeService.class.getName(), "("+Constants.PROVIDER+"="
                        + provider + ")");
            } else if (api != null) {
               references = bundleContext.getAllServiceReferences(ComputeService.class.getName(), "("+Constants.API+"=" + api + ")");
            }

            if (references != null && references.length > 0) {
               computeService = (ComputeService) bundleContext.getService(references[0]);
               return computeService;
            }
            Thread.sleep(10000L);
         }
      } catch (Exception e) {
         // noop
      }
      return computeService;
   }