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 2016/11/26 09:27:35 UTC

svn commit: r1771446 - in /sling/trunk/bundles: api/src/main/java/org/apache/sling/api/servlets/ servlets/resolver/ servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/

Author: kwin
Date: Sat Nov 26 09:27:34 2016
New Revision: 1771446

URL: http://svn.apache.org/viewvc?rev=1771446&view=rev
Log:
SLING-6249 move servletresolver constants to API

clarified the javadoc

Added:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/ServletResolverConstants.java   (with props)
Modified:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/package-info.java
    sling/trunk/bundles/servlets/resolver/pom.xml
    sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/ServletResolverConstants.java

Added: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/ServletResolverConstants.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/ServletResolverConstants.java?rev=1771446&view=auto
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/ServletResolverConstants.java (added)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/ServletResolverConstants.java Sat Nov 26 09:27:34 2016
@@ -0,0 +1,162 @@
+/*
+ * 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.api.servlets;
+
+import javax.servlet.ServletConfig;
+
+/**
+ * Service registration properties and common values used for registering a Sling Servlet.
+ * 
+ * @see <a href="http://sling.apache.org/documentation/the-sling-engine/servlets.html">Servlets and Scripts</a>
+ * @since 2.2.0
+ */
+public final class ServletResolverConstants {
+
+    /**
+     * The name of the service registration property of a servlet registered as
+     * a service providing the absolute paths under which the servlet is
+     * accessible as a resource (value is "sling.servlet.paths").
+     * A relative path is made absolute by prefixing it with the value set through the 
+     * {#link SLING_SERVLET_PREFIX} property. 
+     * <p>
+     * The type of this property is a String or String[] (array of strings)
+     * denoting the path(s) under which the servlet is registered in the
+     * resource tree.
+     * <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.
+     * A servlet using this property might be ignored unless its path is included 
+     * in the Execution Paths {@code servletresolver.paths} configuration setting of the {@link org.apache.sling.servlets.resolver.internal.SlingServletResolver} service.
+     */
+    public static final String SLING_SERVLET_PATHS = "sling.servlet.paths";
+
+    /**
+     * The name of the service registration property of a servlet registered as
+     * a service containing 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>
+     * The type of this property is a String or String[] (array of strings)
+     * denoting the resource types.
+     * <p>
+     * Either this property or the {@link #SLING_SERVLET_PATHS} property must be
+     * set, or the servlet is ignored.
+     * If both are set, the servlet is registered using both ways.
+     */
+    public static final String SLING_SERVLET_RESOURCE_TYPES = "sling.servlet.resourceTypes";
+
+    /**
+     * The name of the service registration property of a servlet registered as
+     * a service providing the prefix/index to be used to register this servlet.
+     * It only is applied as prefix to {@link #SLING_SERVLET_PATHS} and 
+     * {@link #SLING_SERVLET_RESOURCE_TYPES} in case they do not start with a "/".
+     * <p>
+     * If the value of this property 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.
+     * If the value of this property is a string starting with "/", this value is applied
+     * as a prefix, regardless of the configured search paths!
+     * If the value is anything else, it is ignored.
+     * If this property is not specified, the configuration of the {@link org.apache.sling.servlets.resolver.internal.SlingServletResolver} service is used.
+     * In case even that one is not set "/" is used as prefix.
+     * <p>
+     * The type of this property is either String or a Number.
+     */
+    public static final String SLING_SERVLET_PREFIX = "sling.servlet.prefix";
+
+    /**
+     * The name of the service registration property of a Servlet registered as
+     * a service containing the request URL selectors supported by the servlet
+     * (value is "sling.servlet.selectors"). The selectors must be configured as
+     * they would be specified in the URL that is as a list of dot-separated
+     * strings such as <em>print.a4</em>.
+     * <p>
+     * The type of this property is a String or String[] (array of strings)
+     * denoting the resource types. This property is ignored if the
+     * {@link #SLING_SERVLET_RESOURCE_TYPES} property is not set. Otherwise this property is
+     * optional and ignored if not set.
+     */
+    public static final String SLING_SERVLET_SELECTORS = "sling.servlet.selectors";
+
+    /**
+     * The name of the service registration property of a servlet registered as
+     * a service containing the request URL extensions supported by the servlet
+     * for GET requests (value is "sling.servlet.extensions").
+     * <p>
+     * The type of this property is a String or String[] (array of strings)
+     * denoting the resource types. This property is ignored if the
+     * {@link #SLING_SERVLET_RESOURCE_TYPES} property is not set. 
+     * Otherwise this property is optional and ignored if not set.
+     */
+    public static final String SLING_SERVLET_EXTENSIONS = "sling.servlet.extensions";
+
+    /**
+     * The name of the service registration property of a servlet registered as
+     * a service containing the request methods supported by the servlet (value
+     * is "sling.servlet.methods"). The value may be one of the HTTP methods or "*" for all methods.
+     * <p>
+     * The type of this property is a String or String[] (array of strings)
+     * denoting the resource types. This property is ignored if the
+     * {@link #SLING_SERVLET_RESOURCE_TYPES} property is not set. 
+     * Otherwise this property is optional and assumed to be {@code GET} and {@code HEAD} if not set.
+     * @see <a href="https://tools.ietf.org/html/rfc7231#section-4.3">HTTP 1.1 Spec Methods</a>
+     */
+    public static final String SLING_SERVLET_METHODS = "sling.servlet.methods";
+
+    /**
+     * The name of the service registration property of a Servlet registered as
+     * a service containing the name of the servlet (value is
+     * "sling.core.servletName"). If this property is missing or 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 {@link ServletConfig#getServletName()}
+     */
+    public static final String SLING_SERVLET_NAME = "sling.core.servletName";
+
+    /**
+     * The resource type of a registered servlet used as the default servlet if
+     * no other (more specific) servlet or script could be selected (value is
+     * "sling/servlet/default"). If no servlet is registered under this name,
+     * the {@link org.apache.sling.servlets.resolver.internal.defaults.DefaultServlet} is
+     * used.
+     * @see <a href="http://sling.apache.org/documentation/the-sling-engine/servlets.html#default-servlets">Default Servlet(s)</a>
+     */
+    public static final String DEFAULT_RESOURCE_TYPE = "sling/servlet/default";
+
+    /**
+     * The resource type used to select error handlers (value is
+     * "sling/servlet/errorhandler").
+     * @see <a href="http://sling.apache.org/documentation/the-sling-engine/errorhandling.html">Errorhandling</a>
+     */
+    public static final String DEFAULT_ERROR_HANDLER_RESOURCE_TYPE = "sling/servlet/errorhandler";
+
+    /**
+     * The HTTP "method" name of an error handler used as the default (value is
+     * "default").
+     * @see <a href="http://sling.apache.org/documentation/the-sling-engine/errorhandling.html#default-handler">Default Error Handle</a>
+     */
+    public static final String DEFAULT_ERROR_HANDLER_METHOD = "default";
+}

