use of org.osgi.resource.Capability in project bnd by bndtools.
the class BndrunResolveContext method postProcessProviders.
protected void postProcessProviders(Requirement requirement, Set<Capability> wired, List<Capability> candidates) {
if (candidates.size() == 0)
return;
// Call resolver hooks
for (ResolverHook resolverHook : registry.getPlugins(ResolverHook.class)) {
resolverHook.filterMatches(requirement, candidates);
}
// Process the resolve preferences
boolean prefsUsed = false;
if (resolvePrefs != null && !resolvePrefs.isEmpty()) {
List<Capability> insertions = new LinkedList<Capability>();
for (Iterator<Capability> iterator = candidates.iterator(); iterator.hasNext(); ) {
Capability cap = iterator.next();
if (resolvePrefs.containsKey(getResourceIdentity(cap.getResource()))) {
iterator.remove();
insertions.add(cap);
}
}
if (!insertions.isEmpty()) {
candidates.addAll(0, insertions);
prefsUsed = true;
}
}
if (!prefsUsed) {
for (ResolutionCallback callback : getCallbacks()) {
callback.processCandidates(requirement, wired, candidates);
}
}
}
use of org.osgi.resource.Capability in project bnd by bndtools.
the class DebugReporter method doAllMembers.
private void doAllMembers() {
header("RESOURCES");
Requirement r = CapReqBuilder.createBundleRequirement("*", null).buildSyntheticRequirement();
List<Capability> providers = context.findProviders(r);
Set<Resource> resources = ResourceUtils.getResources(providers);
for (Resource resource : resources) {
resource(resource);
}
resource(context.getSystemResource());
nl();
}
use of org.osgi.resource.Capability in project bnd by bndtools.
the class AbstractResolveContext method insertHostedCapability.
@Override
public int insertHostedCapability(List<Capability> caps, HostedCapability hc) {
init();
Integer prioObj = resourcePriorities.get(hc.getResource());
int priority = prioObj != null ? prioObj.intValue() : Integer.MAX_VALUE;
for (int i = 0; i < caps.size(); i++) {
Capability c = caps.get(i);
Integer otherPrioObj = resourcePriorities.get(c.getResource());
int otherPriority = otherPrioObj != null ? otherPrioObj.intValue() : 0;
if (otherPriority > priority) {
caps.add(i, hc);
return i;
}
}
int newIndex = caps.size();
// the List passed by Felix does not support the
// single-arg version of add()... it throws
// UnsupportedOperationException
caps.add(newIndex, hc);
return newIndex;
}
use of org.osgi.resource.Capability in project bnd by bndtools.
the class AbstractResolveContext method findProvidersFromRepositories.
protected ArrayList<Capability> findProvidersFromRepositories(Requirement requirement, LinkedHashSet<Capability> existingWiredCapabilities) {
// Second stage results: repository contents; may be reordered.
ArrayList<Capability> secondStageResult = new ArrayList<Capability>();
// Iterate over the repos
int order = 0;
ArrayList<Capability> repoCapabilities = new ArrayList<Capability>();
for (Repository repo : repositories) {
repoCapabilities.clear();
Collection<Capability> capabilities = findProviders(repo, requirement);
if (capabilities != null && !capabilities.isEmpty()) {
repoCapabilities.ensureCapacity(capabilities.size());
for (Capability capability : capabilities) {
if (isPermitted(capability.getResource()) && isCorrectEffectiveness(requirement, capability)) {
repoCapabilities.add(capability);
setResourcePriority(order, capability.getResource());
}
}
secondStageResult.addAll(repoCapabilities);
}
order++;
}
Collections.sort(secondStageResult, capabilityComparator);
// Convert second-stage results to a list and post-process
ArrayList<Capability> secondStageList = new ArrayList<Capability>(secondStageResult);
// Post-processing second stage results
postProcessProviders(requirement, existingWiredCapabilities, secondStageList);
return secondStageList;
}
use of org.osgi.resource.Capability in project bnd by bndtools.
the class AbstractResolveContext method getResources.
public List<Resource> getResources(List<Repository> repos, Requirement req) {
Set<Resource> resources = new HashSet<Resource>();
for (Repository repo : repos) {
Collection<Capability> providers = findProviders(repo, req);
resources.addAll(ResourceUtils.getResources(providers));
}
return new ArrayList<>(resources);
}
Aggregations