use of org.apache.aries.subsystem.util.felix.OsgiResourceAdapter in project aries by apache.
the class RepositoryGenerator method resolve.
public List<Resource> resolve(List<Resource> subsystemContent, List<Resource> subsystemResources) throws SubsystemException {
generateOBR();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Attempt to resolve subsystem content {} subsystem resource {}", subsystemContent.toString(), subsystemResources.toString());
}
Resolver obrResolver = this.repositoryAdmin.resolver();
// add subsystem content to the resolver
for (Resource res : subsystemContent) {
// org.apache.felix.bundlerepository.Resource obrRes = findOBRResource(res);
// obrResolver.add(obrRes);
obrResolver.add(new OsgiResourceAdapter(res));
}
// add subsystem resource to the resolver
for (Resource res : subsystemResources) {
// org.apache.felix.bundlerepository.Resource obrRes = findOBRResource(res);
// obrResolver.add(obrRes);
obrResolver.add(new OsgiResourceAdapter(res));
}
// Question: do we need to create the repository.xml for the subsystem and add the repo to RepoAdmin?
List<Resource> resources = new ArrayList<Resource>();
if (obrResolver.resolve()) {
for (org.apache.felix.bundlerepository.Resource res : obrResolver.getRequiredResources()) {
// resources.add(toResource(res));
resources.add(new FelixResourceAdapter(res));
}
// Question: should we handle optional resource differently?
for (org.apache.felix.bundlerepository.Resource res : obrResolver.getOptionalResources()) {
// resources.add(toResource(res));
resources.add(new FelixResourceAdapter(res));
}
} else {
// log the unsatisfied requirement
Reason[] reasons = obrResolver.getUnsatisfiedRequirements();
StringBuilder builder = new StringBuilder("Failed to resolve subsystem").append(System.getProperty("line.separator"));
for (Reason reason : reasons) {
LOGGER.warn("Unable to resolve subsystem content {} subsystem resource {} because of unsatisfied requirement {}", new Object[] { subsystemContent.toString(), subsystemResources.toString(), reason.getRequirement().getName() });
builder.append("resource = ").append(reason.getResource().getSymbolicName()).append(", requirement = ").append(reason.getRequirement().getName()).append(System.getProperty("line.separator"));
}
throw new SubsystemException(builder.toString());
}
return resources;
}
Aggregations