Fix FELIX-2630 Rename @Component attributes to follow the java naming conventions


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1001605 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Component.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Component.java
index d979768..28fbb2d 100644
--- a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Component.java
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Component.java
@@ -1,4 +1,4 @@
-/* 

+/*

  * Licensed to the Apache Software Foundation (ASF) under one

  * or more contributor license agreements.  See the NOTICE file

  * distributed with this work for additional information

@@ -32,10 +32,17 @@
     /**

      * Set if the component type is public.

      * Default: true

+     * @deprecated renamed to publicFactory.

      */

     boolean public_factory() default true;

 

     /**

+     * Set if the component type is public.

+     * Default: true

+     */

+    boolean publicFactory() default true;

+

+    /**

      * Set the component type name.

      * Default : implementation class name.

      */

@@ -70,10 +77,19 @@
      * from a static method. The specified method must be a static

      * method and return a pojo object.

      * By default, iPOJO uses the 'regular' constructor.

+     * @deprecated now is called <tt>factoryMethod</tt>.

      */

     String factory_method() default "";

 

     /**

+     * Set the factory-method, if the pojo has to be created

+     * from a static method. The specified method must be a static

+     * method and return a pojo object.

+     * By default, iPOJO uses the 'regular' constructor.

+     */

+    String factoryMethod() default "";

+

+    /**

      * Set the version of the component type.

      */

     String version() default "";

diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java
index aaa8767..f3a4836 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java
@@ -65,6 +65,9 @@
      */
     private boolean m_containsComponentAnnotation = false;
 
+    /**
+     * True if the visited class does not have the @Component annotation.
+     */
     private boolean m_ignoredBecauseOfMissingComponent = false;
 
     /**
@@ -460,7 +463,8 @@
          * @see org.objectweb.asm.commons.EmptyVisitor#visit(java.lang.String, java.lang.Object)
          */
         public void visit(String arg0, Object arg1) {
-            if (arg0.equals("public_factory")) {
+            if (arg0.equals("public_factory")  || arg0.equals("publicFactory")) {
+            	// public_factory is deprecated, but must sill be supported
                 m_factory = arg1.toString();
                 return;
             }
@@ -484,7 +488,8 @@
                 m_managedservice = arg1.toString();
                 return;
             }
-            if (arg0.equals("factory_method")) {
+            if (arg0.equals("factory_method")  || arg0.equals("factoryMethod")) {
+            	// factory_method is deprecated, but must still be supported.
                 m_method = arg1.toString();
                 return;
             }
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Factory.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Factory.java
index 5da28e6..0d696d1 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Factory.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Factory.java
@@ -12,6 +12,16 @@
         helper = new IPOJOHelper(this);

     }

 

+    public void testArchDeprecated() {

+        Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.FactoryDeprecated");

+        String fact = meta.getAttribute("public");

+        String name = meta.getAttribute("name");

+        assertNotNull("Factory exists ", fact);

+        assertEquals("Factory value", "true", fact);

+        assertNotNull("Name exists ", name);

+        assertEquals("Name value", "org.apache.felix.ipojo.test.scenarios.component.FactoryDeprecated", name);

+    }

+

     public void testArch() {

         Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.Factory");

         String fact = meta.getAttribute("public");

@@ -39,6 +49,13 @@
         assertEquals("Method value", "create", method);

     }

 

+    public void testFactoryMethodDeprecated() {

+        Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.FactoryMethodDeprecated");

+        String method = meta.getAttribute("factory-method");

+        assertNotNull("Method exists ", method);

+        assertEquals("Method value", "create", method);

+    }

+

     public void testVersion() {

         Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.ComponentTypeVersion");

         String version = meta.getAttribute("version");

diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Factory.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Factory.java
index bafde54..801f798 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Factory.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Factory.java
@@ -2,6 +2,6 @@
 

 import org.apache.felix.ipojo.annotations.Component;

 

-@Component(name="factory", public_factory=true)

+@Component(name="factory", publicFactory=true)

 public class Factory {

 }

diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryDeprecated.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryDeprecated.java
new file mode 100644
index 0000000..bb3e17a
--- /dev/null
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryDeprecated.java
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.test.scenarios.component;

+

+import org.apache.felix.ipojo.annotations.Component;

+

+@Component(public_factory=true)

+public class FactoryDeprecated {

+}

diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethod.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethod.java
index 30c47c4..baa47a5 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethod.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethod.java
@@ -2,9 +2,9 @@
 

 import org.apache.felix.ipojo.annotations.Component;

 

-@Component(factory_method="create")

+@Component(factoryMethod="create")

 public class FactoryMethod {

-    

+

     public static FactoryMethod create() {

         return new FactoryMethod();

     }

diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethodDeprecated.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethodDeprecated.java
new file mode 100644
index 0000000..3f763dd
--- /dev/null
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethodDeprecated.java
@@ -0,0 +1,11 @@
+package org.apache.felix.ipojo.test.scenarios.component;

+

+import org.apache.felix.ipojo.annotations.Component;

+

+@Component(factory_method="create")

+public class FactoryMethodDeprecated {

+    

+    public static FactoryMethodDeprecated create() {

+        return new FactoryMethodDeprecated();

+    }

+}