resolver = resolver.substring(1, resolver.length() - 1);
optional = true;
}
// 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 {
if (optional) {
Resolver r = (Resolver) tracker.getService();
if (r != null) {
return r.resolve(feature);
} 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);
}
} finally {
tracker.close();
}
}