felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1099777 - in /felix/trunk/scrplugin/annotations: ./ src/main/java/org/apache/felix/scr/annotations/sling/ src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/
Date Thu, 05 May 2011 13:03:38 GMT
Author: cziegeler
Date: Thu May  5 13:03:38 2011
New Revision: 1099777

URL: http://svn.apache.org/viewvc?rev=1099777&view=rev
Log:
FELIX-2943 : Component generated by @SlingServlet does not match default settings of @Component

Modified:
    felix/trunk/scrplugin/annotations/changelog.txt
    felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java
    felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
    felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java

Modified: felix/trunk/scrplugin/annotations/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/changelog.txt?rev=1099777&r1=1099776&r2=1099777&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/changelog.txt (original)
+++ felix/trunk/scrplugin/annotations/changelog.txt Thu May  5 13:03:38 2011
@@ -1,6 +1,9 @@
-Changes from 1.5.0 to 1.5.2
+Changes from 1.5.0 to 1.6.0
 ---------------------------
 
+** Bug
+    * [FELIX-2943] - Component generated by @SlingServlet does not match default settings
of @Component
+
 ** Improvement
     * [FELIX-2939] - Maven SCR Plugin is not (marked as) thread-safe for parallel builds
 

Modified: felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java?rev=1099777&r1=1099776&r2=1099777&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java
(original)
+++ felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java
Thu May  5 13:03:38 2011
@@ -18,11 +18,7 @@
  */
 package org.apache.felix.scr.annotations.sling;
 
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import java.lang.annotation.*;
 
 /**
  * Marks servlet classes as SCR component, and allows to configure
@@ -101,4 +97,35 @@ public @interface SlingServlet {
      */
     String[] methods() default {};
 
-}
+    /**
+     * Defines the Component name also used as the PID for the Configuration
+     * Admin Service. Default value: Fully qualified name of the Java class.
+     * @since 1.6
+     */
+    String name() default "";
+
+    /**
+     * Whether Metatype Service data is generated or not. If this parameter is
+     * set to true Metatype Service data is generated in the
+     * <code>metatype.xml</code> file for this component. Otherwise no Metatype
+     * Service data is generated for this component.
+     * @since 1.6
+     */
+    boolean metatype() default false;
+
+    /**
+     * This is generally used as a title for the object described by the meta
+     * type. This name may be localized by prepending a % sign to the name.
+     * Default value: %&lt;name&gt;.name
+     * @since 1.6
+     */
+    String label() default "";
+
+    /**
+     * This is generally used as a description for the object described by the
+     * meta type. This name may be localized by prepending a % sign to the name.
+     * Default value: %&lt;name&gt;.description
+     * @since 1.6
+     */
+    String description() default "";
+ }

Modified: felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java?rev=1099777&r1=1099776&r2=1099777&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
(original)
+++ felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
Thu May  5 13:03:38 2011
@@ -49,7 +49,20 @@ public class SlingAnnotationTagProvider 
             boolean generateComponent = Util.getBooleanValue(annotation, "generateComponent",
SlingServlet.class);
             if (generateComponent)
             {
-                tags.add(new SlingServletComponentTag(annotation, description));
+                String name = Util.getStringValue(annotation, description, "name", SlingServlet.class);
+                if ( name != null && name.trim().length() == 0 ) {
+                    name = null;
+                }
+                String label = Util.getStringValue(annotation, description, "label", SlingServlet.class);
+                if ( label != null && label.trim().length() == 0 ) {
+                    label = null;
+                }
+                String desc = Util.getStringValue(annotation, description, "description",
SlingServlet.class);
+                if ( desc != null && desc.trim().length() == 0 ) {
+                    desc = null;
+                }
+                final boolean createMetatype = Util.getBooleanValue(annotation, "metatype",
SlingServlet.class);
+                tags.add(new SlingServletComponentTag(annotation, description, createMetatype,
name, label, desc));
             }
 
             // generate @Service tag if required

Modified: felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java?rev=1099777&r1=1099776&r2=1099777&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java
(original)
+++ felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java
Thu May  5 13:03:38 2011
@@ -18,7 +18,7 @@
  */
 package org.apache.felix.scrplugin.tags.annotation.sling;
 
-import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.felix.scrplugin.Constants;
@@ -32,11 +32,25 @@ import com.thoughtworks.qdox.model.Annot
  */
 public class SlingServletComponentTag extends AbstractTag {
 
+    private final boolean createMetatype;
+    private final String name;
+    private final String label;
+    private final String description;
+
     /**
      * @param desc Description
      */
-    public SlingServletComponentTag(Annotation annotation, JavaClassDescription desc) {
+    public SlingServletComponentTag(final Annotation annotation,
+            final JavaClassDescription desc,
+            final boolean createMetatype,
+            final String name,
+            final String label,
+            final String description) {
         super(annotation, desc, null);
+        this.createMetatype = createMetatype;
+        this.name = name;
+        this.label = label;
+        this.description = description;
     }
 
     @Override
@@ -51,7 +65,17 @@ public class SlingServletComponentTag ex
 
     @Override
     public Map<String, String> createNamedParameterMap() {
-        return Collections.emptyMap();
+        final Map<String, String> params = new HashMap<String, String>();
+        if ( this.name != null ) {
+            params.put(Constants.COMPONENT_NAME, this.name);
+        }
+        if ( this.label != null ) {
+            params.put(Constants.COMPONENT_LABEL, this.label);
+        }
+        if ( this.description != null ) {
+            params.put(Constants.COMPONENT_DESCRIPTION, this.description);
+        }
+        params.put(Constants.COMPONENT_METATYPE, String.valueOf(this.createMetatype));
+        return params;
     }
-
 }



Mime
View raw message