felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r585146 [4/4] - in /felix/trunk/ipojo: ./ arch/src/main/resources/ core/src/main/java/org/apache/felix/ipojo/ core/src/main/java/org/apache/felix/ipojo/architecture/ core/src/main/java/org/apache/felix/ipojo/composite/ core/src/main/java/or...
Date Tue, 16 Oct 2007 14:05:21 GMT
Modified: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/FieldAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/FieldAdapter.java?rev=585146&r1=585145&r2=585146&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/FieldAdapter.java
(original)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/FieldAdapter.java
Tue Oct 16 07:04:28 2007
@@ -119,7 +119,7 @@
         mv.visitFieldInsn(GETFIELD, m_owner, "_F" + name, "Z");
         Label l2 = new Label();
         mv.visitJumpInsn(IFNE, l2);
-        //TODO move in
+
         mv.visitVarInsn(ALOAD, 0);
         mv.visitVarInsn(ALOAD, 1);
         mv.visitFieldInsn(PUTFIELD, m_owner, name, internalType);
@@ -162,41 +162,10 @@
         mv.visitLabel(l1);
 
         mv.visitVarInsn(ALOAD, 0);
-        // mv.visitFieldInsn(GETFIELD, m_owner, name, "["+type.getInternalName()+";");
-        mv.visitFieldInsn(GETFIELD, m_owner, name, internalType);
-        mv.visitVarInsn(ASTORE, 1);
-
-        mv.visitVarInsn(ALOAD, 0);
         mv.visitFieldInsn(GETFIELD, m_owner, "_cm", "Lorg/apache/felix/ipojo/InstanceManager;");
         mv.visitLdcInsn(name);
-        mv.visitVarInsn(ALOAD, 1);
-        mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/felix/ipojo/InstanceManager", "getterCallback",
"(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;");
-        mv.visitVarInsn(ASTORE, 2);
-
-        mv.visitVarInsn(ALOAD, 2);
+        mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/felix/ipojo/InstanceManager", "getterCallback",
"(Ljava/lang/String;)Ljava/lang/Object;");
         mv.visitTypeInsn(CHECKCAST, internalType);
-        mv.visitVarInsn(ASTORE, 3);
-
-        Label l3a = new Label();
-        mv.visitLabel(l3a);
-
-        mv.visitVarInsn(ALOAD, 1);
-        Label l4a = new Label();
-        mv.visitJumpInsn(IFNULL, l4a);
-        mv.visitVarInsn(ALOAD, 1);
-        mv.visitVarInsn(ALOAD, 3);
-        Label l5a = new Label();
-        mv.visitJumpInsn(IF_ACMPEQ, l5a); // Test equality on object.
-        
-        // Invoke the _set method
-        mv.visitLabel(l4a);        
-        mv.visitVarInsn(ALOAD, 0);
-        mv.visitVarInsn(ALOAD, 3);
-        mv.visitMethodInsn(INVOKEVIRTUAL, m_owner, "_set" + name, "(" + internalType + ")V");
-        
-        // End of the method
-        mv.visitLabel(l5a);
-        mv.visitVarInsn(ALOAD, 3);
         mv.visitInsn(ARETURN);
 
         // End
@@ -240,46 +209,17 @@
                 mv.visitLabel(l1);
 
                 mv.visitVarInsn(ALOAD, 0);
-                mv.visitFieldInsn(GETFIELD, m_owner, name, internalName);
-                mv.visitVarInsn(type.getOpcode(ISTORE), 1);
-
-                mv.visitTypeInsn(NEW, boxingType);
-                mv.visitInsn(DUP);
-                mv.visitVarInsn(type.getOpcode(ILOAD), 1);
-                mv.visitMethodInsn(INVOKESPECIAL, boxingType, "<init>", "(" + internalName
+ ")V");
-                mv.visitVarInsn(ASTORE, 2);
-
-                mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, "_cm", "Lorg/apache/felix/ipojo/InstanceManager;");
                 mv.visitLdcInsn(name);
-                mv.visitVarInsn(ALOAD, 2);
-                mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/felix/ipojo/InstanceManager",
"getterCallback", "(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;");
-                mv.visitVarInsn(ASTORE, 3);
+                mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/felix/ipojo/InstanceManager",
"getterCallback", "(Ljava/lang/String;)Ljava/lang/Object;");
+                mv.visitVarInsn(ASTORE, 1);
 
-                mv.visitVarInsn(ALOAD, 3);
+                mv.visitVarInsn(ALOAD, 1);
                 mv.visitTypeInsn(CHECKCAST, boxingType);
