tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsiva...@apache.org
Subject svn commit: r656143 - /incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-manifest/src/main/java/org/apache/tuscany/sca/manifest/ManifestBundleActivator.java
Date Wed, 14 May 2008 08:11:24 GMT
Author: rsivaram
Date: Wed May 14 01:11:23 2008
New Revision: 656143

URL: http://svn.apache.org/viewvc?rev=656143&view=rev
Log:
Add versions to 3rd party virtual bundles in osgi-tuscany

Modified:
    incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-manifest/src/main/java/org/apache/tuscany/sca/manifest/ManifestBundleActivator.java

Modified: incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-manifest/src/main/java/org/apache/tuscany/sca/manifest/ManifestBundleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-manifest/src/main/java/org/apache/tuscany/sca/manifest/ManifestBundleActivator.java?rev=656143&r1=656142&r2=656143&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-manifest/src/main/java/org/apache/tuscany/sca/manifest/ManifestBundleActivator.java
(original)
+++ incubator/tuscany/java/sca/itest/osgi-tuscany/tuscany-manifest/src/main/java/org/apache/tuscany/sca/manifest/ManifestBundleActivator.java
Wed May 14 01:11:23 2008
@@ -14,6 +14,8 @@
 import java.util.jar.JarInputStream;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.zip.ZipEntry;
 
 import org.osgi.framework.Bundle;
@@ -229,6 +231,7 @@
         attributes.putValue("Bundle-ClassPath", bundleName);
         
         String packages = getPackagesInJar(bundleName, jar);
+        String version = getJarVersion(bundleName);
 
         attributes.remove(new Attributes.Name("Require-Bundle"));
         attributes.remove(new Attributes.Name("Import-Package"));
@@ -236,7 +239,7 @@
         if (attributes.getValue("Bundle-SymbolicName") == null)
             attributes.putValue("Bundle-SymbolicName", bundleName);
         if (attributes.getValue("Bundle-Version") == null)
-            attributes.putValue("Bundle-Version", "1.0.0");
+            attributes.putValue("Bundle-Version", version);
         // Existing export statements in bundles may contain versions, so they should be
used as is
         // SDO exports are not sufficient, and should be changed
         if (attributes.getValue("Export-Package") == null || bundleName.startsWith("tuscany-sdo-impl"))
{
@@ -283,5 +286,19 @@
         }
         return pkgBuf.toString();
     }
+    
+    private String getJarVersion(String bundleName) {
+        Pattern pattern = Pattern.compile("-([0-9.]+)");
+        Matcher matcher = pattern.matcher(bundleName);
+        String version = "1.0.0";
+        if (matcher.find()) {
+            version = matcher.group();
+            if (version.endsWith("."))
+                version = version.substring(1, version.length()-1);
+            else
+                version = version.substring(1);
+        }
+        return version;
+    }
 	
 }



Mime
View raw message