private void install() throws Exception {
BundleContext bundleContext = bundle.getBundleContext();
AriesApplicationResolver resolver = null;
ServiceReference ref = bundleContext.getServiceReference(AriesApplicationResolver.class.getName());
if (ref != null) {
resolver = (AriesApplicationResolver) bundleContext.getService(ref);
}
if (resolver == null) {
throw new ManagementException("AriesApplicationResolver service not found");
}
DeploymentMetadata meta = application.getDeploymentMetadata();
List<DeploymentContent> bundlesToInstall = new ArrayList<DeploymentContent>();
bundlesToInstall.addAll(meta.getApplicationDeploymentContents());
bundlesToInstall.addAll(meta.getApplicationProvisionBundles());
applicationBundles = new HashSet<Bundle>();
try {
for (DeploymentContent content : bundlesToInstall) {
String bundleSymbolicName = content.getContentName();
Version bundleVersion = content.getExactVersion();
BundleInfo bundleInfo = null;
for (BundleInfo info : application.getBundleInfo()) {
if (info.getSymbolicName().equals(bundleSymbolicName)
&& info.getVersion().equals(bundleVersion)) {
bundleInfo = info;
break;
}
}
if (bundleInfo == null) {
// call out to the bundle repository.
bundleInfo = resolver.getBundleInfo(bundleSymbolicName, bundleVersion);
}
if (bundleInfo == null) {
throw new ManagementException("Cound not find bundles: " + bundleSymbolicName + "_" + bundleVersion);
}