use of org.osgi.service.resolver.Resolver in project aries by apache.
the class DependencyCalculator method calculateDependencies.
public List<Requirement> calculateDependencies() throws ResolutionException {
ArrayList<Requirement> result = new ArrayList<Requirement>();
Resolver resolver = Activator.getInstance().getResolver();
Map<Resource, List<Wire>> resolution = resolver.resolve(context);
for (List<Wire> wires : resolution.values()) for (Wire wire : wires) if (wire.getCapability() instanceof MissingCapability)
result.add(wire.getRequirement());
result.trimToSize();
return result;
}
use of org.osgi.service.resolver.Resolver in project bnd by bndtools.
the class BndrunResolveContextTest method testResolveProvidedCapabilitiesWithDistro.
public static void testResolveProvidedCapabilitiesWithDistro() throws Exception {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
BndEditModel model = new BndEditModel();
model.genericSet("-runprovidedcapabilities", "osgi.service;objectClass=foo.bar.FooBarService;effective:=active");
model.setDistro(Arrays.asList("testdata/distro.jar;version=file"));
List<Requirement> requires = new ArrayList<Requirement>();
List<Capability> caps = CapReqBuilder.getCapabilitiesFrom(new Parameters("osgi.service;objectClass=foo.bar.FooBarService;effective:=active"));
Requirement req = CapReqBuilder.createRequirementFromCapability(caps.get(0)).buildSyntheticRequirement();
requires.add(req);
model.setRunRequires(requires);
BndrunResolveContext context = new BndrunResolveContext(model, registry, log);
context.setLevel(0);
context.init();
Resolver resolver = new BndResolver(new ResolverLogger(4));
resolver.resolve(context);
}
use of org.osgi.service.resolver.Resolver in project bnd by bndtools.
the class ResolveTest method testResolveWithDistro.
/**
* Test if we can resolve with a distro
*
* @throws ResolutionException
*/
public void testResolveWithDistro() throws ResolutionException {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
BndEditModel model = new BndEditModel();
model.setDistro(Arrays.asList("testdata/distro.jar;version=file"));
List<Requirement> requires = new ArrayList<Requirement>();
CapReqBuilder capReq = CapReqBuilder.createBundleRequirement("org.apache.felix.gogo.shell", "[0,1)");
requires.add(capReq.buildSyntheticRequirement());
model.setRunRequires(requires);
BndrunResolveContext context = new BndrunResolveContext(model, registry, log);
context.setLevel(0);
context.init();
Resolver resolver = new BndResolver(new ResolverLogger(4));
Map<Resource, List<Wire>> resolved = resolver.resolve(context);
Set<Resource> resources = resolved.keySet();
Resource shell = getResource(resources, "org.apache.felix.gogo.shell", "0.10.0");
assertNotNull(shell);
}
use of org.osgi.service.resolver.Resolver in project bnd by bndtools.
the class ResolveTest method testMinimalSetup.
/**
* Test minimal setup
*
* @throws URISyntaxException
* @throws MalformedURLException
*/
public void testMinimalSetup() throws MalformedURLException, URISyntaxException {
File index = IO.getFile("testdata/repo3.index.xml");
FixedIndexedRepo fir = new FixedIndexedRepo();
fir.setLocations(index.toURI().toString());
Processor model = new Processor();
model.setProperty("-runfw", "org.apache.felix.framework");
model.setProperty("-runrequires", "osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)'");
BndrunResolveContext context = new BndrunResolveContext(model, null, model, log);
context.setLevel(0);
context.addRepository(fir);
context.init();
Resolver resolver = new BndResolver(new ResolverLogger(4));
try {
Map<Resource, List<Wire>> resolved = resolver.resolve(context);
Set<Resource> resources = resolved.keySet();
Resource shell = getResource(resources, "org.apache.felix.gogo.shell", "0.10.0");
assertNotNull(shell);
} catch (ResolutionException e) {
e.printStackTrace();
fail("Resolve failed");
}
}
use of org.osgi.service.resolver.Resolver in project bnd by bndtools.
the class ResolveTest method assertAugmentResolve.
private static void assertAugmentResolve(String augment, String require, String effective) throws Exception {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
Processor model = new Processor();
model.setRunfw("org.apache.felix.framework");
model.setProperty("-augment", augment);
model.setRunRequires(require);
if (effective != null)
model.setProperty("-resolve.effective", effective);
BndrunResolveContext context = new BndrunResolveContext(model, null, registry, log);
Resolver resolver = new BndResolver(new ResolverLogger(4));
Map<Resource, List<Wire>> resolved = resolver.resolve(context);
Set<Resource> resources = resolved.keySet();
Resource resource = getResource(resources, "org.apache.felix.gogo.runtime", "0.10");
assertNotNull(resource);
}
Aggregations