You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2018/05/29 08:18:32 UTC

[sling-org-apache-sling-servlets-annotations] branch master created (now 810cffa)

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git.


      at 810cffa  SLING-7624 fix artifact id

This branch includes the following new commits:

     new 8892698  SLING-7624 initial commit
     new a93c95f  SLING-7624 clarify javadoc on selector matching
     new 06828e2  SLING-7624 use PREFIX_ to make annotation methods less verbose
     new de6ddf0  SLING-7624 add annotation for Sling Servlet Filters
     new 9a1a5b4  SLING-7624 simplify servlet annotations
     new 8cc20c3  SLING-7624 fix some more javadoc
     new d2969f1  SLING-7624 use singular for methods accepting arrays
     new 6643d60  Revert "SLING-7624 use singular for methods accepting arrays"
     new 810cffa  SLING-7624 fix artifact id

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
kwin@apache.org.

[sling-org-apache-sling-servlets-annotations] 03/09: SLING-7624 use PREFIX_ to make annotation methods less verbose

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git

commit 06828e2bcf8e6c3f12df1a95e0fa845587a48514
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sun May 13 16:16:36 2018 +0200

    SLING-7624 use PREFIX_ to make annotation methods less verbose
    
    Separate servlet name property into dedicated property
---
 .../servlets/annotations/SlingServletByPath.java   | 18 ++++-----
 .../annotations/SlingServletByResourceType.java    | 24 +++++-------
 .../servlets/annotations/SlingServletName.java     | 45 ++++++++++++++++++++++
 3 files changed, 62 insertions(+), 25 deletions(-)

diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java
index 82c1609..d244457 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java
@@ -33,6 +33,11 @@ import org.osgi.service.component.annotations.ComponentPropertyType;
 public @interface SlingServletByPath {
 
     /**
+     * Prefix for every property being generated from the annotations elements (as defined in OSGi 7 Compendium, 112.8.2.1)
+     */
+    static final String PREFIX_ = "sling.servlet.";
+    
+    /**
      * The absolute paths under which the servlet is accessible as a resource.
      * A relative path is made absolute by prefixing it with the value set through the
      * {@link #sling_servlet_prefix()} element.
@@ -47,7 +52,7 @@ public @interface SlingServletByPath {
      * 
      * @see ServletResolverConstants#SLING_SERVLET_PATHS
      */
-    String[] sling_servlet_paths();
+    String[] paths();
     
     /**
      * The prefix/index to be used to register this servlet.
@@ -71,14 +76,5 @@ public @interface SlingServletByPath {
      * In case even that one is not set "/" is used as prefix.
      * @see ServletResolverConstants#SLING_SERVLET_PREFIX
      */
-    String sling_servlet_prefix() default "";
-    
-    /**
-     * Containing the name of the servlet. If this is empty, the
-     * <code>component.name</code> property or the <code>service.pid</code>
-     * is used. If none of the three properties is defined, the Servlet is
-     * ignored.
-     * @see ServletResolverConstants#SLING_SERVLET_NAME
-     */
-    String sling_core_servletName() default "";
+    String prefix() default "";
 }
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
index 75b001f..c9dc6d6 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
@@ -30,13 +30,18 @@ import org.osgi.service.component.annotations.ComponentPropertyType;
 public @interface SlingServletByResourceType {
 
     /**
+     * Prefix for every property being generated from the annotations elements (as defined in OSGi 7 Compendium, 112.8.2.1)
+     */
+    static final String PREFIX_ = "sling.servlet.";
+
+    /**
      * The resource type(s) supported by the servlet (value
      * is "sling.servlet.resourceTypes").
      * A relative resource type is made absolute by prefixing it with the value set through the
      * {@link #sling_servlet_prefix()} property.
      * <p>
      */
-    String[] sling_servlet_resourceTypes();
+    String[] resourceTypes();
     
     /**
      * One ore more request URL selectors supported by the servlet. The
@@ -46,7 +51,7 @@ public @interface SlingServletByResourceType {
      * otherwise the servlet is not executed. After that may follow arbitrarily many non-registered selectors.
      * @see ServletResolverConstants#SLING_SERVLET_SELECTORS
      */
-    String[] sling_servlet_selectors() default {};
+    String[] selectors() default {};
     
     /**
      * The request URL extensions supported by the servlet
@@ -55,7 +60,7 @@ public @interface SlingServletByResourceType {
      * It this is not set, the servlet is not limited to certain extensions.
      * @see ServletResolverConstants#SLING_SERVLET_EXTENSIONS
      */
-    String[] sling_servlet_extensions() default {};
+    String[] extensions() default {};
     
     /**
      * The request methods supported by the servlet. The value may be one of the HTTP 
@@ -65,7 +70,7 @@ public @interface SlingServletByResourceType {
      * @see ServletResolverConstants#SLING_SERVLET_METHODS
      * @see <a href="https://tools.ietf.org/html/rfc7231#section-4.3">HTTP 1.1 Spec Methods</a>
      */
-    String[] sling_servlet_methods() default {};
+    String[] methods() default {};
     
     /**
      * The prefix/index to be used to register this servlet.
@@ -89,14 +94,5 @@ public @interface SlingServletByResourceType {
      * In case even that one is not set "/" is used as prefix.
      * @see ServletResolverConstants#SLING_SERVLET_PREFIX
      */
-    String sling_servlet_prefix() default "";
-    
-    /**
-     * Containing the name of the servlet. If this is empty, the
-     * <code>component.name</code> property or the <code>service.pid</code>
-     * is used. If none of the three properties is defined, the Servlet is
-     * ignored.
-     * @see ServletResolverConstants#SLING_SERVLET_NAME
-     */
-    String sling_core_servletName() default "";
+    String prefix() default "";
 }
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletName.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletName.java
new file mode 100644
index 0000000..79dd1f9
--- /dev/null
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletName.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.servlets.annotations;
+
+import org.apache.sling.api.servlets.ServletResolverConstants;
+import org.osgi.service.component.annotations.ComponentPropertyType;
+
+/**
+ * Component Property Type (as defined by OSGi DS 1.4) for Sling Servlets.
+ * Takes care of writing the relevant component properties to set a name for a Sling Servlet.
+ * Must be combined with either {@link SlingServletByResourceType} or {@link SlingServletByPath}.
+ *
+ * @see <a href="https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java">Felix SCR annotations</a>
+ * @see ServletResolverConstants
+ */
+@ComponentPropertyType
+public @interface SlingServletName {
+    /**
+     * Prefix for every property being generated from the annotations elements (as defined in OSGi 7 Compendium, 112.8.2.1)
+     */
+    static final String PREFIX_ = "sling.core.";
+
+    /**
+     * Containing the name of the servlet. If this is empty (or not set), the
+     * <code>component.name</code> property or the <code>service.pid</code>
+     * is used. If none of the three properties is defined, the Servlet is
+     * ignored.
+     * @see ServletResolverConstants#SLING_SERVLET_NAME
+     */
+    String servletName();
+}