-                mv.visitVarInsn(ASTORE, 4);
+                mv.visitVarInsn(ASTORE, 2);
 
-                mv.visitVarInsn(ALOAD, 4);
+                mv.visitVarInsn(ALOAD, 2);
                 mv.visitMethodInsn(INVOKEVIRTUAL, boxingType, unboxingMethod, "()" + internalName);
-                mv.visitVarInsn(type.getOpcode(ISTORE), 5);
-
-                Label l5 = new Label();
-                mv.visitLabel(l5);
-
-                mv.visitVarInsn(type.getOpcode(ILOAD), 1);
-                mv.visitVarInsn(type.getOpcode(ILOAD), 5);
-                Label l6 = new Label();
-                mv.visitJumpInsn(type.getOpcode(IF_ICMPEQ), l6);
-
-                Label l7 = new Label();
-                mv.visitLabel(l7);
-                mv.visitVarInsn(ALOAD, 0);
-                mv.visitVarInsn(type.getOpcode(ILOAD), 5);
-                mv.visitMethodInsn(INVOKEVIRTUAL, m_owner, "_set" + name, "(" + internalName
+ ")V");
-                mv.visitLabel(l6);
-
-                mv.visitVarInsn(type.getOpcode(ILOAD), 5);
                 mv.visitInsn(type.getOpcode(IRETURN));
                 break;
 
@@ -288,59 +228,29 @@
                 boxingType = ManipulationProperty.PRIMITIVE_BOXING_INFORMATION[type.getSort()][1];
                 unboxingMethod = ManipulationProperty.PRIMITIVE_BOXING_INFORMATION[type.getSort()][2];
 
-                Label l00 = new Label();
-                mv.visitLabel(l00);
+                l0 = new Label();
+                mv.visitLabel(l0);
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, "_F" + name, "Z");
-                Label l10 = new Label();
-                mv.visitJumpInsn(IFNE, l10);
+                l1 = new Label();
+                mv.visitJumpInsn(IFNE, l1);
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, name, internalName);
                 mv.visitInsn(LRETURN);
-                mv.visitLabel(l10);
-
-                mv.visitVarInsn(ALOAD, 0);
-                mv.visitFieldInsn(GETFIELD, m_owner, name, internalName);
-                mv.visitVarInsn(LSTORE, 1);
-
-                mv.visitTypeInsn(NEW, boxingType);
-                mv.visitInsn(DUP);
-                mv.visitVarInsn(LLOAD, 1);
-                mv.visitMethodInsn(INVOKESPECIAL, boxingType, "<init>", "(" + internalName
+ ")V");
-                mv.visitVarInsn(ASTORE, 3); // Double Space
+                mv.visitLabel(l1);
 
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, "_cm", "Lorg/apache/felix/ipojo/InstanceManager;");
                 mv.visitLdcInsn(name);
-                mv.visitVarInsn(ALOAD, 3);
-                mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/felix/ipojo/InstanceManager",
"getterCallback", "(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;");
-                mv.visitVarInsn(ASTORE, 4);
+                mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/felix/ipojo/InstanceManager",
"getterCallback", "(Ljava/lang/String;)Ljava/lang/Object;");
+                mv.visitVarInsn(ASTORE, 1);
 
-                mv.visitVarInsn(ALOAD, 4);
+                mv.visitVarInsn(ALOAD, 1);
                 mv.visitTypeInsn(CHECKCAST, boxingType);
-                mv.visitVarInsn(ASTORE, 5);
+                mv.visitVarInsn(ASTORE, 2);
 
-                mv.visitVarInsn(ALOAD, 5);
+                mv.visitVarInsn(ALOAD, 2);
                 mv.visitMethodInsn(INVOKEVIRTUAL, boxingType, unboxingMethod, "()" + internalName);
-                mv.visitVarInsn(LSTORE, 6);
-
-                l5 = new Label();
-                mv.visitLabel(l5);
-
-                mv.visitVarInsn(LLOAD, 1);
-                mv.visitVarInsn(LLOAD, 6);
-                mv.visitInsn(LCMP);
-                l6 = new Label();
-                mv.visitJumpInsn(IFEQ, l6);
-
-                l7 = new Label();
-                mv.visitLabel(l7);
-                mv.visitVarInsn(ALOAD, 0);
-                mv.visitVarInsn(LLOAD, 6);
-                mv.visitMethodInsn(INVOKEVIRTUAL, m_owner, "_set" + name, "(" + internalName
+ ")V");
-                mv.visitLabel(l6);
-
-                mv.visitVarInsn(LLOAD, 6);
                 mv.visitInsn(LRETURN);
 
                 break;
