// Path: api/src/main/java/org/jboss/osgi/resolver/XEnvironment.java
// public interface XEnvironment {
// 
//     void installResources(XResource... resources);
// 
//     void uninstallResources(XResource... resources);
// 
//     XResource getResourceById(long identifier);
// 
//     Iterator<XResource> getResources(Collection<String> types);
// 
//     Long nextResourceIdentifier(Long value, String symbolicName);
// 
//     List<Capability> findProviders(Requirement req);
// 
//     Map<Resource, Wiring> updateWiring(Map<Resource, List<Wire>> delta);
// 
//     Map<Resource, Wiring> getWirings();
// }
// 
// Path: api/src/main/java/org/jboss/osgi/resolver/XResolveContext.java
// public abstract class XResolveContext extends ResolveContext {
// 
//     public abstract XEnvironment getEnvironment();
// }


import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
import org.osgi.resource.Resource;
import org.osgi.resource.Wiring;
import org.osgi.service.resolver.HostedCapability;
import static org.jboss.osgi.resolver.ResolverLogger.LOGGER;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.jboss.osgi.resolver.XEnvironment;
import org.jboss.osgi.resolver.XResolveContext;
import org.osgi.framework.Constants;
    }

    @Override
    public XEnvironment getEnvironment() {
        return environment;
    }

    @Override
    public List<Capability> findProviders(Requirement req) {
        List<Capability> providers = environment.findProviders(req);
        Collections.sort(providers, getComparator());
        LOGGER.tracef("Ctx provides: %s => %s", req, providers);
        return providers;
    }

    @Override
    public int insertHostedCapability(List<Capability> caps, HostedCapability hostedCapability) {
        caps.add(hostedCapability);
        Collections.sort(caps, getComparator());
        LOGGER.tracef("Insert hosted capability: %s => %s", hostedCapability, caps);
        return caps.indexOf(hostedCapability);
    }

    @Override
    public boolean isEffective(Requirement req) {
        // Ignore reqs that are not effective:=resolve
        String effective = req.getDirectives().get(Constants.EFFECTIVE_DIRECTIVE);
        return effective == null || effective.equals(Constants.EFFECTIVE_RESOLVE);
    }

// Path: api/src/main/java/org/jboss/osgi/resolver/XEnvironment.java
// public interface XEnvironment {
// 
//     void installResources(XResource... resources);
// 
//     void uninstallResources(XResource... resources);
// 
//     XResource getResourceById(long identifier);
// 
//     Iterator<XResource> getResources(Collection<String> types);
// 
//     Long nextResourceIdentifier(Long value, String symbolicName);
// 
//     List<Capability> findProviders(Requirement req);
// 
//     Map<Resource, Wiring> updateWiring(Map<Resource, List<Wire>> delta);
// 
//     Map<Resource, Wiring> getWirings();
// }
// 
// Path: api/src/main/java/org/jboss/osgi/resolver/XResolveContext.java
// public abstract class XResolveContext extends ResolveContext {
// 
//     public abstract XEnvironment getEnvironment();
// }


// Path: api/src/main/java/org/jboss/osgi/resolver/spi/AbstractResolveContext.java
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
import org.osgi.resource.Resource;
import org.osgi.resource.Wiring;
import org.osgi.service.resolver.HostedCapability;
import static org.jboss.osgi.resolver.ResolverLogger.LOGGER;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.jboss.osgi.resolver.XEnvironment;
import org.jboss.osgi.resolver.XResolveContext;
import org.osgi.framework.Constants;

    }

    @Override
    public XEnvironment getEnvironment() {
        return environment;
    }

    @Override
    public List<Capability> findProviders(Requirement req) {
        List<Capability> providers = environment.findProviders(req);
        Collections.sort(providers, getComparator());
        LOGGER.tracef("Ctx provides: %s => %s", req, providers);
        return providers;
    }

    @Override
    public int insertHostedCapability(List<Capability> caps, HostedCapability hostedCapability) {
        caps.add(hostedCapability);
        Collections.sort(caps, getComparator());
        LOGGER.tracef("Insert hosted capability: %s => %s", hostedCapability, caps);
        return caps.indexOf(hostedCapability);
    }

    @Override
    public boolean isEffective(Requirement req) {
        // Ignore reqs that are not effective:=resolve
        String effective = req.getDirectives().get(Constants.EFFECTIVE_DIRECTIVE);
        return effective == null || effective.equals(Constants.EFFECTIVE_RESOLVE);
    }

    @Override