use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class AriesApplicationManagerImpl method uninstall.
public void uninstall(AriesApplicationContext appContext) throws BundleException {
_applicationContextManager.remove(appContext);
// Also unregister the service if we added one for it
AriesApplication app = appContext.getApplication();
if (app != null) {
ServiceRegistration reg = serviceRegistrations.remove(app);
if (reg != null)
try {
reg.unregister();
} catch (IllegalStateException e) {
// Must be already unregistered - ignore
}
}
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class IsolatedRuntimeTest method testUninstallReinstall.
@Test
@Ignore
public void testUninstallReinstall() throws Exception {
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
AriesApplicationContext ctx = manager.install(app);
app = ctx.getApplication();
ctx.start();
assertHelloWorldService("org.apache.aries.sample2");
ctx.stop();
manager.uninstall(ctx);
assertNull(IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, "org.apache.aries.sample2"));
ctx = manager.install(app);
ctx.start();
assertHelloWorldService("org.apache.aries.sample2");
manager.uninstall(ctx);
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class MinimumImportsTest method testAppUsingAriesApplicationManager.
@Test
public void testAppUsingAriesApplicationManager() throws Exception {
// Register a BlueprintListener to listen for the events from the BlueprintContainer for the bundle in the appmgrclienttest.eba
AppMgrClientBlueprintListener acbl = new AppMgrClientBlueprintListener();
ServiceRegistration sr = bundleContext.registerService("org.osgi.service.blueprint.container.BlueprintListener", acbl, null);
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("appmgrclienttest.eba")));
RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
Repository[] repos = repositoryAdmin.listRepositories();
for (Repository repo : repos) {
repositoryAdmin.removeRepository(repo.getURI());
}
repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
AriesApplicationContext ctx = manager.install(app);
ctx.start();
int sleepfor = 3000;
while ((acbl.success == null || acbl.success == false) && sleepfor > 0) {
Thread.sleep(100);
sleepfor -= 100;
}
assertNotNull("Timed out - didn't receive Blueprint CREATED or FAILURE event", acbl.success);
assertTrue("Received Blueprint FAILURE event", acbl.success);
ctx.stop();
manager.uninstall(ctx);
sr.unregister();
}
use of org.apache.aries.application.management.AriesApplication 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.aries.application.management.AriesApplication in project aries by apache.
the class IsolatedCfgAdminRuntimeTest method installApplication.
private Context installApplication(IDirectory application, String applicationName) throws Exception {
//install the application and start it
AriesApplicationManager appManager = context().getService(AriesApplicationManager.class);
AriesApplication app = appManager.createApplication(application);
AriesApplicationContext appCtx = appManager.install(app);
appCtx.start();
return new Context(appCtx, IsolationTestUtils.findIsolatedAppBundleContext(context(), applicationName));
}
Aggregations