Propchange: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/ServletResolverConstants.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/package-info.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/package-info.java?rev=1771446&r1=1771445&r2=1771446&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/package-info.java (original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/package-info.java Sat Nov 26 09:27:34 2016
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-@Version("2.1.3")
+@Version("2.2.0")
 package org.apache.sling.api.servlets;
 
 import org.osgi.annotation.versioning.Version;

Modified: sling/trunk/bundles/servlets/resolver/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/pom.xml?rev=1771446&r1=1771445&r2=1771446&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/resolver/pom.xml (original)
+++ sling/trunk/bundles/servlets/resolver/pom.xml Sat Nov 26 09:27:34 2016
@@ -90,7 +90,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.12.0</version>
+            <version>2.15.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -141,7 +141,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.testing</artifactId>
-            <version>2.0.12</version>
+            <version>2.1.0</version>
             <scope>test</scope>
         </dependency>
         <dependency>

Modified: sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/ServletResolverConstants.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/ServletResolverConstants.java?rev=1771446&r1=1771445&r2=1771446&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/ServletResolverConstants.java (original)
+++ sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/ServletResolverConstants.java Sat Nov 26 09:27:34 2016
@@ -18,6 +18,10 @@
  */
 package org.apache.sling.servlets.resolver.internal;
 
+/**
+ * @deprecated Use the constants from {@link org.apache.sling.api.servlets.ServletResolverConstants}
+ */
+@Deprecated
 public class ServletResolverConstants {
 
     /**
@@ -32,7 +36,9 @@ public class ServletResolverConstants {
      * 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.
+     * @deprecated Use {@link org.apache.sling.api.servlets.ServletResolverConstants#SLING_SERVLET_PATHS}
      */
+    @Deprecated
     public static final String SLING_SERVLET_PATHS = "sling.servlet.paths";
 
     /**
@@ -46,7 +52,9 @@ public class ServletResolverConstants {
      * Either this property or the {@link #SLING_SERVLET_PATHS} property must be
      * set, or the servlet is ignored. If both are set, the servlet is
      * registered using both ways.
+     * @deprecated Use {@link org.apache.sling.api.servlets.ServletResolverConstants#SLING_SERVLET_RESOURCE_TYPES}
      */
+    @Deprecated
     public static final String SLING_SERVLET_RESOURCE_TYPES = "sling.servlet.resourceTypes";
 
     /**
@@ -66,7 +74,9 @@ public class ServletResolverConstants {
      * sling servlet resolver.
      * <p>
      * The type of this property is either String or a Number.
+     * @deprecated Use {@link org.apache.sling.api.servlets.ServletResolverConstants#SLING_SERVLET_PREFIX}
      */
+    @Deprecated
     public static final String SLING_SERVLET_PREFIX = "sling.servlet.prefix";
 
     /**
@@ -80,7 +90,9 @@ public class ServletResolverConstants {
      * denoting the resource types. This property is ignored if the
      * {@link #SLING_SERVLET_RESOURCE_TYPES} property is not set. Otherwise this property is
      * optional and ignored if not set.
+     * @deprecated Use {@link org.apache.sling.api.servlets.ServletResolverConstants#SLING_SERVLET_SELECTORS}
      */
+    @Deprecated
     public static final String SLING_SERVLET_SELECTORS = "sling.servlet.selectors";
 
     /**
@@ -92,7 +104,9 @@ public class ServletResolverConstants {
      * denoting the resource types. This property is ignored if the
      * {@link #SLING_SERVLET_RESOURCE_TYPES} property is not set. Otherwise this property or
      * the {@link #SLING_SERVLET_METHODS} is optional and ignored if not set.
+     * @deprecated Use {@link org.apache.sling.api.servlets.ServletResolverConstants#SLING_SERVLET_EXTENSIONS}
      */
+    @Deprecated
     public static final String SLING_SERVLET_EXTENSIONS = "sling.servlet.extensions";
 
     /**
@@ -104,7 +118,9 @@ public class ServletResolverConstants {
      * denoting the resource types. This property is ignored if the
      * {@link #SLING_SERVLET_RESOURCE_TYPES} property is not set. Otherwise this property or
      * the {@link #SLING_SERVLET_EXTENSIONS} is optional and ignored if not set.
+     * @deprecated Use {@link org.apache.sling.api.servlets.ServletResolverConstants#SLING_SERVLET_METHODS}
      */
+    @Deprecated
     public static final String SLING_SERVLET_METHODS = "sling.servlet.methods";
 
     /**
@@ -113,19 +129,25 @@ public class ServletResolverConstants {
      * "sling/servlet/default"). If no servlet is registered under this name,
      * the {@link org.apache.sling.servlets.resolver.internal.defaults.DefaultServlet} is
      * used.
+     * @deprecated Use {@link org.apache.sling.api.servlets.ServletResolverConstants#DEFAULT_RESOURCE_TYPE}
      */
+    @Deprecated
     public static final String DEFAULT_SERVLET_NAME = "sling/servlet/default";
 
     /**
      * The resource used to select error handlers (value is
      * "sling/servlet/errorhandler").
+     * @deprecated Use {@link org.apache.sling.api.servlets.ServletResolverConstants#DEFAULT_ERROR_HANDLER_RESOURCE_TYPE}
      */
+    @Deprecated
     public static final String ERROR_HANDLER_PATH = "sling/servlet/errorhandler";
 
     /**
      * The "method" name of an error handler used as the default (value is
      * "default").
+     * @deprecated Use {@link org.apache.sling.api.servlets.ServletResolverConstants#DEFAULT_ERROR_HANDLER_METHOD}
      */
+    @Deprecated
     public static final String DEFAULT_ERROR_HANDLER_NAME = "default";
 
     /**
@@ -135,6 +157,8 @@ public class ServletResolverConstants {
      * <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.
+     * @deprecated Use {@link org.apache.sling.api.servlets.ServletResolverConstants#SLING_SERVLET_NAME}
      */
+    @Deprecated
     public static final String SLING_SERLVET_NAME = "sling.core.servletName";
 }