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 2009/04/23 07:52:05 UTC

svn commit: r767809 - in /felix/trunk: scr-annotations/src/main/java/org/apache/felix/scr/annotations/ scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/ scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/

Author: cziegeler
Date: Thu Apr 23 05:52:04 2009
New Revision: 767809

URL: http://svn.apache.org/viewvc?rev=767809&view=rev
Log:
FELIX-1010 : Several fixes for the annotations stuff; removed obsolete methods from interface and fixed property handling.

Modified:
    felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Property.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java

Modified: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Property.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Property.java?rev=767809&r1=767808&r2=767809&view=diff
==============================================================================
--- felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Property.java (original)
+++ felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Property.java Thu Apr 23 05:52:04 2009
@@ -40,7 +40,7 @@
     /**
      * The name of the property
      */
-    String name();
+    String name() default "";
 
     /**
      * The label to display in a form to configure this property. This name may
@@ -61,7 +61,7 @@
      * of the value is done using the valueOf(String) method of the class
      * defined by the property type.
      */
-    String[] value();
+    String[] value() default "";
 
     /**
      * The type of the property value. This must be one of {@link String},

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java?rev=767809&r1=767808&r2=767809&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java Thu Apr 23 05:52:04 2009
@@ -18,7 +18,6 @@
  */
 package org.apache.felix.scrplugin.tags.annotation;
 
-import java.lang.annotation.Annotation;
 import java.util.*;
 
 import org.apache.felix.scrplugin.tags.*;
