felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1574483 - in /felix/trunk/scrplugin/annotations: changelog.txt src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java
Date Wed, 05 Mar 2014 13:38:27 GMT
Author: cziegeler
Date: Wed Mar  5 13:38:26 2014
New Revision: 1574483

URL: http://svn.apache.org/r1574483
Log:
FELIX-4393 :  @Property should accept empty name values on instance fields 

Modified:
    felix/trunk/scrplugin/annotations/changelog.txt
    felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java

Modified: felix/trunk/scrplugin/annotations/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/changelog.txt?rev=1574483&r1=1574482&r2=1574483&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/changelog.txt (original)
+++ felix/trunk/scrplugin/annotations/changelog.txt Wed Mar  5 13:38:26 2014
@@ -2,7 +2,7 @@ Changes from 1.9.8 to 1.9.6
 ---------------------------
 ** Improvement
     * [FELIX-4277] - The maven-scr-plugin generates false warnings when using @SlingServlet
-
+    * [FELIX-4393] - @Property should accept empty name values on instance fields 
 
 Changes from 1.9.6 to 1.9.4
 ---------------------------

Modified: felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java?rev=1574483&r1=1574482&r2=1574483&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java
(original)
+++ felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java
Wed Mar  5 13:38:26 2014
@@ -403,9 +403,29 @@ public class SCRAnnotationProcessor impl
                         }
                     }
                 } else {
-                    final Object value = fieldAnnotation.getAnnotatedFieldValue();
-                    if (value != null) {
-                        name = value.toString();
+                    if ( Modifier.isStatic(fieldAnnotation.getAnnotatedField().getModifiers())
) {
+                        final Object value = fieldAnnotation.getAnnotatedFieldValue();
+                        if (value != null) {
+                            name = value.toString();
+                        }
+                    } else {
+                        // non static, no name, no value (FELIX-4393)
+                        name = fieldAnnotation.getAnnotatedField().getName();
+                        final Object value = fieldAnnotation.getAnnotatedFieldValue();
+                        if (value != null) {
+                            if (value.getClass().isArray()) {
+                                final String[] newValues = new String[Array.getLength(value)];
+                                for (int i = 0; i < newValues.length; i++) {
+                                    newValues[i] = Array.get(value, i).toString();
+                                }
+                                prop.setMultiValue(newValues);
+                                prop.setType(PropertyType.from(fieldAnnotation.getAnnotatedField().getType().getComponentType()));
+                            } else {
+                                prop.setType(PropertyType.from(value.getClass()));
+                                prop.setValue(value.toString());
+                            }
+                        }
+
                     }
                 }
             }



Mime
View raw message