You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2012/07/02 12:57:16 UTC

svn commit: r1356177 - in /felix/trunk/scrplugin: annotations/src/main/java/org/apache/felix/scrplugin/processing/ generator/src/main/java/org/apache/felix/scrplugin/ generator/src/main/java/org/apache/felix/scrplugin/xml/

Author: cziegeler
Date: Mon Jul  2 10:57:16 2012
New Revision: 1356177

URL: http://svn.apache.org/viewvc?rev=1356177&view=rev
Log:
FELIX-3550 : Reimplement the SCR Generator

Modified:
    felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java

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=1356177&r1=1356176&r2=1356177&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 Mon Jul  2 10:57:16 2012
@@ -370,7 +370,7 @@ public class SCRAnnotationProcessor impl
                 index += 2;
             }
 
-            final boolean hasName = ad.getStringValue("name", null) != null;
+            String name = ad.getStringValue("name", null);
 
             if (values != null) {
                 prop.setType(PropertyType.valueOf(type));
@@ -379,9 +379,16 @@ public class SCRAnnotationProcessor impl
                 } else {
                     prop.setMultiValue(values);
                 }
+                if ( name == null ) {
+                    final Object value = fieldAnnotation.getAnnotatedFieldValue();
+                    if (value != null) {
+                        name = value.toString();
+                    }
+                }
+
             } else if (fieldAnnotation != null) {
                 // Detect values from field
-                if ( hasName ) {
+                if ( name != null ) {
                     final Object value = fieldAnnotation.getAnnotatedFieldValue();
                     if (value != null) {
                         if (value.getClass().isArray()) {
@@ -398,26 +405,11 @@ public class SCRAnnotationProcessor impl
                     }
                 } else {
                     prop.setType(PropertyType.String);
-                    prop.setValue(fieldAnnotation.getAnnotatedField().getName());
-                }
-            }
-
-            final String name;
-            if ( hasName ) {
-                name = ad.getStringValue("name", null);
-            } else if (fieldAnnotation != null) {
-                if (values == null) {
                     final Object value = fieldAnnotation.getAnnotatedFieldValue();
                     if (value != null) {
                         name = value.toString();
-                    } else {
-                        name = null;
                     }
-                } else {
-                    name = fieldAnnotation.getAnnotatedField().getName();
                 }
-            } else {
-                name = null;
             }
 
             prop.setName(name);

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java?rev=1356177&r1=1356176&r2=1356177&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java (original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java Mon Jul  2 10:57:16 2012
@@ -433,6 +433,9 @@ public class SCRDescriptorGenerator {
             }
         } while ( current != null);
 
+        // global properties
+        this.processGlobalProperties(desc, container.getProperties());
+
         // PID handling
         if ( componentDesc.isCreatePid() && !container.getProperties().containsKey(org.osgi.framework.Constants.SERVICE_PID)) {
             final PropertyDescription pid = new PropertyDescription(null);
@@ -442,7 +445,6 @@ public class SCRDescriptorGenerator {
 
             container.getProperties().put(org.osgi.framework.Constants.SERVICE_PID, pid);
         }
-        this.processGlobalProperties(desc, container.getProperties());
 
         return container;
     }

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java?rev=1356177&r1=1356176&r2=1356177&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java (original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java Mon Jul  2 10:57:16 2012
@@ -310,7 +310,9 @@ public class ComponentDescriptorIO {
     protected static void generatePropertyXML(PropertyDescription property, ContentHandler contentHandler) throws SAXException {
         final AttributesImpl ai = new AttributesImpl();
         IOUtils.addAttribute(ai, "name", property.getName());
-        IOUtils.addAttribute(ai, "type", property.getType());
+        if ( property.getType() != PropertyType.String ) {
+            IOUtils.addAttribute(ai, "type", property.getType());
+        }
         IOUtils.addAttribute(ai, "value", property.getValue());
 
         IOUtils.indent(contentHandler, 2);