-- 
To stop receiving notification emails like this one, please contact
kwin@apache.org.

[sling-org-apache-sling-servlets-annotations] 06/09: SLING-7624 fix some more javadoc

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git

commit 8cc20c309d58145c72c90e29948fa2ce1995051f
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Fri May 25 10:38:07 2018 +0200

    SLING-7624 fix some more javadoc
---
 pom.xml                                                   |  6 ------
 .../sling/servlets/annotations/SlingServletPaths.java     |  2 --
 .../sling/servlets/annotations/SlingServletPrefix.java    | 15 ++++-----------
 3 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/pom.xml b/pom.xml
index 58e2e98..156322e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,12 +53,6 @@
             <version>2.16.0</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.api</artifactId>
-            <!-- https://issues.apache.org/jira/browse/SLING-6249, only for link in javadoc -->
-            <version>2.16.0</version>
-        </dependency>
-        <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>javax.servlet-api</artifactId>
         </dependency>
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletPaths.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletPaths.java
index 61fe06d..f402b25 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletPaths.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletPaths.java
@@ -47,6 +47,4 @@ public @interface SlingServletPaths {
      * @see ServletResolverConstants#SLING_SERVLET_PATHS
      */
     String[] value();
-
-    // TODO: does not work due to https://github.com/bndtools/bnd/issues/2445
 }
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletPrefix.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletPrefix.java
index a34bbc5..7f3aab6 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletPrefix.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletPrefix.java
@@ -19,12 +19,10 @@ package org.apache.sling.servlets.annotations;
 import org.apache.sling.api.servlets.ServletResolverConstants;
 import org.osgi.service.component.annotations.ComponentPropertyType;
 /**
- * Component Property Type (as defined by OSGi DS 1.4) for Sling Servlets.
- * Takes care of writing the relevant component properties as being used by the Sling Servlet Resolver ({@link ServletResolverConstants})
- * to register the annotated servlet component as Sling servlet for a specific path.
- * Preferably register Sling servlets by resource type ({@link SlingServletResourceTypes}) though 
- * for reasons outlined at <a href="https://sling.apache.org/documentation/the-sling-engine/servlets.html#caveats-when-binding-servlets-by-path">
- * Caveats when binding servlets by path</a>
+ * The prefix/index to be used to register this servlet.
+ * Must be used in combination with either {@link SlingServletPaths} or {@link SlingServletResourceTypes}.
+ * It only is applied as prefix to {@link SlingServletPaths} or {@link SlingServletResourceTypes#resourceTypes()} 
+ * in case they do not start with a "/".
  *
  * @see <a href="https://sling.apache.org/documentation/the-sling-engine/servlets.html">Sling Servlets</a>
  * @see ServletResolverConstants
@@ -34,10 +32,6 @@ import org.osgi.service.component.annotations.ComponentPropertyType;
 public @interface SlingServletPrefix {
 
     /**
-     * The prefix/index to be used to register this servlet.
-     * It only is applied as prefix to {@link SlingServletPaths} or {@link SlingServletResourceTypes#resourceTypes()} 
-     * in case they do not start with a "/".
-     * </p>
      * <ul>
      * <li>If the value of this element is a number, it defines the index of the search
      * path entries from the resource resolver. The defined search path is used as
@@ -56,5 +50,4 @@ public @interface SlingServletPrefix {
      * @see ServletResolverConstants#SLING_SERVLET_PREFIX
      */
     String value();
-    // TODO: does not work due to https://github.com/bndtools/bnd/issues/2445
 }

-- 
To stop receiving notification emails like this one, please contact
kwin@apache.org.

[sling-org-apache-sling-servlets-annotations] 07/09: SLING-7624 use singular for methods accepting arrays

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git

commit d2969f13aa14089ac7bc0bf72d60bc94a4455983
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Fri May 25 15:05:54 2018 +0200

    SLING-7624 use singular for methods accepting arrays
---
 .../servlets/annotations/SlingServletResourceTypes.java      | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletResourceTypes.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletResourceTypes.java
