felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1548797 - in /felix/trunk/ipojo/manipulator/manipulator/src: main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/module/ main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/ main/java/org/apache/felix/ipoj...
Date Sat, 07 Dec 2013 07:08:34 GMT
Author: clement
Date: Sat Dec  7 07:08:33 2013
New Revision: 1548797

URL: http://svn.apache.org/r1548797
Log:
Remove traces, add test checking static inner classes

Modified:
    felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/module/DefaultBindingModule.java
    felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/RequiresVisitor.java
    felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/generic/GenericVisitorFactory.java
    felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/generic/RootGenericVisitor.java
    felix/trunk/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/InnerClassAdapterTest.java
    felix/trunk/ipojo/manipulator/manipulator/src/test/java/test/inner/ComponentWithInnerClasses.java

Modified: felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/module/DefaultBindingModule.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/module/DefaultBindingModule.java?rev=1548797&r1=1548796&r2=1548797&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/module/DefaultBindingModule.java
(original)
+++ felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/module/DefaultBindingModule.java
Sat Dec  7 07:08:33 2013
@@ -19,24 +19,7 @@
 
 package org.apache.felix.ipojo.manipulator.metadata.annotation.module;
 
-import org.apache.felix.ipojo.annotations.Bind;
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Controller;
-import org.apache.felix.ipojo.annotations.Handler;
-import org.apache.felix.ipojo.annotations.HandlerDeclaration;
-import org.apache.felix.ipojo.annotations.Instantiate;
-import org.apache.felix.ipojo.annotations.Invalidate;
-import org.apache.felix.ipojo.annotations.Modified;
-import org.apache.felix.ipojo.annotations.PostRegistration;
-import org.apache.felix.ipojo.annotations.PostUnregistration;
-import org.apache.felix.ipojo.annotations.Property;
-import org.apache.felix.ipojo.annotations.Provides;
-import org.apache.felix.ipojo.annotations.Requires;
-import org.apache.felix.ipojo.annotations.ServiceController;
-import org.apache.felix.ipojo.annotations.ServiceProperty;
-import org.apache.felix.ipojo.annotations.Unbind;
-import org.apache.felix.ipojo.annotations.Updated;
-import org.apache.felix.ipojo.annotations.Validate;
+import org.apache.felix.ipojo.annotations.*;
 import org.apache.felix.ipojo.manipulator.Reporter;
 import org.apache.felix.ipojo.manipulator.metadata.annotation.ComponentWorkbench;
 import org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.ComponentVisitor;
@@ -56,6 +39,8 @@ import org.apache.felix.ipojo.manipulato
 import org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.bind.Action;
 import org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.bind.MethodBindVisitor;
 import org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.bind.ParameterBindVisitor;
+import org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.generic.GenericVisitor;
+import org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.generic.GenericVisitorFactory;
 import org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.util.Elements;
 import org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.util.Names;
 import org.apache.felix.ipojo.manipulator.spi.AbsBindingModule;
@@ -285,6 +270,8 @@ public class DefaultBindingModule extend
                         return new PostRegistrationVisitor(context.getWorkbench(), node.name);
                     }
                 });
+
+        bind(Context.class).to(new GenericVisitorFactory("context", ""));
     }
 
     private DocumentBuilder m_builder;

Modified: felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/RequiresVisitor.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/RequiresVisitor.java?rev=1548797&r1=1548796&r2=1548797&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/RequiresVisitor.java
(original)
+++ felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/RequiresVisitor.java
Sat Dec  7 07:08:33 2013
@@ -178,7 +178,7 @@ public class RequiresVisitor extends Emp
     @Override
     public void visitEnum(String name, String desc, String value) {
         if (name.equals("policy")) {
-            m_policy = getPolicy(value.toString());
+            m_policy = getPolicy(value);
         }
     }
 

