You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2011/02/07 16:54:51 UTC

svn commit: r1067986 - in /felix/trunk/ipojo: manipulator/doc/changelog.txt manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java plugin/doc/changelog.txt plugin/pom.xml

Author: clement
Date: Mon Feb  7 15:54:51 2011
New Revision: 1067986

URL: http://svn.apache.org/viewvc?rev=1067986&view=rev
Log:
[FELIX-2825] - The maven-ipojo-plugin does not replace component classes in WAR files

Modified:
    felix/trunk/ipojo/manipulator/doc/changelog.txt
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
    felix/trunk/ipojo/plugin/doc/changelog.txt
    felix/trunk/ipojo/plugin/pom.xml

Modified: felix/trunk/ipojo/manipulator/doc/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/doc/changelog.txt?rev=1067986&r1=1067985&r2=1067986&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/doc/changelog.txt (original)
+++ felix/trunk/ipojo/manipulator/doc/changelog.txt Mon Feb  7 15:54:51 2011
@@ -1,3 +1,9 @@
+Changes from the 1.8.0 to 1.8.2
+-------------------------------
+** Bug
+    * [FELIX-2825] - The maven-ipojo-plugin does not replace component classes in WAR files
+
+
 Changes from the 1.6.4 to 1.8.0
 -------------------------------
 ** Bug

Modified: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java?rev=1067986&r1=1067985&r2=1067986&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java (original)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java Mon Feb  7 15:54:51 2011
@@ -351,6 +351,21 @@ public class Pojoization {
     }
 
     /**
+     * Gets the class name from the jar entry.
+     * This method handles the WAR case.
+     * @param entry the entry
+     * @return the class name
+     */
+    private String getClassNameForEntry(JarEntry entry) {
+    	// If we're manipulating a war file remove the WEB-INF/classes prefix.
+    	if (entry.getName().startsWith("WEB-INF/classes/")) {
+        	return entry.getName().substring("WEB-INF/classes/".length());
+        } else {
+        	return entry.getName();
+        }
+    }
+
+    /**
      * Manipulate the input bundle.
      * @param out final bundle
      */
@@ -381,9 +396,11 @@ public class Pojoization {
 
                 // If the class was manipulated, write out the manipulated
                 // version of the bytecode
-                if (m_classes.containsKey(curEntry.getName())) {
+
+                String classEntry = getClassNameForEntry(curEntry);
+                if (m_classes.containsKey(classEntry)) {
                     JarEntry je = new JarEntry(curEntry.getName());
-                    byte[] outClazz = (byte[]) m_classes.get(curEntry.getName());
+                    byte[] outClazz = (byte[]) m_classes.get(classEntry);
                     if (outClazz != null && outClazz.length != 0) {
                         jos.putNextEntry(je); // copy the entry header to jos
                         jos.write(outClazz);
@@ -475,7 +492,6 @@ public class Pojoization {
             while (entries.hasMoreElements()) {
                 String curName = (String) entries.nextElement();
                 try {
-
                     // Need to load the bytecode for each .class entry
                     byte[] in = getBytecode(curName);
 
@@ -484,7 +500,7 @@ public class Pojoization {
 
                     // We check the array size to avoid manipulating empty files
                     // produced by incremental compilers (like Eclipse Compiler)
-                    if(in != null || in.length > 0) {
+                    if(in != null && in.length > 0) {
                         computeAnnotations(in);
                     } else {
                         error("Cannot compute annotations from " + curName + " : Empty file");
@@ -1088,7 +1104,7 @@ public class Pojoization {
         }
 
         if (meta == null || meta.length == 0) {
-            warn("Neither component types, nor instances in the metadata");
+            warn("Neither component types, nor instances in the XML metadata");
         }
 
         m_metadata.addAll(Arrays.asList(meta));

Modified: felix/trunk/ipojo/plugin/doc/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/plugin/doc/changelog.txt?rev=1067986&r1=1067985&r2=1067986&view=diff
==============================================================================
--- felix/trunk/ipojo/plugin/doc/changelog.txt (original)
+++ felix/trunk/ipojo/plugin/doc/changelog.txt Mon Feb  7 15:54:51 2011
@@ -1,6 +1,7 @@
 Changes from the 1.8.0 to 1.8.2
 -------------------------------
 ** Bug
+    * [FELIX-2825] - The maven-ipojo-plugin does not replace component classes in WAR files
     * [FELIX-2829] - The maven-ipojo-plugin archetype descriptor is not conform
 
 Changes from the 1.6.0 to 1.8.0

Modified: felix/trunk/ipojo/plugin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/plugin/pom.xml?rev=1067986&r1=1067985&r2=1067986&view=diff
==============================================================================
--- felix/trunk/ipojo/plugin/pom.xml (original)
+++ felix/trunk/ipojo/plugin/pom.xml Mon Feb  7 15:54:51 2011
@@ -72,7 +72,7 @@
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.ipojo.manipulator</artifactId>
-      <version>1.8.0</version>
+      <version>1.9.0-SNAPSHOT</version>
     </dependency>
   </dependencies>
   <build>