@@ -350,59 +260,29 @@
                 boxingType = ManipulationProperty.PRIMITIVE_BOXING_INFORMATION[type.getSort()][1];
                 unboxingMethod = ManipulationProperty.PRIMITIVE_BOXING_INFORMATION[type.getSort()][2];
 
-                Label l01 = new Label();
-                mv.visitLabel(l01);
+                l0 = new Label();
+                mv.visitLabel(l0);
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, "_F" + name, "Z");
-                Label l11 = new Label();
-                mv.visitJumpInsn(IFNE, l11);
+                l1 = new Label();
+                mv.visitJumpInsn(IFNE, l1);
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, name, internalName);
                 mv.visitInsn(DRETURN);
-                mv.visitLabel(l11);
-
-                mv.visitVarInsn(ALOAD, 0);
-                mv.visitFieldInsn(GETFIELD, m_owner, name, internalName);
-                mv.visitVarInsn(DSTORE, 1);
-
-                mv.visitTypeInsn(NEW, boxingType);
-                mv.visitInsn(DUP);
-                mv.visitVarInsn(DLOAD, 1);
-                mv.visitMethodInsn(INVOKESPECIAL, boxingType, "<init>", "(" + internalName
+ ")V");
-                mv.visitVarInsn(ASTORE, 3); // Double Space
+                mv.visitLabel(l1);
 
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, "_cm", "Lorg/apache/felix/ipojo/InstanceManager;");
                 mv.visitLdcInsn(name);
-                mv.visitVarInsn(ALOAD, 3);
-                mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/felix/ipojo/InstanceManager",
"getterCallback", "(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;");
-                mv.visitVarInsn(ASTORE, 4);
+                mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/felix/ipojo/InstanceManager",
"getterCallback", "(Ljava/lang/String;)Ljava/lang/Object;");
+                mv.visitVarInsn(ASTORE, 1);
 
-                mv.visitVarInsn(ALOAD, 4);
+                mv.visitVarInsn(ALOAD, 1);
                 mv.visitTypeInsn(CHECKCAST, boxingType);
-                mv.visitVarInsn(ASTORE, 5);
+                mv.visitVarInsn(ASTORE, 2);
 
-                mv.visitVarInsn(ALOAD, 5);
+                mv.visitVarInsn(ALOAD, 2);
                 mv.visitMethodInsn(INVOKEVIRTUAL, boxingType, unboxingMethod, "()" + internalName);
-                mv.visitVarInsn(DSTORE, 6);
-
-                l5 = new Label();
-                mv.visitLabel(l5);
-
-                mv.visitVarInsn(DLOAD, 1);
-                mv.visitVarInsn(DLOAD, 6);
-                mv.visitInsn(DCMPL);
-                l6 = new Label();
-                mv.visitJumpInsn(IFEQ, l6);
-
-                l7 = new Label();
-                mv.visitLabel(l7);
-                mv.visitVarInsn(ALOAD, 0);
-                mv.visitVarInsn(DLOAD, 6);
-                mv.visitMethodInsn(INVOKEVIRTUAL, m_owner, "_set" + name, "(" + internalName
+ ")V");
-                mv.visitLabel(l6);
-
-                mv.visitVarInsn(DLOAD, 6);
                 mv.visitInsn(DRETURN);
 
                 break;
@@ -412,110 +292,50 @@
                 boxingType = ManipulationProperty.PRIMITIVE_BOXING_INFORMATION[type.getSort()][1];
                 unboxingMethod = ManipulationProperty.PRIMITIVE_BOXING_INFORMATION[type.getSort()][2];
 
-                Label l02 = new Label();
-                mv.visitLabel(l02);
+                l0 = new Label();
+                mv.visitLabel(l0);
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, "_F" + name, "Z");
-                Label l12 = new Label();
-                mv.visitJumpInsn(IFNE, l12);
+                l1 = new Label();
+                mv.visitJumpInsn(IFNE, l1);
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, name, internalName);
                 mv.visitInsn(FRETURN);
-                mv.visitLabel(l12);
-
-                mv.visitVarInsn(ALOAD, 0);
-                mv.visitFieldInsn(GETFIELD, m_owner, name, internalName);
-                mv.visitVarInsn(FSTORE, 1);
-
-                mv.visitTypeInsn(NEW, boxingType);
-                mv.visitInsn(DUP);
-                mv.visitVarInsn(FLOAD, 1);
-                mv.visitMethodInsn(INVOKESPECIAL, boxingType, "<init>", "(" + internalName
+ ")V");
-                mv.visitVarInsn(ASTORE, 2); // One Space
+                mv.visitLabel(l1);
 
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, "_cm", "Lorg/apache/felix/ipojo/InstanceManager;");
                 mv.visitLdcInsn(name);
