You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cw...@apache.org on 2013/05/17 17:14:04 UTC
svn commit: r1483849 - in /aries/trunk/application:
application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/
application-modeller/src/main/java/org/apache/aries/application/modelling/impl/
Author: cwilkin
Date: Fri May 17 15:14:04 2013
New Revision: 1483849
URL: http://svn.apache.org/r1483849
Log:
ARIES-1071 Modelling performance improvements
Modified:
aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java
aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/DeployedBundlesImpl.java
Modified: aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java?rev=1483849&r1=1483848&r2=1483849&view=diff
==============================================================================
--- aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java (original)
+++ aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java Fri May 17 15:14:04 2013
@@ -248,13 +248,15 @@ public class DeploymentManifestManagerIm
{
deployedBundles.addBundle(rbm);
}
+
+ requiredUseBundle = deployedBundles.getRequiredUseBundle();
}
// 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());
+ sharedBundles.addAll (requiredUseBundle);
Collection<ModelledResource> appContentBundles = deployedBundles.getDeployedContent();
Collection<Content> requiredSharedBundles = new ArrayList<Content>();
Modified: aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/DeployedBundlesImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/DeployedBundlesImpl.java?rev=1483849&r1=1483848&r2=1483849&view=diff
==============================================================================
--- aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/DeployedBundlesImpl.java (original)
+++ aries/trunk/application/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/DeployedBundlesImpl.java Fri May 17 15:14:04 2013
@@ -56,6 +56,11 @@ public final class DeployedBundlesImpl i
{
private final Logger logger = LoggerFactory.getLogger(DeployedBundlesImpl.class);
private final String assetName;
+
+ private String cachedImportPackage;
+ private Collection<ModelledResource> cachedRequiredUseBundle;
+ private Collection<ImportedPackage> cachedExternalRequirements;
+ private String cachedDeployedImportService;
/** Content from APPLICATION.MF */
private final Set<ImportedBundle> appContent = new HashSet<ImportedBundle>();
@@ -128,6 +133,13 @@ public final class DeployedBundlesImpl i
logger.debug("Added to " + AppConstants.DEPLOYMENT_PROVISION_BUNDLE + ": " + resolvedBundle);
deployedProvisionBundle.add(modelledBundle);
}
+
+ // Invalidate caches
+ cachedImportPackage = null;
+ cachedRequiredUseBundle = null;
+ cachedDeployedImportService = null;
+ cachedExternalRequirements = null;
+
logger.debug(LOG_EXIT, "addBundle");
}
@@ -189,39 +201,47 @@ public final class DeployedBundlesImpl i
public String getImportPackage() throws ResolverException
{
logger.debug(LOG_ENTRY, "getImportPackage");
- Collection<ImportedPackage> externalReqs = new ArrayList<ImportedPackage>(getExternalPackageRequirements());
-
- //Validate that we don't have attributes that will break until RFC138 is used
- validateOtherImports(externalReqs);
- // Find the matching capabilities from bundles in use bundle, and prune
- // matched requirements out of the external requirements collection.
- Map<ImportedPackage,ExportedPackage> useBundlePkgs = new HashMap<ImportedPackage,ExportedPackage>();
- for (Iterator<ImportedPackage> iter = externalReqs.iterator(); iter.hasNext(); )
- {
- ImportedPackage req = iter.next();
- ExportedPackage match = getPackageMatch(req, deployedUseBundle);
- if (match != null)
+ String result = cachedImportPackage;
+ if (result == null)
+ {
+
+ Collection<ImportedPackage> externalReqs = new ArrayList<ImportedPackage>(getExternalPackageRequirements());
+
+ //Validate that we don't have attributes that will break until RFC138 is used
+ validateOtherImports(externalReqs);
+
+ // Find the matching capabilities from bundles in use bundle, and prune
+ // matched requirements out of the external requirements collection.
+ Map<ImportedPackage,ExportedPackage> useBundlePkgs = new HashMap<ImportedPackage,ExportedPackage>();
+ for (Iterator<ImportedPackage> iter = externalReqs.iterator(); iter.hasNext(); )
{
- useBundlePkgs.put(req, match);
- iter.remove();
+ ImportedPackage req = iter.next();
+ ExportedPackage match = getPackageMatch(req, deployedUseBundle);
+ if (match != null)
+ {
+ useBundlePkgs.put(req, match);
+ iter.remove();
+ }
}
+
+ StringBuilder useBundleImports = new StringBuilder();
+ for(Map.Entry<ImportedPackage, ExportedPackage> entry : useBundlePkgs.entrySet()) {
+ useBundleImports.append(entry.getValue().toDeploymentString());
+ ImportedPackage key = entry.getKey();
+ if(key.isOptional())
+ useBundleImports.append(";" + Constants.RESOLUTION_DIRECTIVE +":=" + Constants.RESOLUTION_OPTIONAL);
+ useBundleImports.append(",");
+ }
+
+ result = useBundleImports.toString() + createManifestString(externalReqs);
+
+ if(result.endsWith(","))
+ result = result.substring(0, result.length() - 1);
+
+ cachedImportPackage = result;
}
-
- StringBuilder useBundleImports = new StringBuilder();
- for(Map.Entry<ImportedPackage, ExportedPackage> entry : useBundlePkgs.entrySet()) {
- useBundleImports.append(entry.getValue().toDeploymentString());
- ImportedPackage key = entry.getKey();
- if(key.isOptional())
- useBundleImports.append(";" + Constants.RESOLUTION_DIRECTIVE +":=" + Constants.RESOLUTION_OPTIONAL);
- useBundleImports.append(",");
- }
-
- String result = useBundleImports.toString() + createManifestString(externalReqs);
-
- if(result.endsWith(","))
- result = result.substring(0, result.length() - 1);
logger.debug(LOG_EXIT, "getImportPackage", result);
return result;
}
@@ -237,31 +257,37 @@ public final class DeployedBundlesImpl i
*/
public String getDeployedImportService() {
logger.debug(LOG_ENTRY,"getDeployedImportService");
- Collection<ImportedService> deployedBundleServiceImports = new ArrayList<ImportedService>();
- Collection<ExportedService> servicesExportedWithinIsolatedContent = new ArrayList<ExportedService>();
- for (ModelledResource mRes : getDeployedContent()) {
- servicesExportedWithinIsolatedContent.addAll(mRes.getExportedServices());
- }
- for (ModelledResource mRes : fakeDeployedBundles) {
- servicesExportedWithinIsolatedContent.addAll(mRes.getExportedServices());
- }
- for (ImportedService impService : deployedImportService) {
- if (impService.isMultiple()) {
- deployedBundleServiceImports.add(impService);
- } else {
- boolean serviceProvidedWithinIsolatedContent = false;
- Iterator<ExportedService> it = servicesExportedWithinIsolatedContent.iterator();
- while (!serviceProvidedWithinIsolatedContent && it.hasNext()) {
- ExportedService svc = it.next();
- serviceProvidedWithinIsolatedContent |= impService.isSatisfied(svc);
- }
- if (!serviceProvidedWithinIsolatedContent) {
+
+ String result = cachedDeployedImportService;
+ if (result == null)
+ {
+ Collection<ImportedService> deployedBundleServiceImports = new ArrayList<ImportedService>();
+ Collection<ExportedService> servicesExportedWithinIsolatedContent = new ArrayList<ExportedService>();
+ for (ModelledResource mRes : getDeployedContent()) {
+ servicesExportedWithinIsolatedContent.addAll(mRes.getExportedServices());
+ }
+ for (ModelledResource mRes : fakeDeployedBundles) {
+ servicesExportedWithinIsolatedContent.addAll(mRes.getExportedServices());
+ }
+ for (ImportedService impService : deployedImportService) {
+ if (impService.isMultiple()) {
deployedBundleServiceImports.add(impService);
+ } else {
+ boolean serviceProvidedWithinIsolatedContent = false;
+ Iterator<ExportedService> it = servicesExportedWithinIsolatedContent.iterator();
+ while (!serviceProvidedWithinIsolatedContent && it.hasNext()) {
+ ExportedService svc = it.next();
+ serviceProvidedWithinIsolatedContent |= impService.isSatisfied(svc);
+ }
+ if (!serviceProvidedWithinIsolatedContent) {
+ deployedBundleServiceImports.add(impService);
+ }
}
}
+
+ result = createManifestString(deployedBundleServiceImports);
+ cachedDeployedImportService = result;
}
-
- String result = createManifestString(deployedBundleServiceImports);
logger.debug(LOG_EXIT,"getDeployedImportService", result);
return result;
@@ -277,48 +303,61 @@ public final class DeployedBundlesImpl i
{
logger.debug(LOG_ENTRY,"getExternalPackageRequirements");
- // Get all the internal requirements.
- Collection<ImportedPackage> requirements = new ArrayList<ImportedPackage>();
- for (ModelledResource bundle : deployedContent)
- {
- requirements.addAll(bundle.getImportedPackages());
- }
-
- // Filter out requirements satisfied by internal capabilities.
- Collection<ImportedPackage> result = new ArrayList<ImportedPackage>();
- for (ImportedPackage req : requirements)
+ Collection<ImportedPackage> result = cachedExternalRequirements;
+ if (result == null)
{
- ExportedPackage match = getPackageMatch(req, deployedContent);
- //If we didn't find a match then it must come from outside
- if (match == null)
+ // Get all the internal requirements.
+ Collection<ImportedPackage> requirements = new ArrayList<ImportedPackage>();
+ Collection<ExportedPackage> internalExports = new ArrayList<ExportedPackage>();
+ for (ModelledResource bundle : deployedContent)
{
- result.add(req);
+ requirements.addAll(bundle.getImportedPackages());
+ internalExports.addAll(bundle.getExportedPackages());
+ }
+
+ // Filter out requirements satisfied by internal capabilities.
+ result = new ArrayList<ImportedPackage>();
+ for (ImportedPackage req : requirements)
+ {
+ boolean satisfied = false;
+ for (ExportedPackage export : internalExports)
+ {
+ if (req.isSatisfied(export))
+ {
+ satisfied = true;
+ break;
+ }
+ }
+ //If we didn't find a match then it must come from outside
+ if (!satisfied)
+ result.add(req);
}
- }
-
- PackageRequirementMerger merger = new PackageRequirementMerger(result);
- if (!merger.isMergeSuccessful())
- {
- List<String> pkgNames = new ArrayList<String>(merger.getInvalidRequirements());
- StringBuilder buff = new StringBuilder();
- for (String pkgName : merger.getInvalidRequirements())
+ PackageRequirementMerger merger = new PackageRequirementMerger(result);
+ if (!merger.isMergeSuccessful())
{
- buff.append(pkgName).append(", ");
+ List<String> pkgNames = new ArrayList<String>(merger.getInvalidRequirements());
+
+ StringBuilder buff = new StringBuilder();
+ for (String pkgName : merger.getInvalidRequirements())
+ {
+ buff.append(pkgName).append(", ");
+ }
+
+ int buffLen = buff.length();
+ String pkgString = (buffLen > 0 ? buff.substring(0, buffLen - 2) : "");
+
+ ResolverException re = new ResolverException(MessageUtil.getMessage(
+ "INCOMPATIBLE_PACKAGE_VERSION_REQUIREMENTS", new Object[] { assetName, pkgString }));
+ re.setUnsatisfiedRequirements(pkgNames);
+ logger.debug(LOG_EXIT,"getExternalPackageRequirements", re);
+
+ throw re;
}
-
- int buffLen = buff.length();
- String pkgString = (buffLen > 0 ? buff.substring(0, buffLen - 2) : "");
-
- ResolverException re = new ResolverException(MessageUtil.getMessage(
- "INCOMPATIBLE_PACKAGE_VERSION_REQUIREMENTS", new Object[] { assetName, pkgString }));
- re.setUnsatisfiedRequirements(pkgNames);
- logger.debug(LOG_EXIT,"getExternalPackageRequirements", re);
- throw re;
+ result = merger.getMergedRequirements();
+ cachedExternalRequirements = result;
}
-
- result = merger.getMergedRequirements();
logger.debug(LOG_EXIT,"getExternalPackageRequirements", result);
return result;
@@ -440,17 +479,24 @@ public final class DeployedBundlesImpl i
public Collection<ModelledResource> getRequiredUseBundle() throws ResolverException
{
logger.debug(LOG_ENTRY, "getRequiredUseBundle");
- Collection<ImportedPackage> externalReqs = getExternalPackageRequirements();
- Collection<ModelledResource> usedUseBundles = new HashSet<ModelledResource>();
- for (ImportedPackage req : externalReqs)
- {
- // Find a match from the supplied bundle capabilities.
- ExportedPackage match = getPackageMatch(req, deployedUseBundle);
- if (match != null)
+
+ Collection<ModelledResource> usedUseBundles = cachedRequiredUseBundle;
+ if (usedUseBundles == null)
+ {
+ Collection<ImportedPackage> externalReqs = getExternalPackageRequirements();
+ usedUseBundles = new HashSet<ModelledResource>();
+ for (ImportedPackage req : externalReqs)
{
- usedUseBundles.add(match.getBundle());
+ // Find a match from the supplied bundle capabilities.
+ ExportedPackage match = getPackageMatch(req, deployedUseBundle);
+ if (match != null)
+ {
+ usedUseBundles.add(match.getBundle());
+ }
}
+ cachedRequiredUseBundle = usedUseBundles;
}
+
logger.debug(LOG_EXIT, "getRequiredUseBundle", usedUseBundles);
return usedUseBundles;
}