use of org.osgi.resource.Requirement in project bnd by bndtools.
the class AbstractIndexedRepo method findProviders.
public Map<Requirement, Collection<Capability>> findProviders(Collection<? extends Requirement> requirements) {
try {
init();
} catch (Exception e) {
throw new RuntimeException(e);
}
Map<Requirement, Collection<Capability>> result = new HashMap<Requirement, Collection<Capability>>();
for (Requirement requirement : requirements) {
List<Capability> matches = new LinkedList<Capability>();
result.put(requirement, matches);
capabilityIndex.appendMatchingCapabilities(requirement, matches);
}
return result;
}
use of org.osgi.resource.Requirement in project bnd by bndtools.
the class BndrunResolveContext method constructInputRequirements.
Resource constructInputRequirements() throws Exception {
ResourceBuilder resBuilder = new ResourceBuilder();
CapReqBuilder identity = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addAttribute(IdentityNamespace.IDENTITY_NAMESPACE, IDENTITY_INITIAL_RESOURCE);
resBuilder.addCapability(identity);
Parameters inputRequirements = new Parameters(properties.mergeProperties(Constants.RUNREQUIRES), project);
if (inputRequirements != null && !inputRequirements.isEmpty()) {
List<Requirement> requires = CapReqBuilder.getRequirementsFrom(inputRequirements);
resBuilder.addRequirements(requires);
}
return resBuilder.build();
}
use of org.osgi.resource.Requirement in project bnd by bndtools.
the class AbstractResolveContext method setInputRequirements.
public void setInputRequirements(Requirement... reqs) throws Exception {
ResourceBuilder rb = new ResourceBuilder();
for (Requirement r : reqs) {
rb.addRequirement(r);
}
setInputResource(rb.build());
}
use of org.osgi.resource.Requirement in project bnd by bndtools.
the class ResolveProcess method augment.
private static ResolutionException augment(Collection<Requirement> unresolved, ResolveContext context, ResolutionException re) {
if (unresolved.isEmpty()) {
return re;
}
long deadline = System.currentTimeMillis() + 1000L;
Set<Requirement> list = new HashSet<>(unresolved);
Set<Resource> resources = new HashSet<>();
try {
for (Requirement r : unresolved) {
Requirement find = missing(context, r, resources, deadline);
if (find != null) {
list.add(find);
}
}
} catch (TimeoutException toe) {
}
return new ResolutionException(re.getMessage(), re.getCause(), list);
}
use of org.osgi.resource.Requirement in project bnd by bndtools.
the class ResolveProcess method format.
public static String format(Collection<Requirement> requirements) {
Set<Requirement> mandatory = new HashSet<>();
Set<Requirement> optional = new HashSet<>();
for (Requirement req : requirements) {
if (isOptional(req))
optional.add(req);
else
mandatory.add(req);
}
try (Formatter f = new Formatter()) {
f.format("%n Mandatory:");
for (Requirement req : mandatory) {
f.format("%n [%-19s] %s", req.getNamespace(), req);
}
f.format("%n Optional:");
for (Requirement req : optional) {
f.format("%n [%-19s] %s", req.getNamespace(), req);
}
return f.toString();
}
}
Aggregations