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 2014/12/02 16:36:19 UTC

svn commit: r1642907 - in /felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation: ClassMetadataCollector.java ComponentWorkbench.java visitor/ComponentVisitor.java

Author: clement
Date: Tue Dec  2 15:36:19 2014
New Revision: 1642907

URL: http://svn.apache.org/r1642907
Log:
Fix FELIX-4620

Modified:
    felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/ClassMetadataCollector.java
    felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/ComponentWorkbench.java
    felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/ComponentVisitor.java

Modified: felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/ClassMetadataCollector.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/ClassMetadataCollector.java?rev=1642907&r1=1642906&r2=1642907&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/ClassMetadataCollector.java (original)
+++ felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/ClassMetadataCollector.java Tue Dec  2 15:36:19 2014
@@ -98,6 +98,12 @@ public class ClassMetadataCollector exte
      * @see org.objectweb.asm.ClassVisitor#visitAnnotation(java.lang.String, boolean)
      */
     public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+        //TODO we should find a better way to do this.
+        // Cannot retrieve the class object as @Configuration is in iPOJO runtime.
+        if (Type.getType(desc).getClassName().equals("org.apache.felix.ipojo.configuration.Configuration")) {
+            workbench.ignore(true);
+            return null;
+        }
 
         // Return the visitor to be executed (may be null)
         return registry.selection(workbench)
@@ -152,6 +158,11 @@ public class ClassMetadataCollector exte
             if (workbench.getRoot() == null) {
                 // No 'top-level' element has been contributed
 
+                if (workbench.ignore()) {
+                    // Ignore this class.
+                    return;
+                }
+
                 if (!workbench.getElements().isEmpty()) {
                     // There are other annotation's contribution on this type (additional handler declaration/configuration)
                     // That means that there is a missing 'component type' annotation

Modified: felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/ComponentWorkbench.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/ComponentWorkbench.java?rev=1642907&r1=1642906&r2=1642907&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/ComponentWorkbench.java (original)
+++ felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/ComponentWorkbench.java Tue Dec  2 15:36:19 2014
@@ -63,6 +63,11 @@ public class ComponentWorkbench {
 
     private ClassNode classNode;
 
+    /**
+     * A flag indicating if the class needs to be ignored.
+     */
+    private boolean toIgnore;
+
     public ComponentWorkbench(BindingRegistry bindingRegistry, ClassNode node) {
         this.bindingRegistry = bindingRegistry;
         this.classNode = node;
@@ -83,6 +88,7 @@ public class ComponentWorkbench {
 
     /**
      * The identified root Element. May be null if at the visit time, the root as not been identified.
+     *
      * @return the root Element. or {@literal null} if not defined at the execution time.
      */
     public Element getRoot() {
@@ -149,4 +155,22 @@ public class ComponentWorkbench {
         return root;
 
     }
+
+    /**
+     * Checks whether this class must be ignored.
+     *
+     * @return {@code true} if the class is ignored.
+     */
+    public boolean ignore() {
+        return toIgnore;
+    }
+
+    /**
+     * Sets the 'ignore' aspect of the current class.
+     *
+     * @param ignore whether or not the class must be ignored.
+     */
+    public void ignore(boolean ignore) {
+        this.toIgnore = ignore;
+    }
 }

Modified: felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/ComponentVisitor.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/ComponentVisitor.java?rev=1642907&r1=1642906&r2=1642907&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/ComponentVisitor.java (original)
+++ felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/annotation/visitor/ComponentVisitor.java Tue Dec  2 15:36:19 2014
@@ -60,7 +60,7 @@ public class ComponentVisitor extends An
         if (name.equals("public_factory")  || name.equals("publicFactory")) {
             // public_factory is deprecated, but must sill be supported
             String factory = value.toString();
-            if (factory != null && factory.equalsIgnoreCase("false")) {
+            if (factory.equalsIgnoreCase("false")) {
                 component.addAttribute(new Attribute("public", "false"));
             } else {
                 component.addAttribute(new Attribute("public", "true"));