myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r1071458 - in /myfaces/extensions/cdi/trunk/core: api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/ api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/
Date Thu, 17 Feb 2011 00:32:45 GMT
Author: gpetracek
Date: Thu Feb 17 00:32:44 2011
New Revision: 1071458

URL: http://svn.apache.org/viewvc?rev=1071458&view=rev
Log:
EXTCDI-136 show the revision number during the bootstrapping process

Modified:
    myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/CodiInformation.java
    myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java
    myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/CoreStartupObserver.java

Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/CodiInformation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/CodiInformation.java?rev=1071458&r1=1071457&r2=1071458&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/CodiInformation.java
(original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/CodiInformation.java
Thu Feb 17 00:32:44 2011
@@ -28,4 +28,6 @@ import org.apache.myfaces.extensions.cdi
 public interface CodiInformation
 {
     static final String VERSION = ClassUtils.getJarVersion(CodiInformation.class);
+
+    static final String REVISION = ClassUtils.getRevision(CodiInformation.class);
 }

Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java?rev=1071458&r1=1071457&r2=1071458&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java
(original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java
Thu Feb 17 00:32:44 2011
@@ -161,12 +161,7 @@ public class ClassUtils
 
     public static String getJarVersion(Class targetClass)
     {
-        String classFilePath = targetClass.getCanonicalName().replace('.', '/') + ".class";
-        String manifestFilePath = "/META-INF/MANIFEST.MF";
-
-        String classLocation = targetClass.getResource(targetClass.getSimpleName() + ".class").toString();
-        String manifestFileLocation = classLocation
-                .substring(0, classLocation.indexOf(classFilePath) - 1) + manifestFilePath;
+        String manifestFileLocation = getManifestLocation(targetClass);
 
         try
         {
@@ -178,4 +173,28 @@ public class ClassUtils
             return null;
         }
     }
+
+    public static String getRevision(Class targetClass)
+    {
+        String manifestFileLocation = getManifestLocation(targetClass);
+
+        try
+        {
+            return new Manifest(new URL(manifestFileLocation).openStream())
+                    .getMainAttributes().getValue("Revision");
+        }
+        catch (Throwable t)
+        {
+            return null;
+        }
+    }
+
+    private static String getManifestLocation(Class targetClass)
+    {
+        String classFilePath = targetClass.getCanonicalName().replace('.', '/') + ".class";
+        String manifestFilePath = "/META-INF/MANIFEST.MF";
+
+        String classLocation = targetClass.getResource(targetClass.getSimpleName() + ".class").toString();
+        return classLocation.substring(0, classLocation.indexOf(classFilePath) - 1) + manifestFilePath;
+    }
 }

Modified: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/CoreStartupObserver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/CoreStartupObserver.java?rev=1071458&r1=1071457&r2=1071458&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/CoreStartupObserver.java
(original)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/CoreStartupObserver.java
Thu Feb 17 00:32:44 2011
@@ -188,7 +188,14 @@ public class CoreStartupObserver extends
     {
         if(CodiInformation.VERSION != null && !CodiInformation.VERSION.startsWith("null"))
         {
-            return " v" + CodiInformation.VERSION;
+            String revision = "";
+            if(CodiInformation.VERSION.endsWith("-SNAPSHOT") &&
+                    CodiInformation.REVISION != null && !CodiInformation.REVISION.startsWith("null"))
+            {
+                revision = " r" + CodiInformation.REVISION;
+            }
+
+            return " v" + CodiInformation.VERSION + revision;
         }
         return "";
     }



Mime
View raw message