You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by mn...@apache.org on 2010/09/16 11:46:09 UTC
svn commit: r997653 - in /incubator/aries/trunk/application:
application-api/src/main/java/org/apache/aries/application/
application-api/src/main/java/org/apache/aries/application/management/spi/resolve/
application-api/src/main/java/org/apache/aries/a...
Author: mnuttall
Date: Thu Sep 16 09:46:09 2010
New Revision: 997653
URL: http://svn.apache.org/viewvc?rev=997653&view=rev
Log:
ARIES-361: Further changes to the PostResolveTransformer.
Modified:
incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/PostResolveTransformer.java
incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/spi/resolve/DeploymentManifestManager.java
incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/modelling/DeployedBundles.java
incubator/aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java
incubator/aries/trunk/application/application-deployment-management/src/main/resources/OSGI-INF/blueprint/deployment-manager.xml
incubator/aries/trunk/application/application-deployment-management/src/main/resources/org/apache/aries/application/deployment/management/messages/DeploymentManagementMessages.properties
incubator/aries/trunk/application/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java
incubator/aries/trunk/application/application-management/src/test/java/org/apache/aries/application/management/impl/AriesApplicationManagerImplTest.java
incubator/aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/DeployedBundlesImpl.java
Modified: incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/PostResolveTransformer.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/PostResolveTransformer.java?rev=997653&r1=997652&r2=997653&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/PostResolveTransformer.java (original)
+++ incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/PostResolveTransformer.java Thu Sep 16 09:46:09 2010
@@ -18,20 +18,17 @@
*/
package org.apache.aries.application;
-import java.util.Collection;
-import java.util.Map;
-
import org.apache.aries.application.management.ResolverException;
-import org.apache.aries.application.modelling.ModelledResource;
+import org.apache.aries.application.modelling.DeployedBundles;
public interface PostResolveTransformer
{
/**
* This method is to perform any post process after the resolver returns back a collection of bundles. It returns the updated manifest map.
* @param bundles A collection of bundles required by this application.
- * @param deploymentHeaders the deployment manifest map
+ * @return Modified collection of bundles
* @throws ResolverException
*/
- void postResolveProcess(Collection<ModelledResource> bundles, Map<String, String> deploymentHeaders) throws ResolverException;
+ DeployedBundles postResolveProcess(DeployedBundles deployedBundles) throws ResolverException;
}
Modified: incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/spi/resolve/DeploymentManifestManager.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/spi/resolve/DeploymentManifestManager.java?rev=997653&r1=997652&r2=997653&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/spi/resolve/DeploymentManifestManager.java (original)
+++ incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/spi/resolve/DeploymentManifestManager.java Thu Sep 16 09:46:09 2010
@@ -26,6 +26,7 @@ import org.apache.aries.application.Serv
import org.apache.aries.application.management.AriesApplication;
import org.apache.aries.application.management.ResolveConstraint;
import org.apache.aries.application.management.ResolverException;
+import org.apache.aries.application.modelling.DeployedBundles;
import org.apache.aries.application.modelling.ModelledResource;
public interface DeploymentManifestManager
@@ -47,10 +48,10 @@ public interface DeploymentManifestManag
* @param useBundleSet Use Bundle set
* @param otherBundles Other bundles to be used to narrow the resolved bundles
* @param appImportServices the Application-ImportService header
- * @return the deployment manifest
+ * @return DeployedBundles model of the deployed application
* @throws ResolverException
*/
- Manifest generateDeploymentManifest(
+ DeployedBundles generateDeployedBundles(
String appName,
String appVersion,
Collection<Content> appContent,
@@ -60,6 +61,20 @@ public interface DeploymentManifestManag
Collection<ServiceDeclaration> appImportServices) throws ResolverException;
/**
+ * Generate a Manifest representation of a DEPLOYMENT.MF,
+ * suitable for example to writing to disk
+ * @param appSymbolicName
+ * @param appVersion
+ * @param deployedBundles Such as obtained from generateDeployedBundles()
+ * @return
+ * @throws ResolverException
+ */
+ Manifest generateDeploymentManifest (
+ String appSymbolicName,
+ String appVersion,
+ DeployedBundles deployedBundles) throws ResolverException;
+
+ /**
*
* @return the AriesApplicationResolver
*/
Modified: incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/modelling/DeployedBundles.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/modelling/DeployedBundles.java?rev=997653&r1=997652&r2=997653&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/modelling/DeployedBundles.java (original)
+++ incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/modelling/DeployedBundles.java Thu Sep 16 09:46:09 2010
@@ -21,6 +21,7 @@
package org.apache.aries.application.modelling;
import java.util.Collection;
+import java.util.Map;
import org.apache.aries.application.management.ResolverException;
@@ -91,4 +92,11 @@ public interface DeployedBundles {
* @throws ResolverException if the requirements could not be resolved.
*/
Collection<ModelledResource> getRequiredUseBundle() throws ResolverException;
+
+ /**
+ * A local environment extension to Apache Aries may manipulate a DeployedBundles object.
+ * This method returns the extra headers and their values.
+ * @return
+ */
+ Map<String, String> getExtraHeaders();
}
Modified: incubator/aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java?rev=997653&r1=997652&r2=997653&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java (original)
+++ incubator/aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java Thu Sep 16 09:46:09 2010
@@ -31,7 +31,6 @@ import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -70,6 +69,7 @@ import org.apache.aries.application.util
import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
+import org.osgi.service.blueprint.container.ServiceUnavailableException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -78,7 +78,7 @@ public class DeploymentManifestManagerIm
private Logger _logger = LoggerFactory.getLogger(DeploymentManifestManagerImpl.class);
private AriesApplicationResolver resolver;
- private List<PostResolveTransformer> postResolveTransformers;
+ private PostResolveTransformer postResolveTransformer = null;
private ModelledResourceManager modelledResourceManager;
private LocalPlatform localPlatform;
@@ -113,32 +113,21 @@ public class DeploymentManifestManagerIm
this.modelledResourceManager = modelledResourceManager;
}
+ @Override
public AriesApplicationResolver getResolver()
{
return resolver;
}
- public void setPostResolveTransformers(List<PostResolveTransformer> transformers) {
- postResolveTransformers = transformers;
+ public void setPostResolveTransformer(PostResolveTransformer transformer) {
+ postResolveTransformer = transformer;
}
+
public void setResolver(AriesApplicationResolver resolver)
{
this.resolver = resolver;
}
- /* Mutable state */
- private DeployedBundles deployedBundles;
- private Collection<ModelledResource> bundlesToBeProvisioned;
- private String importPackages;
- private Collection<ModelledResource> requiredUseBundle;
-
-
-
- public DeployedBundles getDeployedBundles() {
- return deployedBundles;
- }
-
-
/**
* Perform provisioning to work out the 'freeze dried list' of the eba
* @param app - Aries application
@@ -146,6 +135,7 @@ public class DeploymentManifestManagerIm
* @return manifest the generated deployment manifest
* @throws ResolverException
*/
+ @Override
public Manifest generateDeploymentManifest( AriesApplication app, ResolveConstraint... constraints ) throws ResolverException
{
@@ -172,9 +162,13 @@ public class DeploymentManifestManagerIm
Content content = ManifestHeaderProcessor.parseContent(constraint.getBundleName(), constraint.getVersionRange().toString());
restrictedReqs.add(content);
}
- Manifest man = generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+
+ DeployedBundles deployedBundles = generateDeployedBundles (appMetadata.getApplicationSymbolicName(),
appMetadata.getApplicationVersion().toString(), appMetadata.getApplicationContents(),
byValueBundles, useBundles, restrictedReqs, appMetadata.getApplicationImportServices());
+
+ Manifest man = generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+ appMetadata.getApplicationVersion().toString(), deployedBundles);
_logger.debug(LOG_EXIT, "generateDeploymentManifest", new Object[] {man});
return man;
}
@@ -187,7 +181,9 @@ public class DeploymentManifestManagerIm
* @return
* @throws ResolverException
*/
- public Manifest generateDeploymentManifest(
+ @Override
+ public DeployedBundles generateDeployedBundles
+ (
String appSymbolicName,
String appVersion,
Collection<Content> appContent,
@@ -196,10 +192,8 @@ public class DeploymentManifestManagerIm
Collection<Content> otherBundles,
Collection<ServiceDeclaration> applicationImportService) throws ResolverException {
- _logger.debug(LOG_ENTRY, "generateDeploymentManifest", new Object[]{appSymbolicName, appVersion,
+ _logger.debug(LOG_ENTRY, "generateDeployedBundles", new Object[]{appSymbolicName, appVersion,
appContent, provideByValueBundles,useBundleSet,otherBundles });
- Map<String, String> deploymentManifestMap = Collections.EMPTY_MAP;
-
Collection<Content> bundlesToResolve = new ArrayList<Content>();
Set<ImportedBundle> appContentIB = null;
Set<ImportedBundle> useBundleIB = null;
@@ -222,145 +216,149 @@ public class DeploymentManifestManagerIm
}
byValueBundles.add(fakeBundleResource);
String uniqueName = appSymbolicName + "_" + appVersion;
- deployedBundles = modellingHelper.createDeployedBundles(appSymbolicName, appContentIB, useBundleIB, Arrays.asList(fakeBundleResource));
- bundlesToBeProvisioned = resolver.resolve(
+
+ DeployedBundles deployedBundles = modellingHelper.createDeployedBundles(appSymbolicName, appContentIB, useBundleIB, Arrays.asList(fakeBundleResource));
+ Collection<ModelledResource> bundlesToBeProvisioned = resolver.resolve(
appSymbolicName, appVersion, byValueBundles, bundlesToResolve);
pruneFakeBundleFromResults (bundlesToBeProvisioned);
if (bundlesToBeProvisioned.isEmpty()) {
throw new ResolverException(MessageUtil.getMessage("EMPTY_DEPLOYMENT_CONTENT",uniqueName));
- } else {
+ }
+ 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);
+ pruneFakeBundleFromResults (bundlesToBeProvisioned);
for (ModelledResource rbm : bundlesToBeProvisioned)
{
deployedBundles.addBundle(rbm);
}
- 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);
- pruneFakeBundleFromResults (bundlesToBeProvisioned);
- 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<Content> requiredSharedBundles = new ArrayList<Content>();
- for (ModelledResource mr : sharedBundles) {
- String version = mr.getExportedBundle().getVersion();
- String exactVersion = "[" + version + "," + version + "]";
-
- Content ib = ManifestHeaderProcessor.parseContent(mr.getExportedBundle().getSymbolicName(),
- exactVersion);
- requiredSharedBundles.add(ib);
+ }
- }
- // This will throw a ResolverException if the shared content does not resolve
- Collection<ModelledResource> resolvedSharedBundles = resolver.resolve(appSymbolicName, appVersion
- , byValueBundles, requiredSharedBundles);
-
- List<String> differences = findDifferences (resolvedSharedBundles, sharedBundles);
- // If we have differences, it means that we have shared bundles trying to import packages
- // from isolated bundles. We need to build up the error message and throw a ResolverException
- if (!differences.isEmpty()) {
- StringBuilder msgs = new StringBuilder();
- List<String> unsatisfiedRequirements = new ArrayList<String>();
-
- Map<String, List<String>> isolatedBundles = new HashMap<String, List<String>>();
- // Find the isolated bundles and store all the packages that they export in a map.
- for (ModelledResource mr : resolvedSharedBundles) {
- String mrName = mr.getSymbolicName() + "_" + mr.getExportedBundle().getVersion();
- if (differences.contains(mrName)) {
- List<String> exportedPackages = new ArrayList<String>();
- isolatedBundles.put(mrName, exportedPackages);
- for (ExportedPackage ep : mr.getExportedPackages()) {
- exportedPackages.add(ep.getPackageName());
- }
+ // 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<Content> requiredSharedBundles = new ArrayList<Content>();
+ for (ModelledResource mr : sharedBundles) {
+ String version = mr.getExportedBundle().getVersion();
+ String exactVersion = "[" + version + "," + version + "]";
+
+ Content ib = ManifestHeaderProcessor.parseContent(mr.getExportedBundle().getSymbolicName(),
+ exactVersion);
+ requiredSharedBundles.add(ib);
+
+ }
+ // This will throw a ResolverException if the shared content does not resolve
+ Collection<ModelledResource> resolvedSharedBundles = resolver.resolve(appSymbolicName, appVersion
+ , byValueBundles, requiredSharedBundles);
+
+ List<String> differences = findDifferences (resolvedSharedBundles, sharedBundles);
+ // If we have differences, it means that we have shared bundles trying to import packages
+ // from isolated bundles. We need to build up the error message and throw a ResolverException
+ if (!differences.isEmpty()) {
+ StringBuilder msgs = new StringBuilder();
+ List<String> unsatisfiedRequirements = new ArrayList<String>();
+
+ Map<String, List<String>> isolatedBundles = new HashMap<String, List<String>>();
+ // Find the isolated bundles and store all the packages that they export in a map.
+ for (ModelledResource mr : resolvedSharedBundles) {
+ String mrName = mr.getSymbolicName() + "_" + mr.getExportedBundle().getVersion();
+ if (differences.contains(mrName)) {
+ List<String> exportedPackages = new ArrayList<String>();
+ isolatedBundles.put(mrName, exportedPackages);
+ for (ExportedPackage ep : mr.getExportedPackages()) {
+ exportedPackages.add(ep.getPackageName());
}
}
- // Now loop through the shared bundles, reading the imported packages, and find which ones
- // are exported from the isolated bundles.
- for (ModelledResource mr : resolvedSharedBundles) {
- String mrName = mr.getSymbolicName() + "_" + mr.getExportedBundle().getVersion();
- // if current reource isn't an isolated bundle check it's requirements
- if (!!! differences.contains(mrName)) {
- // Iterate through the imported packages of the current shared bundle.
- for (ImportedPackage ip : mr.getImportedPackages()) {
- String packageName = ip.getPackageName();
- List<String> bundlesExportingPackage = new ArrayList<String>();
- // Loop through each exported package of each isolated bundle, and if we
- // get a match store the info away.
- for (Map.Entry<String, List<String>> currBundle : isolatedBundles.entrySet()) {
-
- List<String> exportedPackages = currBundle.getValue();
- if (exportedPackages != null && exportedPackages.contains(packageName)) {
- bundlesExportingPackage.add(currBundle.getKey());
- }
+ }
+ // Now loop through the shared bundles, reading the imported packages, and find which ones
+ // are exported from the isolated bundles.
+ for (ModelledResource mr : resolvedSharedBundles) {
+ String mrName = mr.getSymbolicName() + "_" + mr.getExportedBundle().getVersion();
+ // if current reource isn't an isolated bundle check it's requirements
+ if (!!! differences.contains(mrName)) {
+ // Iterate through the imported packages of the current shared bundle.
+ for (ImportedPackage ip : mr.getImportedPackages()) {
+ String packageName = ip.getPackageName();
+ List<String> bundlesExportingPackage = new ArrayList<String>();
+ // Loop through each exported package of each isolated bundle, and if we
+ // get a match store the info away.
+ for (Map.Entry<String, List<String>> currBundle : isolatedBundles.entrySet()) {
+
+ List<String> exportedPackages = currBundle.getValue();
+ if (exportedPackages != null && exportedPackages.contains(packageName)) {
+ bundlesExportingPackage.add(currBundle.getKey());
}
- // If we have found at least one matching entry, we construct the sub message for the
- // exception.
- if (!!! bundlesExportingPackage.isEmpty()) {
- String newMsg;
- if (bundlesExportingPackage.size() > 1) {
- newMsg = MessageUtil.getMessage("SHARED_BUNDLE_IMPORTING_FROM_ISOLATED_BUNDLES",
- new Object[] {mrName, packageName, bundlesExportingPackage});
- } else {
- newMsg = MessageUtil.getMessage("SHARED_BUNDLE_IMPORTING_FROM_ISOLATED_BUNDLE",
- new Object[] {mrName, packageName, bundlesExportingPackage});
- }
- msgs.append("\n");
- msgs.append(newMsg);
- unsatisfiedRequirements.add(newMsg);
+ }
+ // If we have found at least one matching entry, we construct the sub message for the
+ // exception.
+ if (!!! bundlesExportingPackage.isEmpty()) {
+ String newMsg;
+ if (bundlesExportingPackage.size() > 1) {
+ newMsg = MessageUtil.getMessage("SHARED_BUNDLE_IMPORTING_FROM_ISOLATED_BUNDLES",
+ new Object[] {mrName, packageName, bundlesExportingPackage});
+ } else {
+ newMsg = MessageUtil.getMessage("SHARED_BUNDLE_IMPORTING_FROM_ISOLATED_BUNDLE",
+ new Object[] {mrName, packageName, bundlesExportingPackage});
}
+ msgs.append("\n");
+ msgs.append(newMsg);
+ unsatisfiedRequirements.add(newMsg);
}
}
}
- // Once we have iterated over all bundles and have got our translated submessages,
- // throw the exception.
- // Well! if the msgs is empty, no need to throw an exception
- if (msgs.length() !=0) {
- String message = MessageUtil.getMessage(
- "SUSPECTED_CIRCULAR_DEPENDENCIES", new Object[] {appSymbolicName, msgs});
- ResolverException rx = new ResolverException (message);
- rx.setUnsatisfiedRequirements(unsatisfiedRequirements);
- _logger.debug(LOG_EXIT, "generateDeploymentManifest", new Object[] {rx});
- throw (rx);
- }
}
-
- requiredUseBundle = deployedBundles.getRequiredUseBundle();
- importPackages = deployedBundles.getImportPackage();
- Collection<ModelledResource> requiredBundles = new HashSet<ModelledResource>();
- requiredBundles.addAll(deployedBundles.getDeployedContent());
- requiredBundles.addAll(deployedBundles.getRequiredUseBundle());
- requiredBundles.addAll(deployedBundles.getDeployedProvisionBundle());
- deploymentManifestMap = generateDeploymentAttributes(appSymbolicName, appVersion);
- // Perform some post process if there are any.
- if ((postResolveTransformers != null) && (!postResolveTransformers.isEmpty())) {
- // validate the contents
- for (PostResolveTransformer prt : postResolveTransformers) {
- prt.postResolveProcess(requiredBundles, deploymentManifestMap);
- }
+ // Once we have iterated over all bundles and have got our translated submessages,
+ // throw the exception.
+ // Well! if the msgs is empty, no need to throw an exception
+ if (msgs.length() !=0) {
+ String message = MessageUtil.getMessage(
+ "SUSPECTED_CIRCULAR_DEPENDENCIES", new Object[] {appSymbolicName, msgs});
+ ResolverException rx = new ResolverException (message);
+ rx.setUnsatisfiedRequirements(unsatisfiedRequirements);
+ _logger.debug(LOG_EXIT, "generateDeploymentManifest", new Object[] {rx});
+ throw (rx);
}
}
+
+ if (postResolveTransformer != null) try {
+ deployedBundles = postResolveTransformer.postResolveProcess (deployedBundles);
+ } catch (ServiceUnavailableException e) {
+ _logger.debug(MessageUtil.getMessage("POST_RESOLVE_TRANSFORMER_UNAVAILABLE",e));
+ }
+ return deployedBundles;
+ }
+
+
+ @Override
+ public Manifest generateDeploymentManifest(String appSymbolicName,
+ String appVersion, DeployedBundles deployedBundles)
+ throws ResolverException
+ {
+
+ _logger.debug (LOG_ENTRY, "generateDeploymentManifest",
+ new Object[]{appSymbolicName, appVersion, deployedBundles});
+ Map<String, String> deploymentManifestMap = generateDeploymentAttributes(appSymbolicName,
+ appVersion, deployedBundles);
Manifest man = convertMapToManifest(deploymentManifestMap);
- _logger.debug(LOG_EXIT, "generateDeploymentManifest", new Object[] {man});
+ _logger.debug (LOG_EXIT, "generateDeploymentManifest", man);
return man;
}
-
+
/**
* Returns a Collection of the {@link ImportedBundle} objects that are
* satisfied by the contents of the Collection of requiredUseBundles.
@@ -389,7 +387,8 @@ public class DeploymentManifestManagerIm
- private Map<String,String> generateDeploymentAttributes(String appSymbolicName, String version) throws ResolverException
+ private Map<String,String> generateDeploymentAttributes(String appSymbolicName, String version,
+ DeployedBundles deployedBundles) throws ResolverException
{
_logger.debug(LOG_ENTRY, "generateDeploymentAttributes", new Object[] {appSymbolicName, version});
Map<String,String> result = new HashMap<String, String>();
@@ -416,14 +415,17 @@ public class DeploymentManifestManagerIm
result.put(AppConstants.DEPLOYMENTSERVICE_IMPORT, importServices);
}
-
+ String importPackages = deployedBundles.getImportPackage();
if (!importPackages.isEmpty()) {
result.put(Constants.IMPORT_PACKAGE, importPackages);
}
result.put(AppConstants.APPLICATION_VERSION, version);
result.put(AppConstants.APPLICATION_SYMBOLIC_NAME, appSymbolicName);
- _logger.debug(LOG_ENTRY, "generateDeploymentAttributes", new Object[] {result});
+
+ result.putAll(deployedBundles.getExtraHeaders());
+
+ _logger.debug(LOG_EXIT, "generateDeploymentAttributes", result);
return result;
}
@@ -592,4 +594,5 @@ public class DeploymentManifestManagerIm
return result;
}
+
}
Modified: incubator/aries/trunk/application/application-deployment-management/src/main/resources/OSGI-INF/blueprint/deployment-manager.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-deployment-management/src/main/resources/OSGI-INF/blueprint/deployment-manager.xml?rev=997653&r1=997652&r2=997653&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-deployment-management/src/main/resources/OSGI-INF/blueprint/deployment-manager.xml (original)
+++ incubator/aries/trunk/application/application-deployment-management/src/main/resources/OSGI-INF/blueprint/deployment-manager.xml Thu Sep 16 09:46:09 2010
@@ -21,7 +21,7 @@
<bean id="deploymentManifestManager" class="org.apache.aries.application.deployment.management.impl.DeploymentManifestManagerImpl">
<property name="resolver" ref="resolver"/>
- <property name="postResolveTransformers" ref="post-resolver-transformers"/>
+ <property name="postResolveTransformer" ref="postResolveTransformer"/>
<property name="modelledResourceManager" ref = "modelledResourceManager"/>
<property name="localPlatform" ref="localPlatform"/>
<property name="modellingManager" ref="modellingManager"/>
@@ -30,10 +30,10 @@
<reference id="modellingManager" interface="org.apache.aries.application.modelling.ModellingManager"/>
<reference id="modellingHelper" interface="org.apache.aries.application.modelling.utils.ModellingHelper"/>
- <reference id = "modelledResourceManager" interface="org.apache.aries.application.modelling.ModelledResourceManager"/>
+ <reference id="modelledResourceManager" interface="org.apache.aries.application.modelling.ModelledResourceManager"/>
<reference id="localPlatform" interface="org.apache.aries.application.management.spi.runtime.LocalPlatform"/>
<reference id="resolver" interface="org.apache.aries.application.management.spi.resolve.AriesApplicationResolver"/>
- <reference-list id="post-resolver-transformers" interface="org.apache.aries.application.PostResolveTransformer" availability="optional"/>
+ <reference id="postResolveTransformer" interface="org.apache.aries.application.PostResolveTransformer" availability="optional"/>
<service id ="deploymentManifestManager-Service" ref="deploymentManifestManager" interface="org.apache.aries.application.management.spi.resolve.DeploymentManifestManager"/>
Modified: incubator/aries/trunk/application/application-deployment-management/src/main/resources/org/apache/aries/application/deployment/management/messages/DeploymentManagementMessages.properties
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-deployment-management/src/main/resources/org/apache/aries/application/deployment/management/messages/DeploymentManagementMessages.properties?rev=997653&r1=997652&r2=997653&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-deployment-management/src/main/resources/org/apache/aries/application/deployment/management/messages/DeploymentManagementMessages.properties (original)
+++ incubator/aries/trunk/application/application-deployment-management/src/main/resources/org/apache/aries/application/deployment/management/messages/DeploymentManagementMessages.properties Thu Sep 16 09:46:09 2010
@@ -21,3 +21,6 @@ SHARED_BUNDLE_IMPORTING_FROM_ISOLATED_BU
SUSPECTED_CIRCULAR_DEPENDENCIES=Resolution of asset {0} indicates invalid dependencies of shared content on isolated content: {1}
+
+EMPTY_DEPLOYMENT_CONTENT=Enterprise application {0} contains no content.
+POST_RESOLVE_TRANSFORMER_UNAVAILABLE=An instance of the PostResolveTransformer was injected earlier but is currently inaccessible. Exception: {0}
\ No newline at end of file
Modified: incubator/aries/trunk/application/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java?rev=997653&r1=997652&r2=997653&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java (original)
+++ incubator/aries/trunk/application/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java Thu Sep 16 09:46:09 2010
@@ -46,6 +46,7 @@ import org.apache.aries.application.mana
import org.apache.aries.application.management.ResolverException;
import org.apache.aries.application.management.spi.resolve.AriesApplicationResolver;
import org.apache.aries.application.management.spi.runtime.LocalPlatform;
+import org.apache.aries.application.modelling.DeployedBundles;
import org.apache.aries.application.modelling.ExportedPackage;
import org.apache.aries.application.modelling.ModelledResource;
import org.apache.aries.application.modelling.ModellingManager;
@@ -71,13 +72,14 @@ import org.osgi.framework.Version;
*/
public class DeploymentGeneratorTest
{
- private DeploymentManifestManagerImpl sut;
+ private DeploymentManifestManagerImpl deplMFMgr;
private AriesApplication app;
private ApplicationMetadata appMetadata;
private static class MockResolver implements AriesApplicationResolver {
boolean returnAppContentNextTime = true;
+ @Override
public Collection<ModelledResource> resolve(String appName, String appVersion,
Collection<ModelledResource> byValueBundles, Collection<Content> inputs)
throws ResolverException
@@ -183,11 +185,11 @@ public class DeploymentGeneratorTest
app = Skeleton.newMock(AriesApplication.class);
Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
- sut = new DeploymentManifestManagerImpl();
- sut.setResolver(_resolver);
- sut.setLocalPlatform(localPlatform);
- sut.setModellingManager(modellingManager);
- sut.setModellingHelper(modellingHelper);
+ deplMFMgr = new DeploymentManifestManagerImpl();
+ deplMFMgr.setResolver(_resolver);
+ deplMFMgr.setLocalPlatform(localPlatform);
+ deplMFMgr.setModellingManager(modellingManager);
+ deplMFMgr.setModellingHelper(modellingHelper);
}
private static ExportedPackage CAPABILITY_A;
@@ -238,11 +240,15 @@ public class DeploymentGeneratorTest
{
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getApplicationContents"), Arrays.asList(mockContent("aries.test.a", "1.0.0"), mockContent("aries.test.b", "[1.0.0, 2.0.0)" )));
- Manifest man = sut.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+
+
+ DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles (appMetadata.getApplicationSymbolicName(),
appMetadata.getApplicationVersion().toString(), appMetadata.getApplicationContents(),
new ArrayList<ModelledResource>(),
- Arrays.asList(BUNDLE_C, BUNDLE_D), Collections.<Content>emptyList(),
- appMetadata.getApplicationImportServices());
+ Arrays.asList(BUNDLE_C, BUNDLE_D), Collections.<Content>emptyList(), appMetadata.getApplicationImportServices());
+ Manifest man = deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+ appMetadata.getApplicationVersion().toString(), deployedBundles);
+
Attributes attrs = man.getMainAttributes();
assertEquals("aries.test", attrs.getValue(AppConstants.APPLICATION_SYMBOLIC_NAME));
@@ -284,12 +290,12 @@ public class DeploymentGeneratorTest
try {
-
- sut.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+ DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles (appMetadata.getApplicationSymbolicName(),
appMetadata.getApplicationVersion().toString(), appMetadata.getApplicationContents(),
- new ArrayList<ModelledResource>(), new ArrayList<Content>(),
- Collections.<Content>emptyList(),
- appMetadata.getApplicationImportServices());
+ new ArrayList<ModelledResource>(),
+ new ArrayList<Content>(), Collections.<Content>emptyList(), appMetadata.getApplicationImportServices());
+ deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+ appMetadata.getApplicationVersion().toString(), deployedBundles);
} catch (ResolverException rx) {
List<String> usr = rx.getUnsatisfiedRequirements();
assertEquals ("One unsatisfied requirement expected, not " + usr.size(), usr.size(), 1);
@@ -337,12 +343,12 @@ public class DeploymentGeneratorTest
Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
try {
- sut.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
- appMetadata.getApplicationVersion().toString(),
- appMetadata.getApplicationContents(),
- Arrays.asList(new ModelledResource[] {testIsolated1.getBundle(), testIsolated2.getBundle()}), new ArrayList<Content>(), Collections.<Content>emptyList(),
- appMetadata.getApplicationImportServices());
-
+ DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles (appMetadata.getApplicationSymbolicName(),
+ appMetadata.getApplicationVersion().toString(), appMetadata.getApplicationContents(),
+ Arrays.asList(new ModelledResource[] {testIsolated1.getBundle(), testIsolated2.getBundle()}),
+ new ArrayList<Content>(), Collections.<Content>emptyList(), appMetadata.getApplicationImportServices());
+ deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+ appMetadata.getApplicationVersion().toString(), deployedBundles);
} catch (ResolverException rx) {
// Get the unsatisfied Requirements
List<String> unsatisfiedReqs = rx.getUnsatisfiedRequirements();
Modified: incubator/aries/trunk/application/application-management/src/test/java/org/apache/aries/application/management/impl/AriesApplicationManagerImplTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/test/java/org/apache/aries/application/management/impl/AriesApplicationManagerImplTest.java?rev=997653&r1=997652&r2=997653&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-management/src/test/java/org/apache/aries/application/management/impl/AriesApplicationManagerImplTest.java (original)
+++ incubator/aries/trunk/application/application-management/src/test/java/org/apache/aries/application/management/impl/AriesApplicationManagerImplTest.java Thu Sep 16 09:46:09 2010
@@ -67,6 +67,7 @@ import org.apache.aries.application.mana
import org.apache.aries.application.management.spi.resolve.DeploymentManifestManager;
import org.apache.aries.application.management.spi.runtime.AriesApplicationContextManager;
import org.apache.aries.application.management.spi.runtime.LocalPlatform;
+import org.apache.aries.application.modelling.DeployedBundles;
import org.apache.aries.application.modelling.ModelledResource;
import org.apache.aries.application.utils.AppConstants;
import org.apache.aries.application.utils.filesystem.FileSystem;
@@ -145,8 +146,23 @@ public class AriesApplicationManagerImpl
throws ResolverException {
return null;
}
-
-
+
+ public DeployedBundles generateDeployedBundles(String appName,
+ String appVersion, Collection<Content> appContent,
+ Collection<ModelledResource> byValueBundles,
+ Collection<Content> useBundleSet, Collection<Content> otherBundles,
+ Collection<ServiceDeclaration> appImportServices)
+ throws ResolverException {
+ // Not required or used in this test
+ return null;
+ }
+
+ public Manifest generateDeploymentManifest(String appSymbolicName,
+ String appVersion, DeployedBundles deployedBundles)
+ throws ResolverException {
+ // Not required or used in this test
+ return null;
+ }
}
static class DummyResolver implements AriesApplicationResolver {
Modified: incubator/aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/DeployedBundlesImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/DeployedBundlesImpl.java?rev=997653&r1=997652&r2=997653&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/DeployedBundlesImpl.java (original)
+++ incubator/aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/DeployedBundlesImpl.java Thu Sep 16 09:46:09 2010
@@ -463,4 +463,15 @@ public final class DeployedBundlesImpl i
logger.debug(LOG_EXIT, "getRequiredUseBundle", usedUseBundles);
return usedUseBundles;
}
+
+ /** This method will be overridden by a PostResolveTransformer returning an extended version of
+ * DeployedBundles
+ */
+ @Override
+ public Map<String, String> getExtraHeaders() {
+ logger.debug (LOG_ENTRY, "getExtraHeaders");
+ Map<String, String> result = Collections.emptyMap();
+ logger.debug (LOG_EXIT, "getExtraHeaders", result);
+ return result;
+ }
}