FELIX-4648 : SlingAnnotationProcessor.processSlingFilter cannot deal with multiple scopes
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1626545 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/annotations/changelog.txt b/scrplugin/annotations/changelog.txt
index 529117d..2bd4ca6 100644
--- a/scrplugin/annotations/changelog.txt
+++ b/scrplugin/annotations/changelog.txt
@@ -1,3 +1,9 @@
+Changes from 1.9.10 to 1.9.8
+----------------------------
+** Bug
+ * [FELIX-4648] - SlingAnnotationProcessor.processSlingFilter cannot deal with multiple scopes
+
+
Changes from 1.9.8 to 1.9.6
---------------------------
** Improvement
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 12d43c3..9ae20a3 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
@@ -188,10 +188,41 @@
classDescription.add(pd);
// property scope
- final String scope = cad.getEnumValue("scope", SlingFilterScope.REQUEST.getScope());
+ final String[] scopes;
+ final Object val = cad.getValue("scope");
+ if ( val != null ) {
+ if ( val instanceof String[] ) {
+ final String[] arr = (String[])val;
+ scopes = new String[arr.length / 2];
+ int i = 0;
+ int index = 0;
+ while ( i < arr.length) {
+ scopes[index] = arr[i];
+ i+=2;
+ index++;
+ }
+ } else if ( val instanceof String[][] ) {
+ final String[][] arr = (String[][])val;
+ scopes = new String[arr.length];
+ int index = 0;
+ while ( index < arr.length) {
+ scopes[index] = arr[index][1];
+ index++;
+ }
+ } else {
+ scopes = new String[] { val.toString()};
+ }
+ } else {
+ scopes = new String[] {SlingFilterScope.REQUEST.getScope()};
+ }
+
final PropertyDescription pd2 = new PropertyDescription(cad);
pd2.setName("sling.filter.scope");
- pd2.setValue(scope);
+ if ( scopes.length == 1 ) {
+ pd2.setValue(scopes[0]);
+ } else {
+ pd2.setMultiValue(scopes);
+ }
pd2.setType(PropertyType.String);
if (metatype) {
pd2.setPrivate(true);