Requirement req = parseRequirement(bundleInfo.getLocation());
reqs.add(req);
infos.put(req, bundleInfo);
}
if (url != null) {
Resource res = repositoryAdmin.getHelper().createResource(url);
ress.add(res);
infos.put(res, bundleInfo);
}
}
Repository repository = repositoryAdmin.getHelper().repository(ress.toArray(new Resource[ress.size()]));
List<Repository> repos = new ArrayList<Repository>();
repos.add(repositoryAdmin.getSystemRepository());
repos.add(repositoryAdmin.getLocalRepository());
repos.add(repository);
repos.addAll(Arrays.asList(repositoryAdmin.listRepositories()));
org.apache.felix.bundlerepository.Resolver resolver = repositoryAdmin.resolver(repos.toArray(new Repository[repos.size()]));
for (Resource res : ress) {
if (!infos.get(res).isDependency()) {
resolver.add(res);
}
}
for (Requirement req : reqs) {
resolver.add(req);
}
if (!doResolve(resolver)) {
StringWriter w = new StringWriter();
PrintWriter out = new PrintWriter(w);
Reason[] failedReqs = resolver.getUnsatisfiedRequirements();
if ((failedReqs != null) && (failedReqs.length > 0)) {
out.println("Unsatisfied requirement(s):");
printUnderline(out, 27);
for (Reason r : failedReqs) {
out.println(" " + r.getRequirement().getName() + ":" + r.getRequirement().getFilter());
out.println(" " + r.getResource().getPresentationName());
}
} else {
out.println("Could not resolve targets.");
}
out.flush();
throw new Exception("Can not resolve feature:\n" + w.toString());
}
List<BundleInfo> bundles = new ArrayList<BundleInfo>();
List<Resource> deploy = new ArrayList<Resource>();
Collections.addAll(deploy, resolver.getRequiredResources());
if (resolveOptionalImports) {
Collections.addAll(deploy, resolver.getOptionalResources());
}
Collections.addAll(deploy, resolver.getAddedResources());
deploy.addAll(featureDeploy);
for (Resource res : deploy) {
BundleInfo info = infos.get(res);
if (info == null) {
Reason[] reasons = resolver.getReason(res);
if (reasons != null) {
for (Reason r : reasons) {
info = infos.get(r);
if (info != null) {
break;
}
}
}
}
if (info == null) {
info = new BundleInfoImpl(res.getURI(), this.startLevel, this.startByDefault, false);
}
bundles.add(info);
}
return bundles;
}