index 0881303..0da40d0 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletResourceTypes.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletResourceTypes.java
@@ -42,7 +42,7 @@ public @interface SlingServletResourceTypes {
      * {@link SlingServletPrefix} annotation.
      * <p>
      */
-    String[] resourceTypes();
+    String[] resourceType();
     
     /**
      * One ore more request URL selectors supported by the servlet. The
@@ -52,24 +52,24 @@ public @interface SlingServletResourceTypes {
      * otherwise the servlet is not executed. After that may follow arbitrarily many non-registered selectors.
      * @see ServletResolverConstants#SLING_SERVLET_SELECTORS
      */
-    String[] selectors() default {};
+    String[] selector() default {};
     
     /**
-     * The request URL extensions supported by the servlet
+     * The request URL extension(s) supported by the servlet
      * for GET requests.
      * <p>
      * It this is not set, the servlet is not limited to certain extensions.
      * @see ServletResolverConstants#SLING_SERVLET_EXTENSIONS
      */
-    String[] extensions() default {};
+    String[] extension() default {};
     
     /**
-     * The request methods supported by the servlet. The value may be one of the HTTP 
+     * The request method(s) supported by the servlet. The value may be one of the HTTP 
      * methods or "*" for all methods.
      * <p>
      * If this is not set (i.e. empty array) it is assumed to be {@code GET} and {@code HEAD}.
      * @see ServletResolverConstants#SLING_SERVLET_METHODS
      * @see <a href="https://tools.ietf.org/html/rfc7231#section-4.3">HTTP 1.1 Spec Methods</a>
      */
-    String[] methods() default {};
+    String[] method() default {};
 }

-- 
To stop receiving notification emails like this one, please contact
kwin@apache.org.

[sling-org-apache-sling-servlets-annotations] 09/09: SLING-7624 fix artifact id

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git

commit 810cffa99e68102833c798446a85dd025446e156
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue May 29 10:15:59 2018 +0200

    SLING-7624 fix artifact id
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 156322e..2be9ba8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,10 +20,10 @@
         <relativePath/>
     </parent>
 
-    <artifactId>sling-org-apache-sling-servlets-annotations</artifactId>
+    <artifactId>org.apache.sling.servlets.annotations</artifactId>
     <version>1.0.0-SNAPSHOT</version>
 
-    <name>Apache Sling Servlets Annotations</name>
+    <name>Apache Sling Servlet Annotations</name>
     <description>
       OSGi DS 1.4 component property type annotations for Sling servlets and filters
     </description>

-- 
To stop receiving notification emails like this one, please contact
kwin@apache.org.

[sling-org-apache-sling-servlets-annotations] 05/09: SLING-7624 simplify servlet annotations

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git

commit 9a1a5b451bd53217d1c65c279f1ffa38b4746007
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Fri May 25 10:27:50 2018 +0200

    SLING-7624 simplify servlet annotations
---
 .../servlets/annotations/SlingServletName.java     |  2 +-
 ...ngServletByPath.java => SlingServletPaths.java} | 45 ++++------------------
 ...gServletByPath.java => SlingServletPrefix.java} | 31 +++------------
 ...rceType.java => SlingServletResourceTypes.java} | 28 +-------------
 4 files changed, 16 insertions(+), 90 deletions(-)

diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletName.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletName.java
index 79dd1f9..ef68ac8 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletName.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletName.java
@@ -22,7 +22,7 @@ import org.osgi.service.component.annotations.ComponentPropertyType;
 /**
  * Component Property Type (as defined by OSGi DS 1.4) for Sling Servlets.
  * Takes care of writing the relevant component properties to set a name for a Sling Servlet.
- * Must be combined with either {@link SlingServletByResourceType} or {@link SlingServletByPath}.
+ * Must be combined with either {@link SlingServletResourceTypes} or {@link SlingServletPaths}.
  *
  * @see <a href="https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java">Felix SCR annotations</a>
  * @see ServletResolverConstants
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletPaths.java
similarity index 57%
copy from src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java
copy to src/main/java/org/apache/sling/servlets/annotations/SlingServletPaths.java
index 9bbdc5c..61fe06d 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletPaths.java
@@ -22,29 +22,22 @@ import org.osgi.service.component.annotations.ComponentPropertyType;
  * Component Property Type (as defined by OSGi DS 1.4) for Sling Servlets.
  * Takes care of writing the relevant component properties as being used by the Sling Servlet Resolver ({@link ServletResolverConstants})
  * to register the annotated servlet component as Sling servlet for a specific path.
- * Preferably register Sling servlets by resource type ({@link SlingServletByResourceType}) though 
+ * Preferably register Sling servlets by resource type ({@link SlingServletResourceTypes}) though 
  * for reasons outlined at <a href="https://sling.apache.org/documentation/the-sling-engine/servlets.html#caveats-when-binding-servlets-by-path">
- * Caveats when binding servlets by path</a>
+ * Caveats when binding servlets by path</a>.
  *
  * @see <a href="https://sling.apache.org/documentation/the-sling-engine/servlets.html">Sling Servlets</a>
  * @see ServletResolverConstants
  * @see <a href="https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java">Felix SCR annotation</a>
  */
 @ComponentPropertyType