-                mv.visitVarInsn(ALOAD, 2);
-                mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/felix/ipojo/InstanceManager",
"getterCallback", "(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;");
-                mv.visitVarInsn(ASTORE, 3);
+                mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/felix/ipojo/InstanceManager",
"getterCallback", "(Ljava/lang/String;)Ljava/lang/Object;");
+                mv.visitVarInsn(ASTORE, 1);
 
-                mv.visitVarInsn(ALOAD, 3);
+                mv.visitVarInsn(ALOAD, 1);
                 mv.visitTypeInsn(CHECKCAST, boxingType);
-                mv.visitVarInsn(ASTORE, 4);
+                mv.visitVarInsn(ASTORE, 2);
 
-                mv.visitVarInsn(ALOAD, 4);
+                mv.visitVarInsn(ALOAD, 2);
                 mv.visitMethodInsn(INVOKEVIRTUAL, boxingType, unboxingMethod, "()" + internalName);
-                mv.visitVarInsn(FSTORE, 5);
-
-                l5 = new Label();
-                mv.visitLabel(l5);
-
-                mv.visitVarInsn(FLOAD, 1);
-                mv.visitVarInsn(FLOAD, 5);
-                mv.visitInsn(FCMPL);
-                l6 = new Label();
-                mv.visitJumpInsn(IFEQ, l6);
-
-                l7 = new Label();
-                mv.visitLabel(l7);
-                mv.visitVarInsn(ALOAD, 0);
-                mv.visitVarInsn(FLOAD, 5);
-                mv.visitMethodInsn(INVOKEVIRTUAL, m_owner, "_set" + name, "(" + internalName
+ ")V");
-                mv.visitLabel(l6);
-
-                mv.visitVarInsn(FLOAD, 5);
                 mv.visitInsn(FRETURN);
 
                 break;
 
             case Type.OBJECT:
-                Label l03 = new Label();
-                mv.visitLabel(l03);
+                l0 = new Label();
+                mv.visitLabel(l0);
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, "_F" + name, "Z");
-                Label l13 = new Label();
-                mv.visitJumpInsn(IFNE, l13);
+                l1 = new Label();
+                mv.visitJumpInsn(IFNE, l1);
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, name, "L" + type.getInternalName() +
";");
                 mv.visitInsn(ARETURN);
-                mv.visitLabel(l13);
-
-                mv.visitVarInsn(ALOAD, 0);
-                mv.visitFieldInsn(GETFIELD, m_owner, name, "L" + type.getInternalName() +
";");
-                mv.visitVarInsn(ASTORE, 1);
+                mv.visitLabel(l1);
 
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitFieldInsn(GETFIELD, m_owner, "_cm", "Lorg/apache/felix/ipojo/InstanceManager;");
                 mv.visitLdcInsn(name);
-                mv.visitVarInsn(ALOAD, 1);
-                mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/felix/ipojo/InstanceManager",
"getterCallback", "(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;");
-                mv.visitVarInsn(ASTORE, 2);
-
-                mv.visitVarInsn(ALOAD, 2);
+                mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/felix/ipojo/InstanceManager",
"getterCallback", "(Ljava/lang/String;)Ljava/lang/Object;");
                 mv.visitTypeInsn(CHECKCAST, type.getInternalName());
-                mv.visitVarInsn(ASTORE, 3);
-
-                Label l3b = new Label();
-                mv.visitLabel(l3b);
-
-                mv.visitVarInsn(ALOAD, 1);
-                Label l4b = new Label();
-                mv.visitJumpInsn(IFNULL, l4b);
-                mv.visitVarInsn(ALOAD, 1);
-                mv.visitVarInsn(ALOAD, 3);
-                
-                Label l5b = new Label();
-                mv.visitJumpInsn(IF_ACMPEQ, l5b); // Test equality on object.
-                
-                mv.visitLabel(l4b);
-                mv.visitVarInsn(ALOAD, 0);
-                mv.visitVarInsn(ALOAD, 3);
-                mv.visitMethodInsn(INVOKEVIRTUAL, m_owner, "_set" + name, "(L" + type.getInternalName()
+ ";)V");
-                
-                // End of the getter method, return the object
-                mv.visitLabel(l5b);
-                mv.visitVarInsn(ALOAD, 3);
                 mv.visitInsn(ARETURN);
 
                 break;
