use of org.apache.felix.bundlerepository.Resource in project aries by apache.
the class OBRAppManagerTest method testAppWithApplicationManifest.
@Test
public void testAppWithApplicationManifest() throws Exception {
RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
Repository[] repos = repositoryAdmin.listRepositories();
for (Repository repo : repos) {
Resource[] resources = repo.getResources();
for (Resource r : resources) {
Capability[] cs = r.getCapabilities();
for (Capability c : cs) {
System.out.println(c.getName() + " : " + c.getProperties());
}
}
}
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
app = manager.resolve(app);
// installing requires a valid url for the bundle in repository.xml.
AriesApplicationContext ctx = manager.install(app);
ctx.start();
HelloWorld hw = context().getService(HelloWorld.class);
String result = hw.getMessage();
assertEquals(result, "hello world");
ctx.stop();
manager.uninstall(ctx);
}
use of org.apache.felix.bundlerepository.Resource in project aries by apache.
the class Aries1523Test method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
BundleContext context = context();
ServiceReference<RepositoryAdmin> ref = context.getServiceReference(RepositoryAdmin.class);
assertNotNull("The RepositoryAdmin service does not exist", ref);
try {
repositoryAdmin = (RepositoryAdmin) context.getService(ref);
DataModelHelper helper = repositoryAdmin.getHelper();
url = createRepositoryXml(helper);
Repository repository = repositoryAdmin.addRepository(url);
Resource resource = repository.getResources()[0];
System.out.println(resource.getURI());
} finally {
context.ungetService(ref);
}
}
use of org.apache.felix.bundlerepository.Resource in project aries by apache.
the class Aries1608Test method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
BundleContext context = context();
ServiceReference<RepositoryAdmin> ref = context.getServiceReference(RepositoryAdmin.class);
assertNotNull("The RepositoryAdmin service does not exist", ref);
try {
repositoryAdmin = (RepositoryAdmin) context.getService(ref);
DataModelHelper helper = repositoryAdmin.getHelper();
url = createRepositoryXml(helper);
Repository repository = repositoryAdmin.addRepository(url);
Resource resource = repository.getResources()[0];
System.out.println(resource.getURI());
} finally {
context.ungetService(ref);
}
}
use of org.apache.felix.bundlerepository.Resource 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;
}
use of org.apache.felix.bundlerepository.Resource in project aries by apache.
the class Aries1522Test method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
BundleContext context = context();
ServiceReference<RepositoryAdmin> ref = context.getServiceReference(RepositoryAdmin.class);
assertNotNull("The RepositoryAdmin service does not exist", ref);
try {
repositoryAdmin = (RepositoryAdmin) context.getService(ref);
DataModelHelper helper = repositoryAdmin.getHelper();
url = createRepositoryXml(helper);
Repository repository = repositoryAdmin.addRepository(url);
Resource resource = repository.getResources()[0];
System.out.println(resource.getURI());
} finally {
context.ungetService(ref);
}
}
Aggregations