String appSymbolicName = appMetadata.getApplicationSymbolicName();
String appVersion = appMetadata.getApplicationVersion().toString();
String uniqueName = appSymbolicName + "_" + appVersion;
DeployedBundles deployedBundles = modellingHelper.createDeployedBundles(appSymbolicName, appContentIB, useBundleIB, Arrays.asList(fakeBundleResource));
Collection<ModelledResource> bundlesToBeProvisioned = resolver.resolve(
appSymbolicName, appVersion, byValueBundles, bundlesToResolve);
pruneFakeBundlesFromResults (bundlesToBeProvisioned, fakeResources);
if (bundlesToBeProvisioned.isEmpty()) {
throw new ResolverException(MessageUtil.getMessage("EMPTY_DEPLOYMENT_CONTENT",uniqueName));
}
for (ModelledResource rbm : bundlesToBeProvisioned)
{
deployedBundles.addBundle(rbm);
}
Collection<ModelledResource> requiredUseBundle = deployedBundles.getRequiredUseBundle();
if (requiredUseBundle.size() < useBundleSet.size())
{
// Some of the use-bundle entries were redundant so resolve again with just the good ones.
deployedBundles = modellingHelper.createDeployedBundles(appSymbolicName, appContentIB, useBundleIB, Arrays.asList(fakeBundleResource));
bundlesToResolve.clear();
bundlesToResolve.addAll(appContent);
Collection<ImportedBundle> slimmedDownUseBundle = narrowUseBundles(useBundleIB, requiredUseBundle);
bundlesToResolve.addAll(toContent(slimmedDownUseBundle));
bundlesToBeProvisioned = resolver.resolve(appSymbolicName, appVersion,
byValueBundles, bundlesToResolve);
pruneFakeBundlesFromResults (bundlesToBeProvisioned, fakeResources);
for (ModelledResource rbm : bundlesToBeProvisioned)
{
deployedBundles.addBundle(rbm);
}
}
// Check for circular dependencies. No shared bundle can depend on any
// isolated bundle.
Collection<ModelledResource> sharedBundles = new HashSet<ModelledResource>();
sharedBundles.addAll (deployedBundles.getDeployedProvisionBundle());
sharedBundles.addAll (deployedBundles.getRequiredUseBundle());
Collection<ModelledResource> appContentBundles = deployedBundles.getDeployedContent();
Collection<Content> requiredSharedBundles = new ArrayList<Content>();
for (ModelledResource mr : sharedBundles) {
String version = mr.getExportedBundle().getVersion();
String exactVersion = "[" + version + "," + version + "]";