in chef/commands/src/main/java/org/jclouds/karaf/chef/commands/ChefServiceCreateCommand.java [183:205]
public synchronized ApiContext<ChefApi> waitForChefService(BundleContext bundleContext, String name, String api) {
ApiContext<ChefApi> chefService = null;
try {
for (int r = 0; r < 6; r++) {
ServiceReference[] references = null;
if (name != null) {
references = bundleContext.getAllServiceReferences(ApiContext.class.getName(), "(" + Constants.NAME + "="
+ name + ")");
} else if (api != null) {
references = bundleContext.getAllServiceReferences(ApiContext.class.getName(), "(" + Constants.API + "=" + api + ")");
}
if (references != null && references.length > 0) {
chefService = (ApiContext<ChefApi>) bundleContext.getService(references[0]);
return chefService;
}
Thread.sleep(10000L);
}
} catch (Exception e) {
// noop
}
return chefService;
}