-public @interface SlingServletByPath {
-
-    /**
-     * Prefix for every property being generated from the annotations elements (as defined in OSGi 7 Compendium, 112.8.2.1)
-     */
-    static final String PREFIX_ = "sling.servlet.";
-    
+public @interface SlingServletPaths {
     /**
      * The absolute paths under which the servlet is accessible as a resource.
      * A relative path is made absolute by prefixing it with the value set through the
-     * {@link #sling_servlet_prefix()} element.
+     * {@link SlingServletPrefix} annotation.
      * <p>
-     * Either this property or the {@link #SLING_SERVLET_RESOURCE_TYPES}
-     * property must be set or the servlet is ignored.
+     * This annotation or {@link SlingServletResourceTypes} should be used to properly register the servlet in Sling.
      * If both are set the servlet is registered using both ways.
      * <p>
      * A servlet using this property might be ignored unless its path is included
@@ -53,29 +46,7 @@ public @interface SlingServletByPath {
      * 
      * @see ServletResolverConstants#SLING_SERVLET_PATHS
      */
-    String[] paths();
-    
-    /**
-     * The prefix/index to be used to register this servlet.
-     * It only is applied as prefix to {@link #sling_servlet_paths()} and 
-     * in case they do not start with a "/".
-     * </p>
-     * <ul>
-     * <li>If the value of this element is a number, it defines the index of the search
-     * path entries from the resource resolver. The defined search path is used as
-     * a prefix to mount this servlet. The number can be -1 which always points to the
-     * last search entry. If the specified value is higher than than the highest index
-     * of the search paths, the last entry is used. The index starts with 0.
-     * If the value of this property is a string and parseable as a number, the above
-     * logic is used.</li>
-     * <li>If the value of this element is a string starting with "/", this value is applied
-     * as a prefix, regardless of the configured search paths!</li>
-     * <li>If the value is anything else, it is ignored.</li>
-     * </ul>
-     * If this property is empty, the configuration of the {@code org.apache.sling.servlets.resolver.internal.SlingServletResolver}
-     * service is used.
-     * In case even that one is not set "/" is used as prefix.
-     * @see ServletResolverConstants#SLING_SERVLET_PREFIX
-     */
-    String prefix() default "";
+    String[] value();
+
+    // TODO: does not work due to https://github.com/bndtools/bnd/issues/2445
 }
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletPrefix.java
similarity index 72%
rename from src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java
rename to src/main/java/org/apache/sling/servlets/annotations/SlingServletPrefix.java
index 9bbdc5c..a34bbc5 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletPrefix.java
@@ -22,7 +22,7 @@ import org.osgi.service.component.annotations.ComponentPropertyType;
  * Component Property Type (as defined by OSGi DS 1.4) for Sling Servlets.
  * Takes care of writing the relevant component properties as being used by the Sling Servlet Resolver ({@link ServletResolverConstants})
  * to register the annotated servlet component as Sling servlet for a specific path.
- * Preferably register Sling servlets by resource type ({@link SlingServletByResourceType}) though 
+ * Preferably register Sling servlets by resource type ({@link SlingServletResourceTypes}) though 
  * for reasons outlined at <a href="https://sling.apache.org/documentation/the-sling-engine/servlets.html#caveats-when-binding-servlets-by-path">
  * Caveats when binding servlets by path</a>
  *
@@ -31,33 +31,11 @@ import org.osgi.service.component.annotations.ComponentPropertyType;
  * @see <a href="https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java">Felix SCR annotation</a>
  */
 @ComponentPropertyType
-public @interface SlingServletByPath {
+public @interface SlingServletPrefix {
 
     /**
-     * Prefix for every property being generated from the annotations elements (as defined in OSGi 7 Compendium, 112.8.2.1)
-     */
-    static final String PREFIX_ = "sling.servlet.";
-    
-    /**
-     * The absolute paths under which the servlet is accessible as a resource.
-     * A relative path is made absolute by prefixing it with the value set through the
-     * {@link #sling_servlet_prefix()} element.
-     * <p>
-     * Either this property or the {@link #SLING_SERVLET_RESOURCE_TYPES}
-     * property must be set or the servlet is ignored.
-     * If both are set the servlet is registered using both ways.
-     * <p>
-     * A servlet using this property might be ignored unless its path is included
-     * in the Execution Paths {@code servletresolver.paths} configuration setting of the
-     * {@code org.apache.sling.servlets.resolver.internal.SlingServletResolver} service.
-     * 
-     * @see ServletResolverConstants#SLING_SERVLET_PATHS
-     */
-    String[] paths();
-    
-    /**
      * The prefix/index to be used to register this servlet.
-     * It only is applied as prefix to {@link #sling_servlet_paths()} and 
+     * It only is applied as prefix to {@link SlingServletPaths} or {@link SlingServletResourceTypes#resourceTypes()} 
      * in case they do not start with a "/".
      * </p>
      * <ul>
@@ -77,5 +55,6 @@ public @interface SlingServletByPath {
      * In case even that one is not set "/" is used as prefix.
      * @see ServletResolverConstants#SLING_SERVLET_PREFIX
      */
-    String prefix() default "";
+    String value();
+    // TODO: does not work due to https://github.com/bndtools/bnd/issues/2445
 }
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletResourceTypes.java
similarity index 70%
rename from src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
rename to src/main/java/org/apache/sling/servlets/annotations/SlingServletResourceTypes.java
index 096df75..0881303 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletResourceTypes.java
@@ -28,7 +28,7 @@ import org.osgi.service.component.annotations.ComponentPropertyType;
  * @see <a href="https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java">Felix SCR annotation</a>
  */
 @ComponentPropertyType
-public @interface SlingServletByResourceType {
+public @interface SlingServletResourceTypes {
 
     /**
      * Prefix for every property being generated from the annotations elements (as defined in OSGi 7 Compendium, 112.8.2.1)
@@ -39,7 +39,7 @@ public @interface SlingServletByResourceType {
      * The resource type(s) supported by the servlet (value
      * is "sling.servlet.resourceTypes").
      * A relative resource type is made absolute by prefixing it with the value set through the
-     * {@link #sling_servlet_prefix()} property.
+     * {@link SlingServletPrefix} annotation.
      * <p>
      */
     String[] resourceTypes();
@@ -72,28 +72,4 @@ public @interface SlingServletByResourceType {
      * @see <a href="https://tools.ietf.org/html/rfc7231#section-4.3">HTTP 1.1 Spec Methods</a>
      */
     String[] methods() default {};
-    
-    /**
-     * The prefix/index to be used to register this servlet.
-     * It only is applied as prefix to {@link #sling_servlet_paths()} and 
-     * in case they do not start with a "/".
-     * </p>
-     * <ul>
-     * <li>If the value of this element is a number, it defines the index of the search
-     * path entries from the resource resolver. The defined search path is used as
-     * a prefix to mount this servlet. The number can be -1 which always points to the
-     * last search entry. If the specified value is higher than than the highest index
-     * of the search paths, the last entry is used. The index starts with 0.
-     * If the value of this property is a string and parseable as a number, the above
-     * logic is used.</li>
-     * <li>If the value of this element is a string starting with "/", this value is applied
-     * as a prefix, regardless of the configured search paths!</li>
-     * <li>If the value is anything else, it is ignored.</li>
-     * </ul>
-     * If this property is empty, the configuration of the {@code org.apache.sling.servlets.resolver.internal.SlingServletResolver}
-     * service is used.
-     * In case even that one is not set "/" is used as prefix.
-     * @see ServletResolverConstants#SLING_SERVLET_PREFIX
-     */
-    String prefix() default "";
 }

-- 
To stop receiving notification emails like this one, please contact
kwin@apache.org.

[sling-org-apache-sling-servlets-annotations] 08/09: Revert "SLING-7624 use singular for methods accepting arrays"

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git

commit 6643d60d184d1beb5389966e63fb01e4037f3246
Author: Konrad Windszus <ko...@netcentric.biz>
AuthorDate: Fri May 25 16:25:42 2018 +0200

    Revert "SLING-7624 use singular for methods accepting arrays"
    
    This reverts commit d2969f13aa14089ac7bc0bf72d60bc94a4455983.
---
 .../servlets/annotations/SlingServletResourceTypes.java      | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletResourceTypes.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletResourceTypes.java
index 0da40d0..0881303 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletResourceTypes.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletResourceTypes.java
@@ -42,7 +42,7 @@ public @interface SlingServletResourceTypes {
      * {@link SlingServletPrefix} annotation.
      * <p>
      */
-    String[] resourceType();
+    String[] resourceTypes();
     
     /**
      * One ore more request URL selectors supported by the servlet. The
@@ -52,24 +52,24 @@ public @interface SlingServletResourceTypes {
      * otherwise the servlet is not executed. After that may follow arbitrarily many non-registered selectors.
      * @see ServletResolverConstants#SLING_SERVLET_SELECTORS
      */
-    String[] selector() default {};
+    String[] selectors() default {};
     
     /**
-     * The request URL extension(s) supported by the servlet
+     * The request URL extensions supported by the servlet
      * for GET requests.
      * <p>
      * It this is not set, the servlet is not limited to certain extensions.
      * @see ServletResolverConstants#SLING_SERVLET_EXTENSIONS
      */
-    String[] extension() default {};
+    String[] extensions() default {};
     
     /**
-     * The request method(s) supported by the servlet. The value may be one of the HTTP 
+     * The request methods supported by the servlet. The value may be one of the HTTP 
      * methods or "*" for all methods.
      * <p>
      * If this is not set (i.e. empty array) it is assumed to be {@code GET} and {@code HEAD}.
      * @see ServletResolverConstants#SLING_SERVLET_METHODS
      * @see <a href="https://tools.ietf.org/html/rfc7231#section-4.3">HTTP 1.1 Spec Methods</a>
      */
-    String[] method() default {};
+    String[] methods() default {};
 }

-- 
To stop receiving notification emails like this one, please contact
kwin@apache.org.

[sling-org-apache-sling-servlets-annotations] 01/09: SLING-7624 initial commit

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git

commit 8892698aeae1439653e9c43493f56589a545d41f
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sun May 13 11:16:30 2018 +0200

    SLING-7624 initial commit
---
 .gitignore                                         |   4 +
 LICENSE                                            | 202 +++++++++++++++++++++
 README.md                                          |   3 +
 pom.xml                                            |  57 ++++++
 .../servlets/annotations/SlingServletByPath.java   |  84 +++++++++
 .../annotations/SlingServletByResourceType.java    | 101 +++++++++++
 6 files changed, 451 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4c06d21
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+/target/
+/.project
+/.settings/
+/.classpath
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5fcce6b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+# Apache Sling Servlet Annotations
+
+This module is part of the [Apache Sling](https://sling.apache.org) project.
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..8903fa0
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+    license agreements. See the NOTICE file distributed with this work for additional
+    information regarding copyright ownership. The ASF licenses this file to
+    you under the Apache License, Version 2.0 (the "License"); you may not use
+    this file except in compliance with the License. You may obtain a copy of
+    the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+    by applicable law or agreed to in writing, software distributed under the
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+    OF ANY KIND, either express or implied. See the License for the specific
+    language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>33</version>
+        <relativePath/>
+    </parent>
+
+    <artifactId>sling-org-apache-sling-servlets-annotations</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+
+    <name>Apache Sling Servlets Annotations</name>
+    <description>
+      OSGi DS 1.4 component property type annotations for Sling servlets and filters
+    </description>
+
+    <scm>
+        <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git</connection>
+        <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git</developerConnection>
+        <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-servlets-annotations.git</url>
+        <tag>HEAD</tag>
+    </scm>
+
+    <!-- compile with java 7 -->
+    <properties>
+        <sling.java.version>7</sling.java.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.service.component.annotations</artifactId>
+            <version>1.4.0</version><!-- for annotation @ComponentPropertyType -->
+        </dependency>
+         <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <!-- https://issues.apache.org/jira/browse/SLING-6249, only for link in javadoc -->
+            <version>2.16.0</version>
+        </dependency>
+    </dependencies>
+
+</project>
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java
new file mode 100644
index 0000000..82c1609
--- /dev/null
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.servlets.annotations;
+
+import org.apache.sling.api.servlets.ServletResolverConstants;
+import org.osgi.service.component.annotations.ComponentPropertyType;
+/**
+ * Component Property Type (as defined by OSGi DS 1.4) for Sling Servlets.
+ * Takes care of writing the relevant component properties as being used by the Sling Servlet Resolver ({@link ServletResolverConstants})
+ * to register the annotated servlet component as Sling servlet for a specific path.
+ * Preferably register Sling servlets by resource type ({@link SlingServletByResourceType}) though 
+ * for reasons outlined at <a href="https://sling.apache.org/documentation/the-sling-engine/servlets.html#caveats-when-binding-servlets-by-path">
+ * Caveats when binding servlets by path</a>
+ *
+ * @see <a href="https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java">Felix SCR annotations</a>
+ * @see ServletResolverConstants
+ */
+@ComponentPropertyType
+public @interface SlingServletByPath {
+
+    /**
+     * The absolute paths under which the servlet is accessible as a resource.
+     * A relative path is made absolute by prefixing it with the value set through the
+     * {@link #sling_servlet_prefix()} element.
+     * <p>
+     * Either this property or the {@link #SLING_SERVLET_RESOURCE_TYPES}
+     * property must be set or the servlet is ignored.
+     * If both are set the servlet is registered using both ways.
+     * <p>
+     * A servlet using this property might be ignored unless its path is included
+     * in the Execution Paths {@code servletresolver.paths} configuration setting of the
+     * {@code org.apache.sling.servlets.resolver.internal.SlingServletResolver} service.
+     * 
+     * @see ServletResolverConstants#SLING_SERVLET_PATHS
+     */
+    String[] sling_servlet_paths();
+    
+    /**
+     * The prefix/index to be used to register this servlet.
+     * It only is applied as prefix to {@link #sling_servlet_paths()} and 
+     * in case they do not start with a "/".
+     * </p>
+     * <ul>
+     * <li>If the value of this element is a number, it defines the index of the search
+     * path entries from the resource resolver. The defined search path is used as
+     * a prefix to mount this servlet. The number can be -1 which always points to the
+     * last search entry. If the specified value is higher than than the highest index
+     * of the search paths, the last entry is used. The index starts with 0.
+     * If the value of this property is a string and parseable as a number, the above
+     * logic is used.</li>
+     * <li>If the value of this element is a string starting with "/", this value is applied
+     * as a prefix, regardless of the configured search paths!</li>
+     * <li>If the value is anything else, it is ignored.</li>
+     * </ul>
+     * If this property is empty, the configuration of the {@code org.apache.sling.servlets.resolver.internal.SlingServletResolver}
+     * service is used.
+     * In case even that one is not set "/" is used as prefix.
+     * @see ServletResolverConstants#SLING_SERVLET_PREFIX
+     */
+    String sling_servlet_prefix() default "";
+    
+    /**
+     * Containing the name of the servlet. If this is empty, the
+     * <code>component.name</code> property or the <code>service.pid</code>
+     * is used. If none of the three properties is defined, the Servlet is
+     * ignored.
+     * @see ServletResolverConstants#SLING_SERVLET_NAME
+     */
+    String sling_core_servletName() default "";
+}
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
new file mode 100644
index 0000000..f7e62b5
--- /dev/null
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.servlets.annotations;
+
+import org.apache.sling.api.servlets.ServletResolverConstants;
+import org.osgi.service.component.annotations.ComponentPropertyType;
+/**
+ * Component Property Type (as defined by OSGi DS 1.4) for Sling Servlets.
+ * Takes care of writing the relevant component properties as being used by the Sling Servlet Resolver ({@link ServletResolverConstants})
+ * to register the annotated servlet component as Sling servlet for a specific resource type.
+ * 
+ * @see <a href="https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java">Felix SCR annotations</a>
+ * @see ServletResolverConstants
+ */
+@ComponentPropertyType
+public @interface SlingServletByResourceType {
+
+    /**
+     * The resource type(s) supported by the servlet (value
+     * is "sling.servlet.resourceTypes").
+     * A relative resource type is made absolute by prefixing it with the value set through the
+     * {@link #sling_servlet_prefix()} property.
+     * <p>
+     */
+    String[] sling_servlet_resourceTypes();
+    
+    /**
+     * One ore more request URL selectors supported by the servlet. The
+     * selectors must be configured in the order as they would be specified in the URL that
+     * is as a list of dot-separated strings such as <em>print.a4</em>.
+     * In case this is not empty all selectors must match, otherwise the servlet is not executed.
+     * @see ServletResolverConstants#SLING_SERVLET_SELECTORS
+     */
+    String[] sling_servlet_selectors() default {};
+    
+    /**
+     * The request URL extensions supported by the servlet
+     * for GET requests.
+     * <p>
+     * It this is not set, the servlet is not limited to certain extensions.
+     * @see ServletResolverConstants#SLING_SERVLET_EXTENSIONS
+     */
+    String[] sling_servlet_extensions() default {};
+    
+    /**
+     * The request methods supported by the servlet. The value may be one of the HTTP 
+     * methods or "*" for all methods.
+     * <p>
+     * If this is not set (i.e. empty array) it is assumed to be {@code GET} and {@code HEAD}.
+     * @see ServletResolverConstants#SLING_SERVLET_METHODS
+     * @see <a href="https://tools.ietf.org/html/rfc7231#section-4.3">HTTP 1.1 Spec Methods</a>
+     */
+    String[] sling_servlet_methods() default {};
+    
+    /**
+     * The prefix/index to be used to register this servlet.
+     * It only is applied as prefix to {@link #sling_servlet_paths()} and 
+     * in case they do not start with a "/".
+     * </p>
+     * <ul>
+     * <li>If the value of this element is a number, it defines the index of the search
+     * path entries from the resource resolver. The defined search path is used as
+     * a prefix to mount this servlet. The number can be -1 which always points to the
+     * last search entry. If the specified value is higher than than the highest index
+     * of the search paths, the last entry is used. The index starts with 0.
+     * If the value of this property is a string and parseable as a number, the above
+     * logic is used.</li>
+     * <li>If the value of this element is a string starting with "/", this value is applied
+     * as a prefix, regardless of the configured search paths!</li>
+     * <li>If the value is anything else, it is ignored.</li>
+     * </ul>
+     * If this property is empty, the configuration of the {@code org.apache.sling.servlets.resolver.internal.SlingServletResolver}
+     * service is used.
+     * In case even that one is not set "/" is used as prefix.
+     * @see ServletResolverConstants#SLING_SERVLET_PREFIX
+     */
+    String sling_servlet_prefix() default "";
+    
+    /**
+     * Containing the name of the servlet. If this is empty, the
+     * <code>component.name</code> property or the <code>service.pid</code>
+     * is used. If none of the three properties is defined, the Servlet is
+     * ignored.
+     * @see ServletResolverConstants#SLING_SERVLET_NAME
+     */
+    String sling_core_servletName() default "";
+}

-- 
To stop receiving notification emails like this one, please contact
kwin@apache.org.

[sling-org-apache-sling-servlets-annotations] 04/09: SLING-7624 add annotation for Sling Servlet Filters

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git

commit de6ddf01a0d9d6dd4735a74b65dfddde87e31f5e
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sun May 13 18:57:06 2018 +0200

    SLING-7624 add annotation for Sling Servlet Filters
---
 pom.xml                                            | 13 +++-
 .../servlets/annotations/SlingServletByPath.java   |  3 +-
 .../annotations/SlingServletByResourceType.java    |  3 +-
 .../servlets/annotations/SlingServletFilter.java   | 60 ++++++++++++++++
 .../annotations/SlingServletFilterScope.java       | 82 ++++++++++++++++++++++
 5 files changed, 158 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 8903fa0..58e2e98 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,12 +46,23 @@
             <artifactId>org.osgi.service.component.annotations</artifactId>
             <version>1.4.0</version><!-- for annotation @ComponentPropertyType -->
         </dependency>
-         <dependency>
+        <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
             <!-- https://issues.apache.org/jira/browse/SLING-6249, only for link in javadoc -->
             <version>2.16.0</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <!-- https://issues.apache.org/jira/browse/SLING-6249, only for link in javadoc -->
+            <version>2.16.0</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        
     </dependencies>
 
 </project>
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java
index d244457..9bbdc5c 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByPath.java
@@ -26,8 +26,9 @@ import org.osgi.service.component.annotations.ComponentPropertyType;
  * for reasons outlined at <a href="https://sling.apache.org/documentation/the-sling-engine/servlets.html#caveats-when-binding-servlets-by-path">
  * Caveats when binding servlets by path</a>
  *
- * @see <a href="https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java">Felix SCR annotations</a>
+ * @see <a href="https://sling.apache.org/documentation/the-sling-engine/servlets.html">Sling Servlets</a>
  * @see ServletResolverConstants
+ * @see <a href="https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java">Felix SCR annotation</a>
  */
 @ComponentPropertyType
 public @interface SlingServletByPath {
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
index c9dc6d6..096df75 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
@@ -23,8 +23,9 @@ import org.osgi.service.component.annotations.ComponentPropertyType;
  * Takes care of writing the relevant component properties as being used by the Sling Servlet Resolver ({@link ServletResolverConstants})
  * to register the annotated servlet component as Sling servlet for a specific resource type.
  * 
- * @see <a href="https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java">Felix SCR annotations</a>
+ * @see <a href="https://sling.apache.org/documentation/the-sling-engine/servlets.html">Sling Servlets</a>
  * @see ServletResolverConstants
+ * @see <a href="https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java">Felix SCR annotation</a>
  */
 @ComponentPropertyType
 public @interface SlingServletByResourceType {
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletFilter.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletFilter.java
new file mode 100644
index 0000000..de6fbb6
--- /dev/null
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletFilter.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.servlets.annotations;
+
+import org.apache.sling.api.servlets.ServletResolverConstants;
+import org.osgi.service.component.annotations.ComponentPropertyType;
+
+/** 
+ * Component Property Type (as defined by OSGi DS 1.4) for Sling Servlet Filters. 
+ * Takes care of writing the relevant component properties as being used by the Sling Servlet Resolver 
+ * ({@link ServletResolverConstants}) to register the annotated servlet filter component as
+ * Sling servlet filter. 
+ * <br><br>
+ * The order of the filter is determined by the property {@code service.ranking}. Its value is used to sort the filters. 
+ * Filters with a higher order are executed before a filter with a lower order. If two filters have the same order, 
+ * the one with the lower service id is executed first.
+ * <br>
+ * <br>
+ * Please note that the ordering is actually depending on the used Apache Sling Engine bundle version. Version older than 2.3.4 of that
+ * bundle are sorting the filters in the wrong reverse order. Make sure to run a newer version of the Sling engine to get the correct
+ * ordering (see also <a href="https://issues.apache.org/jira/browse/SLING-2920">SLING-2920</a>).
+ *
+ * @see <a href=
+ *      "https://github.com/apache/felix/blob/trunk/tools/org.apache.felix.scr.annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilter.java">Felix
+ *      SCR annotation</a>
+ * @see <a href="https://sling.apache.org/documentation/the-sling-engine/filters.html">Sling Servlet Filter</a> 
+ */
+@ComponentPropertyType
+public @interface SlingServletFilter {
+
+    /** 
+     * Prefix for every property being generated from the annotations elements (as defined in OSGi 7 Compendium, 112.8.2.1) 
+     */
+    static final String PREFIX_ = "sling.filter.";
+
+    /** 
+     * Restrict the filter to paths that match the supplied regular expression. Requires Sling Engine 2.4.0.
+     */
+    String pattern() default "";
+
+    /** 
+     * The scopes of a filter. If the filter has request scope, it is run once for a request. If the filter has component scope, it is run
+     * once for every included component (rendering). 
+     */
+    SlingServletFilterScope[] scope() default SlingServletFilterScope.REQUEST;
+}
diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletFilterScope.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletFilterScope.java
new file mode 100644
index 0000000..ac92f02
--- /dev/null
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletFilterScope.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.servlets.annotations;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.http.HttpServletResponse;
+/**
+ * The possible scopes for the {@link SlingServletFilter#scope()} annotation.
+ */
+public enum SlingServletFilterScope {
+
+    /**
+     * Filters are called once per request hitting Sling from the outside. 
+     * These filters are called after the resource addressed by the request URL and the Servlet or script to process the request has been resolved 
+     * before the COMPONENT filters (if any) and the Servlet or script are called.
+     * <p>Servlet API Correspondence: {@code REQUEST}</p>
+     */
+    REQUEST("REQUEST"),
+
+    /**
+     * Filters are called upon calling the {@link RequestDispatcher#include(javax.servlet.ServletRequest, javax.servlet.ServletResponse)} 
+     * method after the included resource and the Servlet or script to process the include have been resolved before the Servlet or script is called.
+     * <p>Servlet API Correspondence: {@code REQUEST},{@code INCLUDE},{@code FORWARD}</p>
+     */
+    COMPONENT("COMPONENT"),
+
+    /**
+     * Filters are called upon {@link HttpServletResponse#sendError(int)} or {@link HttpServletResponse#sendError(int, String)}
+     * or any uncaught Throwable before resolving the error handler Servlet or script.
+     * <p>Servlet API Correspondence: {@code ERROR}</
+     */
+    ERROR("ERROR"),
+
+    /**
+     * Filters are called upon calling the RequestDispatcher.include method after the included resource and the Servlet 
+     * or script to process the include have been resolved before the Servlet or script is called.
+     * <p>Servlet API Correspondence: {@code INCLUDE}</p>
+     */
+    INCLUDE("INCLUDE"),
+
+    /**
+     * Filters are called upon calling the RequestDispatcher.forward method after the included resource and the Servlet
+     * or script to process the include have been resolved before the Servlet or script is called.
+     * <p>Servlet API Correspondence: {@code FORWARD}</p>
+     */
+    FORWARD("FORWARD");
+
+    private final String scope;
+
+    private SlingServletFilterScope(final String scope) {
+        this.scope = scope;
+    }
+
+    /**
+     * @return String representation of the scope
+     */
+    public String getScope() {
+        return this.scope;
+    }
+
+    @Override
+    public String toString() {
+        return this.getScope();
+    }
+
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
kwin@apache.org.

[sling-org-apache-sling-servlets-annotations] 02/09: SLING-7624 clarify javadoc on selector matching

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git

commit a93c95fc26519df14949e7c8ded21de8439f2bb4
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sun May 13 12:12:30 2018 +0200

    SLING-7624 clarify javadoc on selector matching
---
 .../apache/sling/servlets/annotations/SlingServletByResourceType.java  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
index f7e62b5..75b001f 100644
--- a/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletByResourceType.java
@@ -42,7 +42,8 @@ public @interface SlingServletByResourceType {
      * One ore more request URL selectors supported by the servlet. The
      * selectors must be configured in the order as they would be specified in the URL that
      * is as a list of dot-separated strings such as <em>print.a4</em>.
-     * In case this is not empty all selectors must match, otherwise the servlet is not executed.
+     * In case this is not empty the first selector(s) (i.e. the most right-hand ones in the URL) must match, 
+     * otherwise the servlet is not executed. After that may follow arbitrarily many non-registered selectors.
      * @see ServletResolverConstants#SLING_SERVLET_SELECTORS
      */
     String[] sling_servlet_selectors() default {};

-- 
To stop receiving notification emails like this one, please contact
kwin@apache.org.