FELIX-2943 : Component generated by @SlingServlet does not match default settings of @Component

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1099777 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/annotations/changelog.txt b/scrplugin/annotations/changelog.txt
index e846651..cfac5a0 100644
--- a/scrplugin/annotations/changelog.txt
+++ b/scrplugin/annotations/changelog.txt
@@ -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
 
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java b/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java
index a748680..526794e 100644
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java
+++ b/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java
@@ -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 @@
      */
     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 "";
+ }
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
index 041b989..5f37691 100644
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
+++ b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
@@ -49,7 +49,20 @@
             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
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java
index 84450a6..5fa4ae1 100644
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java
+++ b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java
@@ -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 @@
  */
 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 @@
 
     @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;
     }
-
 }