use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class UpdateAppTest method testFullUpdate.
@Test
@Ignore
public void testFullUpdate() throws Exception {
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = setupApp();
updateApp(manager, app);
assertAppMessage("hello brave new world");
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class BundleFrameworkManagerImpl method updateBundles.
public void updateBundles(final DeploymentMetadata newMetadata, final DeploymentMetadata oldMetadata, final AriesApplication app, final BundleLocator locator, final Set<Bundle> bundles, final boolean startBundles) throws UpdateException {
UpdateStrategy strategy = null;
for (UpdateStrategy us : _updateStrategies) {
if (us.allowsUpdate(newMetadata, oldMetadata)) {
strategy = us;
break;
}
}
if (strategy == null)
throw new IllegalArgumentException("No UpdateStrategy supports the supplied DeploymentMetadata changes.");
synchronized (BundleFrameworkManager.SHARED_FRAMEWORK_LOCK) {
final BundleFramework appFwk = _frameworksByAppScope.get(app.getApplicationMetadata().getApplicationScope());
strategy.update(new UpdateStrategy.UpdateInfo() {
public void register(Bundle bundle) {
bundles.add(bundle);
}
public void unregister(Bundle bundle) {
bundles.remove(bundle);
}
public Map<DeploymentContent, BundleSuggestion> suggestBundle(Collection<DeploymentContent> bundles) throws BundleException {
return locator.suggestBundle(bundles);
}
public boolean startBundles() {
return startBundles;
}
public BundleFramework getSharedFramework() {
return _sharedBundleFramework;
}
public DeploymentMetadata getOldMetadata() {
return oldMetadata;
}
public DeploymentMetadata getNewMetadata() {
return newMetadata;
}
public AriesApplication getApplication() {
return app;
}
public BundleFramework getAppFramework() {
return appFwk;
}
});
}
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class BundleFrameworkManagerTest method testFailedInstall.
@Test
public void testFailedInstall() throws Exception {
/*
* Mock up a failing framework install
*/
BundleFramework fwk = Skeleton.newMock(new Object() {
public Bundle install(BundleSuggestion suggestion, AriesApplication app) throws BundleException {
throw new BundleException("Expected failure");
}
}, BundleFramework.class);
frameworkFactory.setReturnValue(new MethodCall(BundleFrameworkFactory.class, "createBundleFramework", BundleContext.class, BundleFrameworkConfiguration.class), fwk);
try {
sut.installIsolatedBundles(Arrays.asList(Skeleton.newMock(BundleSuggestion.class)), Skeleton.newMock(AriesApplication.class));
fail("Expected a BundleException");
} catch (BundleException be) {
// when a failure occurred we need to have cleaned up the new framework, otherwise it is
// left as floating debris
Skeleton.getSkeleton(fwk).assertCalled(new MethodCall(BundleFramework.class, "close"));
}
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class IsolatedRuntimeTest method testFrameworkResolvedBeforeInnerBundlesStart.
@Test
@Ignore
public void testFrameworkResolvedBeforeInnerBundlesStart() throws Exception {
/*
* Lazy bundles have in the past triggered recursive bundle trackers to handle them before
* the composite bundle framework was even resolved. In such a case the below loadClass
* operation on a class that depends on a class imported from the outside of the composite
* will fail with an NPE.
*/
final AtomicBoolean loadedClass = new AtomicBoolean(false);
context().addBundleListener(new SynchronousBundleListener() {
public void bundleChanged(BundleEvent event) {
Bundle b = event.getBundle();
if (event.getType() == BundleEvent.STARTING || event.getType() == BundleEvent.LAZY_ACTIVATION) {
if (b.getEntry("org/apache/aries/isolated/sample/SharedImpl.class") != null) {
try {
Class<?> cl = b.loadClass("org.apache.aries.isolated.sample.SharedImpl");
cl.newInstance();
loadedClass.set(true);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
} else if (event.getType() == BundleEvent.INSTALLED && b instanceof CompositeBundle) {
((CompositeBundle) b).getCompositeFramework().getBundleContext().addBundleListener(this);
}
}
});
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
AriesApplicationContext ctx = manager.install(app);
try {
ctx.start();
app = ctx.getApplication();
assertEquals(1, app.getDeploymentMetadata().getApplicationDeploymentContents().size());
assertEquals(1, app.getDeploymentMetadata().getApplicationProvisionBundles().size());
assertTrue(loadedClass.get());
} finally {
manager.uninstall(ctx);
}
}
use of org.apache.aries.application.management.AriesApplication 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);
}
Aggregations