@@ -48,14 +47,6 @@
      */
     @Override
     public JavaTag getTagByName(String name) {
-        for (Annotation annotation : this.clazz.getAnnotations()) {
-            List<JavaTag> tags = manager.getAnnotationTagProviderManager().getTags(annotation, this);
-            for (JavaTag tag : tags) {
-                if (tag.getName().equals(name)) {
-                    return tag;
-                }
-            }
-        }
         for(com.thoughtworks.qdox.model.Annotation annotation : this.javaClass.getAnnotations()) {
             List<JavaTag> tags = manager.getAnnotationTagProviderManager().getTags(annotation, this);
             for (JavaTag tag : tags) {
@@ -74,15 +65,6 @@
     public JavaTag[] getTagsByName(String name, boolean inherited) throws MojoExecutionException {
 
         List<JavaTag> tags = new ArrayList<JavaTag>();
-
-        for (Annotation annotation : this.clazz.getAnnotations()) {
-            List<JavaTag> annotationTags = manager.getAnnotationTagProviderManager().getTags(annotation, this);
-            for (JavaTag tag : annotationTags) {
-                if (tag.getName().equals(name)) {
-                    tags.add(tag);
-                }
-            }
-        }
         for(com.thoughtworks.qdox.model.Annotation annotation : this.javaClass.getAnnotations()) {
             List<JavaTag> annotationTags = manager.getAnnotationTagProviderManager().getTags(annotation, this);
             for (JavaTag tag : annotationTags) {

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java?rev=767809&r1=767808&r2=767809&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java Thu Apr 23 05:52:04 2009
@@ -18,12 +18,13 @@
  */
 package org.apache.felix.scrplugin.tags.annotation;
 
-import java.lang.annotation.Annotation;
 import java.util.List;
 
 import org.apache.felix.scrplugin.tags.JavaField;
 import org.apache.felix.scrplugin.tags.JavaTag;
 
+import com.thoughtworks.qdox.model.Annotation;
+
 /**
  * Interface for provider classes, that map java annotations to {@link JavaTag}
  * implementations.
@@ -40,15 +41,4 @@
      *         cannot map the annotation to any tag instance.
      */
     List<JavaTag> getTags(Annotation pAnnotation, AnnotationJavaClassDescription description, JavaField field);
-
-    /**
-     * Maps a annotation to one or many {@link JavaTag} implementations.
-     * @param pAnnotation Java annotation
-     * @param description Annotations-based java class description
-     * @param field Reference to field (set on field-level annotations, null on
-     *            other annotations)
-     * @return List of tag implementations. Return empty list if this provider
-     *         cannot map the annotation to any tag instance.
-     */
-    List<JavaTag> getTags(com.thoughtworks.qdox.model.Annotation pAnnotation, AnnotationJavaClassDescription description, JavaField field);
 }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java?rev=767809&r1=767808&r2=767809&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java Thu Apr 23 05:52:04 2009
@@ -18,7 +18,6 @@
  */
 package org.apache.felix.scrplugin.tags.annotation;
 
-import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -27,6 +26,7 @@
 import org.apache.felix.scrplugin.tags.annotation.defaulttag.DefaultAnnotationTagProvider;
 import org.apache.maven.plugin.MojoFailureException;
 
+import com.thoughtworks.qdox.model.Annotation;
 import com.thoughtworks.qdox.model.JavaClass;
 
 /**
@@ -93,17 +93,6 @@
      *
      * @param annotation Java annotation
      * @param description Description
-     * @return Tag declaration or null if no mapping found
-     */
-    public List<JavaTag> getTags(com.thoughtworks.qdox.model.Annotation annotation, AnnotationJavaClassDescription description) {
-        return getTags(annotation, description, null);
-    }
-
-    /**
-     * Converts a java annotation to {@link JavaTag} if a mapping can be found.
-     *
-     * @param annotation Java annotation
-     * @param description Description
      * @param field Field
      * @return Tag declaration or null if no mapping found
      */
@@ -118,38 +107,6 @@
     }
 
     /**
-     * Converts a java annotation to {@link JavaTag} if a mapping can be found.
-     *
-     * @param annotation Java annotation
-     * @param description Description
-     * @param field Field
-     * @return Tag declaration or null if no mapping found
-     */
-    public List<JavaTag> getTags(com.thoughtworks.qdox.model.Annotation annotation, AnnotationJavaClassDescription description, JavaField field) {
-        List<JavaTag> tags = new ArrayList<JavaTag>();
-
-        for (AnnotationTagProvider provider : this.annotationTagProviders) {
-            tags.addAll(provider.getTags(annotation, description, field));
-        }
-
-        return tags;
-    }
-
-    /**
-     * Checks if the given class has any SCR plugin java annotations defined.
-     * @param pClass Class
-     * @return true if SCR plugin java annotation found
-     */
-    public boolean hasScrPluginAnnotation(Class<?> pClass) {
-        for (Annotation annotation : pClass.getAnnotations()) {
-            if (getTags(annotation, null).size() > 0) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
      * Checks if the given class has any SCR plugin java annotations defined.
      * @param pClass Class
      * @return true if SCR plugin java annotation found

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java?rev=767809&r1=767808&r2=767809&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java Thu Apr 23 05:52:04 2009
@@ -34,21 +34,15 @@
 
     protected final Component annotation;
 
-    /**
-     * @param annotation Annotation
-     * @param desc Description
-     */
-    public ComponentTag(Component annotation, JavaClassDescription desc) {
-        super(desc, null);
-        this.annotation = annotation;
-    }
+    protected final Annotation sourceAnnotation;
 
     /**
      * @param annotation Annotation
      * @param desc Description
      */
-    public ComponentTag(final Annotation annotation, JavaClassDescription desc) {
+    public ComponentTag(final Annotation annotation, final JavaClassDescription desc) {
         super(desc, null);
+        this.sourceAnnotation = annotation;
         this.annotation = new Component() {
 
             public boolean componentAbstract() {
@@ -60,7 +54,7 @@
             }
 
             public String description() {
-                return Util.getStringValue(annotation, "description", Component.class);
+                return Util.getStringValue(annotation, desc, "description", Component.class);
             }
 
             public boolean ds() {
@@ -72,7 +66,7 @@
             }
 
             public String factory() {
-                return Util.getStringValue(annotation, "factory", Component.class);
+                return Util.getStringValue(annotation, desc, "factory", Component.class);
             }
 
             public boolean immediate() {
@@ -84,7 +78,7 @@
             }
 
             public String label() {
-                return Util.getStringValue(annotation, "label", Component.class);
+                return Util.getStringValue(annotation, desc, "label", Component.class);
             }
 
             public boolean metatype() {
@@ -92,7 +86,7 @@
             }
 
             public String name() {
-                return Util.getStringValue(annotation, "name", Component.class);
+                return Util.getStringValue(annotation, desc, "name", Component.class);
             }
 
             public Class<? extends java.lang.annotation.Annotation> annotationType() {
@@ -115,7 +109,11 @@
         map.put(Constants.COMPONENT_DESCRIPTION, emptyToNull(this.annotation.description()));
         map.put(Constants.COMPONENT_ENABLED, String.valueOf(this.annotation.enabled()));
         map.put(Constants.COMPONENT_FACTORY, emptyToNull(this.annotation.factory()));
-        map.put(Constants.COMPONENT_IMMEDIATE, String.valueOf(this.annotation.immediate()));
+        // FELIX-593: immediate attribute does not default to true all the
+        // times hence we only set it if declared in the tag
+        if ( this.sourceAnnotation.getNamedParameter("immediate") != null) {
+            map.put(Constants.COMPONENT_IMMEDIATE, this.sourceAnnotation.getNamedParameter("immediate").toString());
+        }
         map.put(Constants.COMPONENT_INHERIT, String.valueOf(this.annotation.inherit()));
         map.put(Constants.COMPONENT_METATYPE, String.valueOf(this.annotation.metatype()));
         map.put(Constants.COMPONENT_ABSTRACT, String.valueOf(this.annotation.componentAbstract()));

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java?rev=767809&r1=767808&r2=767809&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java Thu Apr 23 05:52:04 2009
@@ -18,7 +18,6 @@
  */
 package org.apache.felix.scrplugin.tags.annotation.defaulttag;
 
-import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -28,51 +27,17 @@
 import org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription;
 import org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider;
 
+import com.thoughtworks.qdox.model.Annotation;
+
 /**
  * Provides mapping of default SCR annotations to tag implementations.
  */
 public class DefaultAnnotationTagProvider implements AnnotationTagProvider {
 
     /**
-     * @see AnnotationTagProvider#getTags(Annotation,
-     *      AnnotationJavaClassDescription, JavaField)
-     */
-    public List<JavaTag> getTags(Annotation annotation, AnnotationJavaClassDescription description, JavaField field) {
-        List<JavaTag> tags = new ArrayList<JavaTag>();
-
-        // check for single annotations
-        if (annotation instanceof Component) {
-            tags.add(new ComponentTag((Component) annotation, description));
-        } else if (annotation instanceof Property) {
-            tags.add(new PropertyTag((Property) annotation, description));
-        } else if (annotation instanceof Service) {
-            tags.add(new ServiceTag((Service) annotation, description));
-        } else if (annotation instanceof Reference) {
-            tags.add(new ReferenceTag((Reference) annotation, description, field));
-        }
-
-        // check for multi-annotations
-        else if (annotation instanceof Properties) {
-            for (Property property : ((Properties) annotation).value()) {
-                tags.add(new PropertyTag(property, description));
-            }
-        } else if (annotation instanceof Services) {
-            for (Service service : ((Services) annotation).value()) {
-                tags.add(new ServiceTag(service, description));
-            }
-        } else if (annotation instanceof References) {
-            for (Reference reference : ((References) annotation).value()) {
-                tags.add(new ReferenceTag(reference, description, field));
-            }
-        }
-
-        return tags;
-    }
-
-    /**
-     * @see org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider#getTags(java.lang.annotation.Annotation, org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription, org.apache.felix.scrplugin.tags.JavaField)
+     * @see org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider#getTags(Annotation, org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription, org.apache.felix.scrplugin.tags.JavaField)
      */
-    public List<JavaTag> getTags(com.thoughtworks.qdox.model.Annotation annotation,
+    public List<JavaTag> getTags(Annotation annotation,
                                  AnnotationJavaClassDescription description, JavaField field) {
         List<JavaTag> tags = new ArrayList<JavaTag>();
 
@@ -80,7 +45,7 @@
         if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(Component.class.getName())) {
             tags.add(new ComponentTag(annotation, description));
         } else if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(Property.class.getName())) {
-            tags.add(new PropertyTag(annotation, description));
+            tags.add(new PropertyTag(annotation, description, field));
         } else if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(Service.class.getName())) {
             tags.add(new ServiceTag(annotation, description));
         } else if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(Reference.class.getName())) {
@@ -89,18 +54,21 @@
 
         // check for multi-annotations
         else if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(Properties.class.getName())) {
-            final List<com.thoughtworks.qdox.model.Annotation> properties = (List<com.thoughtworks.qdox.model.Annotation>)annotation.getNamedParameter("value");
-            for (com.thoughtworks.qdox.model.Annotation property : properties) {
-                tags.add(new PropertyTag(property, description));
+            @SuppressWarnings("unchecked")
+            final List<Annotation> properties = (List<Annotation>)annotation.getNamedParameter("value");
+            for (Annotation property : properties) {
+                tags.add(new PropertyTag(property, description, field));
             }
         } else if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(Services.class.getName())) {
-            final List<com.thoughtworks.qdox.model.Annotation> services = (List<com.thoughtworks.qdox.model.Annotation>)annotation.getNamedParameter("value");
-            for (com.thoughtworks.qdox.model.Annotation service : services) {
+            @SuppressWarnings("unchecked")
+            final List<Annotation> services = (List<Annotation>)annotation.getNamedParameter("value");
+            for (Annotation service : services) {
                 tags.add(new ServiceTag(service, description));
             }
         } else if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(References.class.getName())) {
-            final List<com.thoughtworks.qdox.model.Annotation> references = (List<com.thoughtworks.qdox.model.Annotation>)annotation.getNamedParameter("value");
-            for (com.thoughtworks.qdox.model.Annotation reference : references) {
+            @SuppressWarnings("unchecked")
+            final List<Annotation> references = (List<Annotation>)annotation.getNamedParameter("value");
+            for (Annotation reference : references) {
                 tags.add(new ReferenceTag(reference, description, field));
             }
         }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java?rev=767809&r1=767808&r2=767809&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java Thu Apr 23 05:52:04 2009
@@ -23,6 +23,7 @@
 import org.apache.felix.scr.annotations.*;
 import org.apache.felix.scrplugin.Constants;
 import org.apache.felix.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.scrplugin.tags.JavaField;
 
 import com.thoughtworks.qdox.model.Annotation;
 
@@ -37,17 +38,8 @@
      * @param annotation Annotation
      * @param desc Description
      */
-    public PropertyTag(Property annotation, JavaClassDescription desc) {
-        super(desc, null);
-        this.annotation = annotation;
-    }
-
-    /**
-     * @param annotation Annotation
-     * @param desc Description
-     */
-    public PropertyTag(final Annotation annotation, JavaClassDescription desc) {
-        super(desc, null);
+    public PropertyTag(final Annotation annotation, final JavaClassDescription desc, JavaField field) {
+        super(desc, field);
         this.annotation = new Property() {
 
             public int cardinality() {
@@ -55,15 +47,15 @@
             }
 
             public String description() {
-                return Util.getStringValue(annotation, "description", Property.class);
+                return Util.getStringValue(annotation, desc, "description", Property.class);
             }
 
             public String label() {
-                return Util.getStringValue(annotation, "label", Property.class);
+                return Util.getStringValue(annotation, desc, "label", Property.class);
             }
 
             public String name() {
-                return Util.getStringValue(annotation, "name", Property.class);
+                return Util.getStringValue(annotation, desc, "name", Property.class);
             }
 
             public PropertyOption[] options() {
@@ -89,8 +81,7 @@
 
             public String[] value() {
                 // value property can be used as String[] or String property
-                Object obj = annotation.getNamedParameter("value");
-                return Util.getStringValues(annotation, "value", Property.class);
+                return Util.getStringValues(annotation, desc, "value", Property.class);
             }
 
             public Class<? extends java.lang.annotation.Annotation> annotationType() {

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java?rev=767809&r1=767808&r2=767809&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java Thu Apr 23 05:52:04 2009
@@ -38,24 +38,14 @@
     /**
      * @param annotation Annotation
      * @param desc Description
-     * @param field Field
      */
-    public ReferenceTag(Reference annotation, JavaClassDescription desc, JavaField field) {
-        super(desc, field);
-        this.annotation = annotation;
-    }
-
-    /**
-     * @param annotation Annotation
-     * @param desc Description
-     */
-    public ReferenceTag(final Annotation annotation, JavaClassDescription desc, JavaField field) {
+    public ReferenceTag(final Annotation annotation, final JavaClassDescription desc, JavaField field) {
         super(desc, field);
 
         this.annotation = new Reference() {
 
             public String bind() {
-                return Util.getStringValue(annotation, "bind", Reference.class);
+                return Util.getStringValue(annotation, desc, "bind", Reference.class);
             }
 
             public ReferenceCardinality cardinality() {
@@ -67,7 +57,7 @@
             }
 
             public String name() {
-                return Util.getStringValue(annotation, "name", Reference.class);
+                return Util.getStringValue(annotation, desc, "name", Reference.class);
             }
 
             public ReferencePolicy policy() {
@@ -79,15 +69,15 @@
             }
 
             public String strategy() {
-                return Util.getStringValue(annotation, "strategy", Reference.class);
+                return Util.getStringValue(annotation, desc, "strategy", Reference.class);
             }
 
             public String target() {
-                return Util.getStringValue(annotation, "target", Reference.class);
+                return Util.getStringValue(annotation, desc, "target", Reference.class);
             }
 
             public String unbind() {
-                return Util.getStringValue(annotation, "unbind", Reference.class);
+                return Util.getStringValue(annotation, desc, "unbind", Reference.class);
             }
 
             public Class<? extends java.lang.annotation.Annotation> annotationType() {

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java?rev=767809&r1=767808&r2=767809&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java Thu Apr 23 05:52:04 2009
@@ -39,15 +39,6 @@
      * @param annotation Annotation
      * @param desc Description
      */
-    public ServiceTag(Service annotation, JavaClassDescription desc) {
-        super(desc, null);
-        this.annotation = annotation;
-    }
-
-    /**
-     * @param annotation Annotation
-     * @param desc Description
-     */
     public ServiceTag(final Annotation annotation, JavaClassDescription desc) {
         super(desc, null);
         this.annotation = new Service() {

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java?rev=767809&r1=767808&r2=767809&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java Thu Apr 23 05:52:04 2009
@@ -19,23 +19,28 @@
 package org.apache.felix.scrplugin.tags.annotation.defaulttag;
 
 import java.util.ArrayList;
-import java.util.EnumSet;
 import java.util.List;
 
-import org.apache.felix.scrplugin.tags.ClassUtil;
+import org.apache.felix.scrplugin.tags.*;
+import org.apache.maven.plugin.MojoExecutionException;
 
 import com.thoughtworks.qdox.model.Annotation;
 
+/**
+ * Helper class for getting values from annotations.
+ */
 public abstract class Util {
 
+    /**
+     * Get a boolean value from an annotation.
+     * @param annotation The annotation.
+     * @param name The name of the attribute.
+     * @param clazz The annotation class.
+     * @return The boolean value.
+     */
     public static boolean getBooleanValue(Annotation annotation, String name, final Class<?> clazz) {
         final Object obj = annotation.getNamedParameter(name);
         if ( obj != null ) {
-            if ( obj instanceof String ) {
-                return Boolean.valueOf((String)obj);
-            } else if ( obj instanceof Boolean ) {
-                return (Boolean)obj;
-            }
             return Boolean.valueOf(obj.toString());
         }
         try {
@@ -64,7 +69,7 @@
         }
     }
 
-    public static String[] getStringValues(Annotation annotation, String name, final Class<?> clazz) {
+    public static String[] getStringValues(Annotation annotation, JavaClassDescription desc, String name, final Class<?> clazz) {
         final Object obj = annotation.getNamedParameter(name);
         if ( obj != null ) {
             List<String> list;
@@ -77,7 +82,7 @@
             }
             String[] values = new String[list.size()];
             for (int i=0; i<values.length; i++) {
-                values[i] = stripQuotes(list.get(i));
+                values[i] = stripQuotes(desc, list.get(i));
             }
             return values;
         }
@@ -89,11 +94,11 @@
         }
     }
 
-    public static String getStringValue(Annotation annotation, String name, final Class<?> clazz) {
+    public static String getStringValue(Annotation annotation, JavaClassDescription desc, String name, final Class<?> clazz) {
         final Object obj = annotation.getNamedParameter(name);
         if ( obj != null ) {
             if ( obj instanceof String ) {
-                return stripQuotes((String)obj);
+                return stripQuotes(desc, (String)obj);
             }
             return obj.toString();
         }
@@ -104,17 +109,40 @@
             return "";
         }
     }
-    
+
     /**
-     * QDox annotations seemt to return annotation values always with quotes - remove them
+     * QDox annotations seem to return annotation values always with quotes - remove them.
+     * If the string value does not contain a string, it's a reference to a field!
      * @param s String with our without quotes
      * @return String without quotes
      */
-    private static String stripQuotes(String s) {
-        if (s.startsWith("\"") && s.endsWith("\"")) {
-            return s.substring(1, s.length() - 1);
+    private static String stripQuotes(final JavaClassDescription desc, String s)
+    throws IllegalArgumentException {
+        try {
+            s = s.trim();
+            if (s.startsWith("\"") && s.endsWith("\"")) {
+                return s.substring(1, s.length() - 1);
+            }
+            int classSep = s.lastIndexOf('.');
+            JavaField field = null;
+            if ( classSep == -1 ) {
+                // local variable
+                field = desc.getFieldByName(s);
+            }
+            if ( field == null ) {
+                field = desc.getExternalFieldByName(s);
+            }
+            if ( field == null ) {
+                throw new IllegalArgumentException("Property references unknown field " + s + " in class " + desc.getName());
+            }
+            String[] values = field.getInitializationExpression();
+            if ( values != null && values.length == 1 ) {
+                return values[0];
+            }
+            throw new IllegalArgumentException("Something is wrong.");
+        } catch (MojoExecutionException mee) {
+            throw new IllegalArgumentException(mee);
         }
-        return s;
     }
 
     public static Class<?> getClassValue(Annotation annotation, String name, final Class<?> clazz) {
@@ -152,7 +180,8 @@
                 if (dotPos >= 0) {
                     enumName = enumName.substring(dotPos+1);
                 }
-                return (T)Enum.valueOf(enumClass, enumName);
+                Object o = Enum.valueOf(enumClass, enumName);
+                return (T)o;
             }
         }
         return null;