@@ -555,7 +375,7 @@
                 mv.visitFieldInsn(GETFIELD, m_owner, "_F" + name, "Z");
                 Label l22 = new Label();
                 mv.visitJumpInsn(IFNE, l22);
-                //TODO move in
+                
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitVarInsn(type.getOpcode(ILOAD), 1);
                 mv.visitFieldInsn(PUTFIELD, m_owner, name, internalName);
@@ -593,7 +413,7 @@
                 mv.visitFieldInsn(GETFIELD, m_owner, "_F" + name, "Z");
                 Label l23 = new Label();
                 mv.visitJumpInsn(IFNE, l23);
-                //TODO move in
+           
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitVarInsn(type.getOpcode(ILOAD), 1);
                 mv.visitFieldInsn(PUTFIELD, m_owner, name, internalName);
@@ -624,7 +444,7 @@
                 mv.visitFieldInsn(GETFIELD, m_owner, "_F" + name, "Z");
                 Label l24 = new Label();
                 mv.visitJumpInsn(IFNE, l24);
-                //TODO move in
+           
                 mv.visitVarInsn(ALOAD, 0);
                 mv.visitVarInsn(ALOAD, 1);
                 mv.visitFieldInsn(PUTFIELD, m_owner, name, "L" + type.getInternalName() +
";");

Modified: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java?rev=585146&r1=585145&r2=585146&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java
(original)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java
Tue Oct 16 07:04:28 2007
@@ -24,8 +24,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -44,17 +42,22 @@
     /**
      * Store the visited fields : [name of the field, type of the field].
      */
-    private Map m_fields = new HashMap();
+    private Map m_fields;
 
     /**
      * Store the interface implemented by the class.
      */
-    private String[] m_interfaces = new String[0];
+    private List m_interfaces;
 
     /**
      * Store the methods list.
      */
