Search in sources :

Example 6 with AriesApplicationContext

use of org.apache.aries.application.management.AriesApplicationContext in project aries by apache.

the class EBAInstaller method install.

public void install(File applicationLocation) throws Exception {
    AriesApplication app = applicationManager.createApplication(FileSystem.getFSRoot(applicationLocation));
    String appSymName = app.getApplicationMetadata().getApplicationSymbolicName();
    Version appVersion = app.getApplicationMetadata().getApplicationVersion();
    LOGGER.debug("created app from {} : {} {} with contents {}", new Object[] { applicationLocation.getName(), appSymName, appVersion, app.getApplicationMetadata().getApplicationContents() });
    AriesApplicationContext context = applicationManager.install(app);
    LOGGER.debug("installed app {} {} state: {}", new Object[] { appSymName, appVersion, context.getApplicationState() });
    context.start();
    LOGGER.debug("started app {} {} state: {}", new Object[] { appSymName, appVersion, context.getApplicationState() });
    // Store the application context away because it is the application context we need
    // to pass to the application manager if we're later asked to uninstall the application
    appContexts.put(applicationLocation, context);
}
Also used : Version(org.osgi.framework.Version) AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplication(org.apache.aries.application.management.AriesApplication)

Example 7 with AriesApplicationContext

use of org.apache.aries.application.management.AriesApplicationContext in project aries by apache.

the class BasicAppManagerTest method testAppWithApplicationManifest.

@Test
public void testAppWithApplicationManifest() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
    // application name should equal to whatever Application name provided in the application.mf
    assertEquals("test application 2", app.getApplicationMetadata().getApplicationName());
    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);
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) File(java.io.File) HelloWorld(org.apache.aries.sample.HelloWorld) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 8 with AriesApplicationContext

use of org.apache.aries.application.management.AriesApplicationContext in project aries by apache.

the class IsolatedRuntimeTest method testAppWithGlobalRepositoryBundle.

@Test
@Ignore
public void testAppWithGlobalRepositoryBundle() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
    IsolationTestUtils.prepareSampleBundleV2(bundleContext, context().getService(RepositoryGenerator.class), context().getService(RepositoryAdmin.class), context().getService(ModellingManager.class));
    AriesApplication newApp = manager.resolve(app, new ResolveConstraint() {

        @Override
        public String getBundleName() {
            return "org.apache.aries.isolated.sample";
        }

        @Override
        public VersionRange getVersionRange() {
            return ManifestHeaderProcessor.parseVersionRange("[2.0.0,2.0.0]", true);
        }
    });
    AriesApplicationContext ctx = manager.install(newApp);
    ctx.start();
    assertHelloWorldService("org.apache.aries.sample2", "hello brave new world");
    manager.uninstall(ctx);
}
Also used : RepositoryGenerator(org.apache.aries.application.management.spi.repository.RepositoryGenerator) RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) ResolveConstraint(org.apache.aries.application.management.ResolveConstraint) AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) ModellingManager(org.apache.aries.application.modelling.ModellingManager) VersionRange(org.apache.aries.util.VersionRange) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 9 with AriesApplicationContext

use of org.apache.aries.application.management.AriesApplicationContext in project aries by apache.

the class IsolatedRuntimeTest method testAppWithApplicationManifest.

@Test
@Ignore
public void testAppWithApplicationManifest() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
    assertHelloWorldService("org.apache.aries.sample2");
    manager.uninstall(ctx);
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 10 with AriesApplicationContext

use of org.apache.aries.application.management.AriesApplicationContext in project aries by apache.

the class IsolatedRuntimeTest method testAppWithFragment.

@Test
@Ignore
public void testAppWithFragment() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("withFragment.eba")));
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
    assertHelloWorldService("withFragment.eba");
    manager.uninstall(ctx);
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Aggregations

AriesApplicationContext (org.apache.aries.application.management.AriesApplicationContext)34 AriesApplication (org.apache.aries.application.management.AriesApplication)24 Test (org.junit.Test)23 AriesApplicationManager (org.apache.aries.application.management.AriesApplicationManager)19 File (java.io.File)18 AbstractIntegrationTest (org.apache.aries.itest.AbstractIntegrationTest)18 HelloWorld (org.apache.aries.sample.HelloWorld)7 Ignore (org.junit.Ignore)7 DeploymentMetadata (org.apache.aries.application.DeploymentMetadata)6 RepositoryAdmin (org.apache.felix.bundlerepository.RepositoryAdmin)6 ArrayList (java.util.ArrayList)5 Repository (org.apache.felix.bundlerepository.Repository)5 UpdateException (org.apache.aries.application.management.UpdateException)4 MavenArtifactUrlReference (org.ops4j.pax.exam.options.MavenArtifactUrlReference)4 Bundle (org.osgi.framework.Bundle)4 URL (java.net.URL)3 DeploymentContent (org.apache.aries.application.DeploymentContent)3 BundleException (org.osgi.framework.BundleException)3 AriesApplicationContextManager (org.apache.aries.application.management.spi.runtime.AriesApplicationContextManager)2 MethodCall (org.apache.aries.unittest.mocks.MethodCall)2