@Override
public Set<ResourceHandle> provisionResources(Set<Requirement> reqs) throws ProvisionException {
// Find resources
ProvisionResult result = findResources(reqs);
Set<Requirement> unsatisfied = result.getUnsatisfiedRequirements();
if (!unsatisfied.isEmpty()) {
throw new ProvisionException("Cannot resolve unsatisfied requirements: " + unsatisfied);
}
// NOTE: installing resources and updating the wiring is not an atomic operation
// Install resources
List<Resource> resources = result.getResources();
Map<Requirement, Resource> mapping = result.getMapping();
DefaultInstallerContext context = new DefaultInstallerContext(resources, mapping);
Set<ResourceHandle> handles = installResources(context);
// Update the wirings
Map<Resource, Wiring> auxwirings = result.getWirings();
for (Entry<Resource, Wiring> entry : auxwirings.entrySet()) {
Resource auxres = entry.getKey();
Resource envres = environment.getResource(auxres.getIdentity());
DefaultWiring envwiring = new DefaultWiring(envres, null, null);
Wiring auxwiring = entry.getValue();