SLING-7624 simplify servlet annotations
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 @@
/**
* 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/SlingServletPaths.java b/src/main/java/org/apache/sling/servlets/annotations/SlingServletPaths.java
new file mode 100644
index 0000000..61fe06d
--- /dev/null
+++ b/src/main/java/org/apache/sling/servlets/annotations/SlingServletPaths.java
@@ -0,0 +1,52 @@
+/*
+ * 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 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>.
+ *
+ * @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 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 SlingServletPrefix} annotation.
+ * <p>
+ * 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
+ * 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[] 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 @@
* 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 @@
* @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 @@
* 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 @@
* @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 @@
* 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 @@
* @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 "";
}