FELIX-4063 : Avoid warnings when using @SlingServlet and @SlingFilter annotations . Apply modified patch from Julian Sedding

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1482216 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/annotations/changelog.txt b/scrplugin/annotations/changelog.txt
index 46e465e..fb1d0cc 100644
--- a/scrplugin/annotations/changelog.txt
+++ b/scrplugin/annotations/changelog.txt
@@ -1,7 +1,10 @@
  Changes from 1.9.4 to 1.9.2
 ----------------------------
-**
-    * [FELIX-4047] -  Unable to single valued (String) array property
+** Bug
+    * [FELIX-4047] - Unable to single valued (String) array property
+
+** Improvement
+    * [FELIX-4063] - Avoid warnings when using @SlingServlet and @SlingFilter annotations 
 
 
  Changes from 1.9.2 to 1.9.0
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SlingAnnotationProcessor.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SlingAnnotationProcessor.java
index 34f0e38..2bdf448 100644
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SlingAnnotationProcessor.java
+++ b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SlingAnnotationProcessor.java
@@ -83,6 +83,8 @@
     private void processSlingServlet(final ClassAnnotation cad, final ClassDescription classDescription) {
         // generate ComponentDescription if required
         final boolean generateComponent = cad.getBooleanValue("generateComponent", true);
+        final boolean metatype = cad.getBooleanValue("metatype", !generateComponent);
+
         if (generateComponent) {
             final ComponentDescription cd = new ComponentDescription(cad);
             cd.setName(cad.getStringValue("name", classDescription.getDescribedClass().getName()));
@@ -91,7 +93,7 @@
             cd.setLabel(cad.getStringValue("label", null));
             cd.setDescription(cad.getStringValue("description", null));
 
-            cd.setCreateMetatype(cad.getBooleanValue("metatype", false));
+            cd.setCreateMetatype(metatype);
 
             classDescription.add(cd);
         }
@@ -112,7 +114,7 @@
             pd.setName("sling.servlet.paths");
             pd.setMultiValue(paths);
             pd.setType(PropertyType.String);
-            pd.setPrivate(true);
+            pd.setPrivate(metatype);
             classDescription.add(pd);
         }
 
@@ -123,7 +125,7 @@
             pd.setName("sling.servlet.resourceTypes");
             pd.setMultiValue(resourceTypes);
             pd.setType(PropertyType.String);
-            pd.setPrivate(true);
+            pd.setPrivate(metatype);
             classDescription.add(pd);
         }
 
@@ -134,7 +136,7 @@
             pd.setName("sling.servlet.selectors");
             pd.setMultiValue(selectors);
             pd.setType(PropertyType.String);
-            pd.setPrivate(true);
+            pd.setPrivate(metatype);
             classDescription.add(pd);
         }
 
@@ -145,7 +147,7 @@
             pd.setName("sling.servlet.extensions");
             pd.setMultiValue(extensions);
             pd.setType(PropertyType.String);
-            pd.setPrivate(true);
+            pd.setPrivate(metatype);
             classDescription.add(pd);
         }
 
@@ -156,7 +158,7 @@
             pd.setName("sling.servlet.methods");
             pd.setMultiValue(methods);
             pd.setType(PropertyType.String);
-            pd.setPrivate(true);
+            pd.setPrivate(metatype);
             classDescription.add(pd);
         }
     }
@@ -167,6 +169,8 @@
     private void processSlingFilter(final ClassAnnotation cad, final ClassDescription classDescription) {
         // generate ComponentDescription if required
         final boolean generateComponent = cad.getBooleanValue("generateComponent", true);
+        final boolean metatype = cad.getBooleanValue("metatype", !generateComponent);
+
         if (generateComponent) {
             final ComponentDescription cd = new ComponentDescription(cad);
             cd.setName(cad.getStringValue("name", classDescription.getDescribedClass().getName()));
@@ -175,7 +179,7 @@
             cd.setLabel(cad.getStringValue("label", null));
             cd.setDescription(cad.getStringValue("description", null));
 
-            cd.setCreateMetatype(cad.getBooleanValue("metatype", false));
+            cd.setCreateMetatype(metatype);
 
             classDescription.add(cd);
         }
@@ -195,7 +199,7 @@
         pd.setName("service.ranking");
         pd.setValue(String.valueOf(order));
         pd.setType(PropertyType.Integer);
-        pd.setPrivate(true);
+        pd.setPrivate(metatype);
         classDescription.add(pd);
 
         // property scope
@@ -204,7 +208,7 @@
         pd2.setName("sling.filter.scope");
         pd2.setValue(scope);
         pd2.setType(PropertyType.String);
-        pd2.setPrivate(true);
+        pd2.setPrivate(metatype);
         classDescription.add(pd2);
     }
 }