-    private List m_methods = new ArrayList();
+    private List m_methods;
+    
+    /**
+     * Pojo super class.
+     */
+    private String m_superClass;
 
     /**
      * Manipulate the class.
@@ -65,12 +68,6 @@
      * @throws Exception : occurs if the manipulation failed.
      */
     public boolean manipulate(String name, File outputDirectory) throws Exception {
-
-        // Initialize fields, interfaces and methods
-        m_fields = new HashMap();
-        m_interfaces = new String[0];
-        m_methods = new ArrayList();
-
         // gets an input stream to read the byte code of the class
         String path = outputDirectory + "/" + name.replace('.', '/') + ".class";
         File clazz = new File(path);
@@ -92,33 +89,14 @@
         ckReader.accept(ck, ClassReader.SKIP_FRAMES);
         is1.close();
 
-        m_fields = ck.getFields(); // GEt visited fields (contains only POJO fields)
+        m_fields = ck.getFields(); // Get visited fields (contains only POJO fields)
 
-        // Get interface and remove POJO interface is presents
-        String[] its = ck.getInterfaces();
-        List l = new ArrayList();
-        for (int i = 0; i < its.length; i++) {
-            l.add(its[i]);
-        }
-        l.remove("org/apache/felix/ipojo/Pojo");
-
-        m_interfaces = new String[l.size()];
-        for (int i = 0; i < m_interfaces.length; i++) {
-            m_interfaces[i] = ((String) l.get(i)).replace('/', '.');
-        }
-
-        // Get the method list
-        // Remove iPOJO methods
-        for (int i = 0; i < ck.getMethods().size(); i++) {
-            MethodDescriptor method = (MethodDescriptor) ck.getMethods().get(i);
-            if (!(method.getName().startsWith("_get") || // Avoid getter method
-                    method.getName().startsWith("_set") || // Avoid setter method
-                    method.getName().equals("_setComponentManager") || // Avoid the set method
-                    method.getName().equals("getComponentInstance"))) { // Avoid the getComponentInstance
method
-                System.err.println(" Add the method : " + method);
-                m_methods.add(method);
-            }
-        }
+        // Get interfaces and super class.
+        m_interfaces = ck.getInterfaces();
+        m_superClass = ck.getSuperClass();
+
+        // Get the methods list
+        m_methods = ck.getMethods();
 
         if (!ck.isalreadyManipulated()) {
 
@@ -163,30 +141,14 @@
         ckReader.accept(ck, ClassReader.SKIP_FRAMES);
         is1.close();
 
-        m_fields = ck.getFields();
+        m_fields = ck.getFields(); // Get visited fields (contains only POJO fields)
 
-        // Get interface and remove POJO interface is presents
-        String[] its = ck.getInterfaces();
-        List l = new ArrayList();
-        for (int i = 0; i < its.length; i++) {
-            l.add(its[i]);
-        }
-        l.remove("org/apache/felix/ipojo/Pojo");
-
-        m_interfaces = new String[l.size()];
-        for (int i = 0; i < m_interfaces.length; i++) {
-            m_interfaces[i] = ((String) l.get(i)).replace('/', '.');
-        }
-
-        for (int i = 0; i < ck.getMethods().size(); i++) {
-            MethodDescriptor method = (MethodDescriptor) ck.getMethods().get(i);
-            if (!(method.getName().startsWith("_get") || // Avoid getter method
-                    method.getName().startsWith("_set") || // Avoid setter method
-                    method.getName().equals("_setComponentManager") || // Avoid the set method
-                    method.getName().equals("getComponentInstance"))) { // Avoid the getComponentInstance
method
-                m_methods.add(method);
-            }
-        }
+        // Get interfaces and super class.
+        m_interfaces = ck.getInterfaces();
+        m_superClass = ck.getSuperClass();
+
+        // Get the methods list
+        m_methods = ck.getMethods();
 
         ClassWriter finalWriter = null;
         if (!ck.isalreadyManipulated()) {
@@ -215,12 +177,18 @@
      */
     public Element getManipulationMetadata() {
         Element elem = new Element("Manipulation", "");
-        for (int j = 0; j < m_interfaces.length; j++) {
+        
+        if (m_superClass != null) {
+            elem.addAttribute(new Attribute("super", m_superClass));
+        }
+        
+        for (int j = 0; j < m_interfaces.size(); j++) {
             Element itf = new Element("Interface", "");
-            Attribute att = new Attribute("name", m_interfaces[j]);
+            Attribute att = new Attribute("name", m_interfaces.get(j).toString());
             itf.addAttribute(att);
             elem.addElement(itf);
         }
+        
         for (Iterator it = m_fields.keySet().iterator(); it.hasNext();) {
             Element field = new Element("Field", "");
             String name = (String) it.next();

Modified: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/PojoAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/PojoAdapter.java?rev=585146&r1=585145&r2=585146&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/PojoAdapter.java
(original)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/PojoAdapter.java
Tue Oct 16 07:04:28 2007
@@ -145,7 +145,7 @@
      */
     public FieldVisitor visitField(int access, String name, String desc, String signature,
Object value) {
         // Add the field to the list.
-        if ((access & ACC_STATIC) == 0) {
+        if (((access & ACC_STATIC) == 0) && (!name.startsWith("class$"))) {
             addFlagField(name);
             m_getterSetterCreator.visitField(access, name, desc, signature, value);
         }
@@ -179,24 +179,45 @@
     public MethodVisitor visitMethod(int access, String name, String desc, String signature,
String[] exceptions) {
         // Avoid manipulating special method
         if (name.equals("<clinit>") || name.equals("class$")) { return super.visitMethod(access,
name, desc, signature, exceptions); }
-        // The constructor is manipulated separatly
-        if (name.equals("<init>")) {
+        // The constructor is manipulated separately
+        if (name.equals("<init>")) {      
+            
             // 1) change the constructor descriptor (add a component manager arg as first
argument)
             String newDesc = desc.substring(1);
             newDesc = "(Lorg/apache/felix/ipojo/InstanceManager;" + newDesc;
 
             // Insert the new constructor
             MethodVisitor mv = super.visitMethod(ACC_PUBLIC, "<init>", newDesc, null,
null);
+            
+            Type[] args = Type.getArgumentTypes(newDesc);
+            String id = "$init";
+            for (int i = 0; i < args.length; i++) {
+                String cn = args[i].getClassName();
+                if (cn.endsWith("[]")) {
+                    cn = cn.replace('[', '$');
+                    cn = cn.substring(0, cn.length() - 1);
+                }
+                cn = cn.replace('.', '_');
+                id += cn;
+            }
+
+            String flag = "_M" + id;
+            m_methods.add(id);
+
+            FieldVisitor flagField = cv.visitField(Opcodes.ACC_PRIVATE, flag, "Z", null,
null);
+            if (flagField != null) {
+                flagField.visitEnd();
+            }
 
             if (mv == null) {
                 return null;
             } else {
-                // return new ConstructorCodeAdapter(mv, access, desc, m_owner);
-                return new ConstructorCodeAdapter(mv, m_owner, m_fields);
+                return new ConstructorCodeAdapter(mv, m_owner, m_fields, access, name, newDesc);
             }
         } else { // "Normal methods"
             // avoid manipulating static methods.
             if ((access & ACC_STATIC) == ACC_STATIC) { return super.visitMethod(access,
name, desc, signature, exceptions); }
+            
             Type[] args = Type.getArgumentTypes(desc);
             String id = name;
             for (int i = 0; i < args.length; i++) {

Modified: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java?rev=585146&r1=585145&r2=585146&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java
(original)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java
Tue Oct 16 07:04:28 2007
@@ -280,7 +280,8 @@
             Element[] props = m_parent.getElements("Property");
             Element prop = null;
             for (int i = 0; prop == null && i < props.length; i++) {
-                if (props[i].containsAttribute("name") && props[i].getAttribute("name").equals(m_name))
{
+                String name = props[i].getAttribute("name");
+                if (name != null && name.equals(m_name)) {
                     prop = props[i];
                 }
             }

Modified: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java?rev=585146&r1=585145&r2=585146&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
(original)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
Tue Oct 16 07:04:28 2007
@@ -335,7 +335,8 @@
             Element[] props = m_parent.getElements("Property");
             Element prop = null;
             for (int i = 0; prop == null && i < props.length; i++) {
-                if (props[i].containsAttribute("name") && props[i].getAttribute("name").equals(m_name))
{
+                String name = props[i].getAttribute("name");
+                if (name != null && name.equals(m_name)) {
                     prop = props[i];
                 }
             }

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=585146&r1=585145&r2=585146&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
Tue Oct 16 07:04:28 2007
@@ -349,14 +349,8 @@
     private List getDeclaredComponents(Element[] meta) {
         List componentClazzes = new ArrayList();
         for (int i = 0; i < meta.length; i++) {
-            if (meta[i].getName().equalsIgnoreCase("component") && meta[i].containsAttribute("className"))
{
-                String name = meta[i].getAttribute("classname");
-                name = name.replace('.', '/');
-                name += ".class";
-                componentClazzes.add(new ComponentInfo(name, meta[i]));
-            }
-            if (meta[i].getName().equalsIgnoreCase("handler") && meta[i].containsAttribute("className"))
{
-                String name = meta[i].getAttribute("classname");
+            String name = meta[i].getAttribute("classname");
+            if (name != null) { // Only handler and component have a classname attribute

                 name = name.replace('.', '/');
                 name += ".class";
                 componentClazzes.add(new ComponentInfo(name, meta[i]));
@@ -626,7 +620,7 @@
      */
     private String buildManifestMetadata(Element element, String actual) {
         String result = "";
-        if (element.getNameSpace().equals("")) {
+        if (element.getNameSpace() == null) {
             result = actual + element.getName() + " { ";
         } else {
             result = actual + element.getNameSpace() + ":" + element.getName() + " { ";
@@ -635,7 +629,7 @@
         Attribute[] atts = element.getAttributes();
         for (int i = 0; i < atts.length; i++) {
             Attribute current = (Attribute) atts[i];
-            if (current.getNameSpace().equals("")) {
+            if (current.getNameSpace() == null) {
                 result = result + "$" + current.getName() + "=\"" + current.getValue() +
"\" ";
             } else {
                 result = result + "$" + current.getNameSpace() + ":" + current.getName()
+ "=\"" + current.getValue() + "\" ";

Modified: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/xml/parser/XMLMetadataParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/xml/parser/XMLMetadataParser.java?rev=585146&r1=585145&r2=585146&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/xml/parser/XMLMetadataParser.java
(original)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/xml/parser/XMLMetadataParser.java
Tue Oct 16 07:04:28 2007
@@ -224,7 +224,6 @@
      */
     public void startElement(String namespaceURI, String localName, String qName, Attributes
atts) throws SAXException {
         Element elem = new Element(localName, namespaceURI);
-
         for (int i = 0; i < atts.getLength(); i++) {
             String name = (String) atts.getLocalName(i);
             String ns = (String) atts.getURI(i);

Modified: felix/trunk/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Attribute.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Attribute.java?rev=585146&r1=585145&r2=585146&view=diff
==============================================================================
--- felix/trunk/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Attribute.java
(original)
+++ felix/trunk/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Attribute.java
Tue Oct 16 07:04:28 2007
@@ -48,7 +48,6 @@
     public Attribute(String name, String value) {
         m_name = name.toLowerCase();
         m_value = value;
-        m_nameSpace = "";
     }
 
     /**
@@ -60,7 +59,9 @@
     public Attribute(String name, String ns, String value) {
         m_name = name.toLowerCase();
         m_value = value;
-        m_nameSpace = ns;
+        if (ns != null && ns.length() > 0) {
+            m_nameSpace = ns;
+        }
     }
 
     /**

Modified: felix/trunk/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Element.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Element.java?rev=585146&r1=585145&r2=585146&view=diff
==============================================================================
--- felix/trunk/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Element.java
(original)
+++ felix/trunk/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Element.java
Tue Oct 16 07:04:28 2007
@@ -64,7 +64,9 @@
      */
     public Element(String name, String ns) {
         m_name = name.toLowerCase();
-        m_nameSpace = ns.toLowerCase();
+        if (ns != null && ns.length() > 0) {
+            m_nameSpace = ns.toLowerCase();
+        }
     }
 
     /**
@@ -139,7 +141,7 @@
      * @return the qualified name of the current element.
      */
     private String getQualifiedName() {
-        if (m_nameSpace.equals("")) {
+        if (m_nameSpace == null) {
             return m_name;
         } else {
             return m_nameSpace + ":" + m_name;
@@ -200,7 +202,7 @@
      */
     public void addAttribute(Attribute att) {
         String name = att.getName().toLowerCase();
-        if (!att.getNameSpace().equals("")) {
+        if (att.getNameSpace() != null) {
             name = att.getNameSpace().toLowerCase() + ":" + name;
         }
         m_attributes.put(name, att);
@@ -212,7 +214,7 @@
      */
     public void removeAttribute(Attribute att) {
         String name = att.getName();
-        if (!att.getNameSpace().equals("")) {
+        if (att.getNameSpace() != null) {
             name = att.getNameSpace() + ":" + name;
         }
         m_attributes.remove(name);
@@ -224,8 +226,7 @@
      * @return the resulting element array (empty if the search failed)
      */
     public Element[] getElements(String name) {
-        name = name.toLowerCase();
-        Element[] elems = (Element[]) m_elements.get(name);
+        Element[] elems = (Element[]) m_elements.get(name.toLowerCase());
         if (elems == null) {
             return new Element[0];
         } else {
@@ -300,7 +301,7 @@
             tabs += "\t";
         }
 
-        if ("".equals(m_nameSpace)) {
+        if (m_nameSpace == null) {
             xml = tabs + "<" + m_name;
         } else {
             xml = tabs + "<" + m_nameSpace + ":" + m_name;
@@ -310,7 +311,7 @@
         Iterator it = keys.iterator();
         while (it.hasNext()) {
             Attribute current = (Attribute) m_attributes.get(it.next());
-            if ("".equals(current.getNameSpace())) {
+            if (current.getNameSpace() == null) {
                 xml += " " + current.getName() + "=\"" + current.getValue() + "\"";
             } else {
                 xml += " " + current.getNameSpace() + ":" + current.getName() + "=\"" + current.getValue()
+ "\"";
@@ -358,7 +359,7 @@
             tabs += "\t";
         }
 
-        if ("".equals(m_nameSpace)) {
+        if (m_nameSpace == null) {
             xml = tabs + m_name;
         } else {
             xml = tabs + m_nameSpace + ":" + m_name;
@@ -368,7 +369,7 @@
         Iterator it = keys.iterator();
         while (it.hasNext()) {
             Attribute current = (Attribute) m_attributes.get(it.next());
-            if ("".equals(current.getNameSpace())) {
+            if (current.getNameSpace() == null) {
                 xml += " " + current.getName() + "=\"" + current.getValue() + "\"";
             } else {
                 xml += " " + current.getNameSpace() + ":" + current.getName() + "=\"" + current.getValue()
+ "\"";

Modified: felix/trunk/ipojo/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/pom.xml?rev=585146&r1=585145&r2=585146&view=diff
==============================================================================
--- felix/trunk/ipojo/pom.xml (original)
+++ felix/trunk/ipojo/pom.xml Tue Oct 16 07:04:28 2007
@@ -12,11 +12,11 @@
   <version>0.7.5-SNAPSHOT</version>
   <packaging>pom</packaging>
   <modules>
-	<module>../ipojo/metadata</module>
-    <module>../ipojo/manipulator</module>
-	<module>../ipojo/plugin</module>
-    <module>../ipojo/core</module>
-    <module>../ipojo/arch</module>
-	<module>../ipojo/ant</module>
+	<module>metadata</module>
+    <module>manipulator</module>
+	<module>plugin</module>
+    <module>core</module>
+    <module>arch</module>
+	<module>ant</module>
   </modules>
 </project>



Mime
View raw message