Modified: felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/generic/GenericVisitorFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/generic/GenericVisitorFactory.java?rev=1548797&r1=1548796&r2=1548797&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/generic/GenericVisitorFactory.java
(original)
+++ felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/generic/GenericVisitorFactory.java
Sat Dec  7 07:08:33 2013
@@ -43,6 +43,7 @@ public class GenericVisitorFactory imple
 
     // Need to build a new Element instance for each created visitor
     public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
+        System.out.println("Create annotation visitor for " + context.getNode());
         if (context.getNode() instanceof ClassNode) {
             return new TypeGenericVisitor(context.getWorkbench(),
                                           new Element(m_name, m_namespace));

Modified: felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/generic/RootGenericVisitor.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/generic/RootGenericVisitor.java?rev=1548797&r1=1548796&r2=1548797&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/generic/RootGenericVisitor.java
(original)
+++ felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/generic/RootGenericVisitor.java
Sat Dec  7 07:08:33 2013
@@ -70,6 +70,8 @@ public class RootGenericVisitor extends 
         }
     }
 
+
+
     /**
      * End of the visit.
      * All attribute were visited, we can update collectors data.
@@ -84,7 +86,7 @@ public class RootGenericVisitor extends 
         } else {
             // No ID provided, generate a new one from the element's namespace (aka handler's
namespace)
             m_id = element.getNameSpace();
-            if (!workbench.getIds().containsKey(m_id) && isClassType()) {
+            if (m_id != null  && !workbench.getIds().containsKey(m_id) &&
isClassType()) {
                 // No Elements were already registered under that namespace
                 workbench.getIds().put(m_id, element);
             } else {

Modified: felix/trunk/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/InnerClassAdapterTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/InnerClassAdapterTest.java?rev=1548797&r1=1548796&r2=1548797&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/InnerClassAdapterTest.java
(original)
+++ felix/trunk/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/InnerClassAdapterTest.java
Sat Dec  7 07:08:33 2013
@@ -170,9 +170,6 @@ public class InnerClassAdapterTest {
 
         ManipulatedClassLoader classloader = manipulate(className, manipulator);
 
-
-
-
         Class cl = classloader.findClass(className);
         Assert.assertNotNull(cl);
         Assert.assertNotNull(manipulator.getManipulationMetadata());
@@ -322,4 +319,29 @@ public class InnerClassAdapterTest {
         assertThat(clazz.getDeclaredField(flag)).isNotNull();
     }
 
+    @Test
+    public void testThatStaticInnerClassesAreNotManipulated() throws Exception {
+        Manipulator manipulator = new Manipulator();
+        String className = "test.inner.ComponentWithInnerClasses";
+        ManipulatedClassLoader classLoader = manipulate(className, manipulator);
+
+        Class clazz = classLoader.findClass(className);
+        Class inner = findInnerClass(clazz.getClasses(), "MyStaticInnerClass");
+        assertThat(inner).isNotNull();
+        Method bar = inner.getMethod("bar");
+        Object o = inner.newInstance();
+        bar.setAccessible(true);
+        assertThat(bar).isNotNull();
+        assertThat((String) bar.invoke(o)).isEqualTo("bar");
+    }
+
+    private Class findInnerClass(Class[] classes, String name) {
+        for (Class clazz : classes) {
+            if (clazz.getName().contains(name)) {
+                return clazz;
+            }
+        }
+        return null;
+    }
+
 }

Modified: felix/trunk/ipojo/manipulator/manipulator/src/test/java/test/inner/ComponentWithInnerClasses.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator/src/test/java/test/inner/ComponentWithInnerClasses.java?rev=1548797&r1=1548796&r2=1548797&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/manipulator/src/test/java/test/inner/ComponentWithInnerClasses.java
(original)
+++ felix/trunk/ipojo/manipulator/manipulator/src/test/java/test/inner/ComponentWithInnerClasses.java
Sat Dec  7 07:08:33 2013
@@ -81,6 +81,7 @@ public class ComponentWithInnerClasses{
         public native void baz();
     }
 
+
     private class MyInnerClass {
         public String foo() {
             return ComponentWithInnerClasses.this.foo;



Mime
View raw message