use of org.apache.aries.application.management.AriesApplicationContext in project aries by apache.
the class JdbcBlogSampleWithEbaTest method test.
@Test
public void test() throws Exception {
MavenArtifactUrlReference eba = maven().groupId("org.apache.aries.samples.blog").artifactId("org.apache.aries.samples.blog.jdbc.eba").versionAsInProject().type("eba");
AriesApplicationContext ctx = installEba(eba);
/* Check that the Blog Sample bundles are present an started */
assertBundleStarted("org.apache.aries.samples.blog.api");
assertBundleStarted("org.apache.aries.samples.blog.web");
assertBundleStarted("org.apache.aries.samples.blog.biz");
assertBundleStarted("org.apache.aries.samples.blog.persistence.jdbc");
assertBlogServicesStarted();
checkBlogWebAccess();
ctx.stop();
manager.uninstall(ctx);
}
use of org.apache.aries.application.management.AriesApplicationContext in project aries by apache.
the class JpaBlogSampleWithEbaTest method test.
@Test
public void test() throws Exception {
MavenArtifactUrlReference eba = maven().groupId("org.apache.aries.samples.blog").artifactId("org.apache.aries.samples.blog.jpa.eba").versionAsInProject().type("eba");
AriesApplicationContext ctx = installEba(eba);
/* Find and check all the blog sample bundles */
assertBundleStarted("org.apache.aries.samples.blog.api");
assertBundleStarted("org.apache.aries.samples.blog.web");
assertBundleStarted("org.apache.aries.samples.blog.biz");
assertBundleStarted("org.apache.aries.samples.blog.persistence.jpa");
assertBundleStarted("org.apache.aries.samples.blog.datasource");
assertBundleStarted("org.apache.aries.transaction.manager");
assertBlogServicesStarted();
checkBlogWebAccess();
ctx.stop();
manager.uninstall(ctx);
}
use of org.apache.aries.application.management.AriesApplicationContext in project aries by apache.
the class UpdateAppTest method testUpdateThenStart.
@Test
@Ignore
public void testUpdateThenStart() throws Exception {
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
AriesApplicationContext ctx = manager.install(app);
app = ctx.getApplication();
BundleContext oldCtx = IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, SAMPLE_APP_NAME);
installMockUpdateStrategy();
ctx = updateApp(manager, app);
BundleContext newCtx = IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, SAMPLE_APP_NAME);
assertNull("App is not started yet but HelloWorld service is already there", IsolationTestUtils.findHelloWorldService(bundleContext, SAMPLE_APP_NAME));
ctx.start();
assertAppMessage("hello brave new world");
assertTrue("We bounced the app where the update was supposed to do an update in place", oldCtx == newCtx);
}
use of org.apache.aries.application.management.AriesApplicationContext in project aries by apache.
the class UpdateAppTest method setupApp.
private AriesApplication setupApp() throws Exception {
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
AriesApplicationContext ctx = manager.install(app);
app = ctx.getApplication();
ctx.start();
assertAppMessage("hello world");
return app;
}
use of org.apache.aries.application.management.AriesApplicationContext in project aries by apache.
the class AriesApplicationManagerImpl method install.
public AriesApplicationContext install(AriesApplication app) throws BundleException, ManagementException, ResolverException {
if (!app.isResolved()) {
app = resolve(app);
}
// Register an Application Repository for this application if none exists
String appScope = app.getApplicationMetadata().getApplicationScope();
ServiceReference[] ref = null;
try {
String filter = "(" + BundleRepository.REPOSITORY_SCOPE + "=" + appScope + ")";
ref = _bundleContext.getServiceReferences(BundleRepository.class.getName(), filter);
} catch (InvalidSyntaxException e) {
// Something went wrong attempting to find a service so we will act as if
// there is no existing service.
}
if (ref == null || ref.length == 0) {
Dictionary dict = new Hashtable();
dict.put(BundleRepository.REPOSITORY_SCOPE, appScope);
ServiceRegistration serviceReg = _bundleContext.registerService(BundleRepository.class.getName(), new ApplicationRepository(app), dict);
serviceRegistrations.put(app, serviceReg);
}
AriesApplicationContext result = _applicationContextManager.getApplicationContext(app);
// When installing bundles in the .eba file we use the jar url scheme. This results in a
// JarFile being held open, which is bad as on windows we cannot delete the .eba file
// so as a work around we open a url connection to one of the bundles in the eba and
// if it is a jar url we close the associated JarFile.
Iterator<BundleInfo> bi = app.getBundleInfo().iterator();
if (bi.hasNext()) {
String location = bi.next().getLocation();
if (location.startsWith("jar")) {
try {
URL url = new URL(location);
JarURLConnection urlc = (JarURLConnection) url.openConnection();
// Make sure that we pick up the cached version rather than creating a new one
urlc.setUseCaches(true);
urlc.getJarFile().close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return result;
}
Aggregations