incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mnutt...@apache.org
Subject svn commit: r897013 - in /incubator/aries/trunk/application: application-management/src/main/java/org/apache/aries/application/management/impl/ application-utils/src/main/java/org/apache/aries/application/impl/ application-utils/src/main/java/org/apach...
Date Thu, 07 Jan 2010 21:11:19 GMT
Author: mnuttall
Date: Thu Jan  7 21:10:47 2010
New Revision: 897013

URL: http://svn.apache.org/viewvc?rev=897013&view=rev
Log:
ARIES-89: Implement application support: fix build break - sorry about that

Modified:
    incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ApplicationMetadataImpl.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java

Modified: incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java?rev=897013&r1=897012&r2=897013&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
(original)
+++ incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
Thu Jan  7 21:10:47 2010
@@ -47,7 +47,6 @@
   private LocalPlatform _localPlatform;
   
   // Placeholders for information we'll need for store()
-  private boolean _applicationManifestChanged = false;
   private Map<String, InputStream> _modifiedBundles = null;
   
   public AriesApplicationImpl(ApplicationMetadata meta, Set<BundleInfo> bundleInfo,

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ApplicationMetadataImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ApplicationMetadataImpl.java?rev=897013&r1=897012&r2=897013&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ApplicationMetadataImpl.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ApplicationMetadataImpl.java
Thu Jan  7 21:10:47 2010
@@ -19,6 +19,8 @@
 package org.apache.aries.application.impl;
 
 import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -30,13 +32,12 @@
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 
-import org.osgi.framework.Version;
-
 import org.apache.aries.application.ApplicationMetadata;
 import org.apache.aries.application.Content;
 import org.apache.aries.application.ServiceDeclaration;
 import org.apache.aries.application.utils.AppConstants;
 import org.apache.aries.application.utils.manifest.ManifestProcessor;
+import org.osgi.framework.Version;
 
 /**
  * Implementation of ApplicationMetadata and DeploymentMetadata
@@ -51,6 +52,7 @@
   private List<Content> appContents;
   private List<ServiceDeclaration> importServices;
   private List<ServiceDeclaration> exportServices;
+  private Manifest manifest;
   
   /**
    * create the applicationMetadata from appManifest
@@ -63,6 +65,10 @@
     this.exportServices = new ArrayList<ServiceDeclaration>();
     setup(appManifest);
     
+    // As of 7 Jan 2010 we have no setter methods. Hence it's currently 
+    // fine to keep a copy of appManifest, and to use it in the store()
+    // method.
+    manifest = appManifest;
   }
   
   /**
@@ -172,13 +178,19 @@
     return appScope.hashCode();
   }
 
-  public void store(File f) {
-    // TODO when writing AriesApplication.store()
-    
+  public void store(File f) throws IOException {
+    FileOutputStream fos = new FileOutputStream (f);
+    store(fos);
+    fos.close();
   }
 
-  public void store(OutputStream out) {
-    // TODO when writing AriesApplication.store()
-    
+  public void store(OutputStream out) throws IOException {
+    if (manifest != null) {
+      Attributes att = manifest.getMainAttributes();
+      if ((att.getValue(Attributes.Name.MANIFEST_VERSION.toString())) == null) {
+        att.putValue(Attributes.Name.MANIFEST_VERSION.toString(), AppConstants.MANIFEST_VERSION);
+      }
+      manifest.write(out);
+    }
   }
 }
\ No newline at end of file

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java?rev=897013&r1=897012&r2=897013&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
Thu Jan  7 21:10:47 2010
@@ -20,20 +20,24 @@
 package org.apache.aries.application.impl;
 
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
 
 import org.apache.aries.application.ApplicationMetadata;
 import org.apache.aries.application.Content;
 import org.apache.aries.application.DeploymentContent;
 import org.apache.aries.application.DeploymentMetadata;
-import org.apache.aries.application.VersionRange;
 import org.apache.aries.application.management.AriesApplication;
 import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.utils.AppConstants;
 import org.osgi.framework.Version;
 
 public class DeploymentMetadataImpl implements DeploymentMetadata {
@@ -74,15 +78,36 @@
   }
 
 
-  public void store(File f) {
-    // TODO when writing AriesApplication.store()
-    
+  public void store(File f) throws FileNotFoundException, IOException{
+    FileOutputStream fos = new FileOutputStream (f);
+    store(fos);
+    fos.close();
   }
 
 
-  public void store(OutputStream in) {
-    // TODO when writing AriesApplication.store()
-    
+  public void store(OutputStream out) throws IOException {
+    // We weren't built from a Manifest, so construct one. 
+    Manifest mf = new Manifest();
+    Attributes attributes = mf.getMainAttributes();
+    attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), AppConstants.MANIFEST_VERSION);
+    attributes.putValue(AppConstants.APPLICATION_VERSION, getApplicationVersion().toString());
+    attributes.putValue(AppConstants.APPLICATION_SYMBOLIC_NAME, getApplicationSymbolicName());
+    attributes.putValue(AppConstants.DEPLOYMENT_CONTENT, getDeploymentContentsAsString());
+    mf.write(out);
+  }
+  
+  private String getDeploymentContentsAsString () { 
+    StringBuilder builder = new StringBuilder();
+    for (DeploymentContent dc : getApplicationDeploymentContents()) {
+      builder.append(dc.getContentName());
+      builder.append(';' + AppConstants.DEPLOYMENT_BUNDLE_VERSION + "=");
+      builder.append(dc.getExactVersion());
+      builder.append(",");
+    }
+    if (builder.length() > 0) { 
+      builder.deleteCharAt(builder.length() - 1);
+    }
+    return builder.toString();
   }
 
 }

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java?rev=897013&r1=897012&r2=897013&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java
Thu Jan  7 21:10:47 2010
@@ -57,4 +57,9 @@
   public static final String MANIFEST_MF = "META-INF/MANIFEST.MF";
   
   public static final String MANIFEST_VERSION="1.0";
+  
+  /* The Deployed-Content header in DEPLOYMENT.MF records all the bundles
+   * to be deployed for a particular application. 
+   */
+  public static final String DEPLOYMENT_CONTENT = "Deployed-Content";
 }



Mime
View raw message