use of org.apache.aries.subsystem.util.felix.FelixRepositoryAdapter in project aries by apache.
the class RepositoryAdminRepository method findProviders.
public Collection<Capability> findProviders(Requirement requirement) {
logger.debug(LOG_ENTRY, "findProviders", requirement);
Collection<Capability> result = Collections.emptyList();
if (IdentityNamespace.IDENTITY_NAMESPACE.equals(requirement.getNamespace())) {
result = new ArrayList<Capability>();
for (org.apache.felix.bundlerepository.Repository r : repositoryAdmin.listRepositories()) {
FelixRepositoryAdapter repository = new FelixRepositoryAdapter(r);
Map<Requirement, Collection<Capability>> map = repository.findProviders(Arrays.asList(requirement));
Collection<Capability> capabilities = map.get(requirement);
if (capabilities != null)
result.addAll(capabilities);
}
return result;
} else {
Resource[] resources = repositoryAdmin.discoverResources(new org.apache.felix.bundlerepository.Requirement[] { new OsgiRequirementAdapter(requirement) });
logger.debug("Found {} resources with capabilities satisfying {}", resources == null ? 0 : resources.length, requirement);
if (resources != null && resources.length != 0) {
result = new ArrayList<Capability>(result.size());
OsgiRequirementAdapter adapter = new OsgiRequirementAdapter(requirement);
for (Resource resource : resources) {
logger.debug("Evaluating resource {}", resource);
for (org.apache.felix.bundlerepository.Capability capability : resource.getCapabilities()) {
logger.debug("Evaluating capability {}", capability);
if (adapter.isSatisfied(capability)) {
logger.debug("Adding capability {}", capability);
result.add(new FelixCapabilityAdapter(capability, new FelixResourceAdapter(resource)));
}
}
}
}
}
logger.debug(LOG_EXIT, "findProviders", result);
return result;
}
Aggregations