incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r929975 - in /sling/trunk/bundles: engine/src/main/java/org/apache/sling/engine/ servlets/resolver/ servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/ servlets/resolver/src/main/java/org/apache/sling/servlets/resol...
Date Thu, 01 Apr 2010 13:57:39 GMT
Author: cziegeler
Date: Thu Apr  1 13:57:39 2010
New Revision: 929975

URL: http://svn.apache.org/viewvc?rev=929975&view=rev
Log:
SLING-1466 : Deprecate AbstractServiceReferenceConfig

Modified:
    sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/EngineConstants.java
    sling/trunk/bundles/servlets/resolver/pom.xml
    sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/ServletResolverConstants.java
    sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java
    sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/WorkspaceResourceResolver.java
    sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/defaults/DefaultErrorHandlerServlet.java
    sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/helper/SlingServletConfig.java
    sling/trunk/bundles/servlets/resolver/src/test/java/org/apache/sling/servlets/resolver/internal/SlingServletResolverTest.java

Modified: sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/EngineConstants.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/EngineConstants.java?rev=929975&r1=929974&r2=929975&view=diff
==============================================================================
--- sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/EngineConstants.java
(original)
+++ sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/EngineConstants.java
Thu Apr  1 13:57:39 2010
@@ -23,7 +23,10 @@ package org.apache.sling.engine;
  * for well known constant strings in Sling. Even though these constants will
  * never change, it is recommended that applications refer to the symbolic
  * constants instead of code the strings themselves.
+ *
+ * @deprecated All constants have alternatives to use
  */
+@Deprecated
 public class EngineConstants {
 
     /**
@@ -76,7 +79,9 @@ public class EngineConstants {
      * <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
      */
+    @Deprecated
     public static final String SLING_SERLVET_NAME = "sling.core.servletName";
 
     /**

Modified: sling/trunk/bundles/servlets/resolver/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/pom.xml?rev=929975&r1=929974&r2=929975&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/resolver/pom.xml (original)
+++ sling/trunk/bundles/servlets/resolver/pom.xml Thu Apr  1 13:57:39 2010
@@ -68,24 +68,32 @@
             <artifactId>servlet-api</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.api</artifactId>
-            <version>2.0.8</version>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.engine</artifactId>
-            <version>2.0.6</version>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.0.9-SNAPSHOT</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.adapter</artifactId>
             <version>2.0.4</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.engine</artifactId>
+            <version>2.0.6</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.osgi</artifactId>
             <version>2.0.2-incubator</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
@@ -113,7 +121,6 @@
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-simple</artifactId>
-            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.jmock</groupId>

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=929975&r1=929974&r2=929975&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
Thu Apr  1 13:57:39 2010
@@ -120,4 +120,14 @@ public class ServletResolverConstants {
      * "default").
      */
     public static final String DEFAULT_ERROR_HANDLER_NAME = "default";
+
+    /**
+     * 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.
+     */
+    public static final String SLING_SERLVET_NAME = "sling.core.servletName";
 }

Modified: sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java?rev=929975&r1=929974&r2=929975&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java
(original)
+++ sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java
Thu Apr  1 13:57:39 2010
@@ -21,7 +21,11 @@ package org.apache.sling.servlets.resolv
 import static org.apache.sling.api.SlingConstants.ERROR_MESSAGE;
 import static org.apache.sling.api.SlingConstants.ERROR_SERVLET_NAME;
 import static org.apache.sling.api.SlingConstants.ERROR_STATUS;
-import static org.apache.sling.engine.EngineConstants.SLING_CURRENT_SERVLET_NAME;
+import static org.apache.sling.api.SlingConstants.SLING_CURRENT_SERVLET_NAME;
+import static org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERLVET_NAME;
+import static org.osgi.framework.Constants.SERVICE_ID;
+import static org.osgi.framework.Constants.SERVICE_PID;
+import static org.osgi.service.component.ComponentConstants.COMPONENT_NAME;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -49,6 +53,7 @@ import org.apache.sling.api.SlingExcepti
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.request.RequestProgressTracker;
+import org.apache.sling.api.request.RequestUtil;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.api.resource.ResourceResolver;
@@ -58,8 +63,6 @@ import org.apache.sling.api.scripting.Sl
 import org.apache.sling.api.servlets.OptingServlet;
 import org.apache.sling.api.servlets.ServletResolver;
 import org.apache.sling.commons.osgi.OsgiUtil;
-import org.apache.sling.engine.RequestUtil;
-import org.apache.sling.engine.servlets.AbstractServiceReferenceConfig;
 import org.apache.sling.engine.servlets.ErrorHandler;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.jcr.resource.JcrResourceResolverFactory;
@@ -825,7 +828,7 @@ public class SlingServletResolver implem
     private boolean createServlet(ServletContext servletContext, ServiceReference reference)
{
 
         // check for a name, this is required
-        String name = AbstractServiceReferenceConfig.getName(reference);
+        final String name = getName(reference);
         if (name == null) {
             log.error("bindServlet: Cannot register servlet {} without a servlet name", reference);
             return false;
@@ -943,4 +946,25 @@ public class SlingServletResolver implem
             }
         }
     }
+
+    /** The list of property names checked by {@link #getName(ServiceReference)} */
+    private static final String[] NAME_PROPERTIES = { SLING_SERLVET_NAME,
+        COMPONENT_NAME, SERVICE_PID, SERVICE_ID };
+
+    /**
+     * Looks for a name value in the service reference properties. See the
+     * class comment at the top for the list of properties checked by this
+     * method.
+     */
+    private static String getName(ServiceReference reference) {
+        String servletName = null;
+        for (int i = 0; i < NAME_PROPERTIES.length
+            && (servletName == null || servletName.length() == 0); i++) {
+            Object prop = reference.getProperty(NAME_PROPERTIES[i]);
+            if (prop != null) {
+                servletName = String.valueOf(prop);
+            }
+        }
+        return servletName;
+    }
 }

Modified: sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/WorkspaceResourceResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/WorkspaceResourceResolver.java?rev=929975&r1=929974&r2=929975&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/WorkspaceResourceResolver.java
(original)
+++ sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/WorkspaceResourceResolver.java
Thu Apr  1 13:57:39 2010
@@ -104,4 +104,7 @@ public class WorkspaceResourceResolver i
         return workspaceName;
     }
 
+    public void close() {
+        delegate.close();
+    }
 }

Modified: sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/defaults/DefaultErrorHandlerServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/defaults/DefaultErrorHandlerServlet.java?rev=929975&r1=929974&r2=929975&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/defaults/DefaultErrorHandlerServlet.java
(original)
+++ sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/defaults/DefaultErrorHandlerServlet.java
Thu Apr  1 13:57:39 2010
@@ -30,7 +30,7 @@ import javax.servlet.http.HttpServletRes
 import org.apache.sling.api.SlingConstants;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.request.RequestProgressTracker;
-import org.apache.sling.engine.ResponseUtil;
+import org.apache.sling.api.request.ResponseUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/helper/SlingServletConfig.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/helper/SlingServletConfig.java?rev=929975&r1=929974&r2=929975&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/helper/SlingServletConfig.java
(original)
+++ sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/helper/SlingServletConfig.java
Thu Apr  1 13:57:39 2010
@@ -18,20 +18,70 @@
  */
 package org.apache.sling.servlets.resolver.internal.helper;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 
-import org.apache.sling.engine.servlets.AbstractServiceReferenceConfig;
 import org.osgi.framework.ServiceReference;
 
-public class SlingServletConfig extends AbstractServiceReferenceConfig implements ServletConfig
{
+public class SlingServletConfig implements ServletConfig {
+
+    /** The <code>ServletContext</code> of this configuration object */
+    private final ServletContext servletContext;
+
+    /** The <code>ServiceReference</code> providing the properties */
+    private final ServiceReference reference;
+
+    /** The name of this configuration object */
+    private final String name;
+
+    /**
+     * Sets up this base configuration object.
+     *
+     * @param servletContext The <code>ServletContext</code> attached to this
+     *            configuration.
+     * @param reference The service reference providing the initialization
+     *            parameter values.
+     * @param name The name of this configuration.
+     */
+    public SlingServletConfig(final ServletContext servletContext,
+            final ServiceReference reference, final String name) {
+        this.servletContext = servletContext;
+        this.reference = reference;
+        this.name = name;
+    }
+
+    /**
+     * @see javax.servlet.ServletConfig#getInitParameter(java.lang.String)
+     */
+    public String getInitParameter(String name) {
+        Object prop = reference.getProperty(name);
+        return (prop == null) ? null : String.valueOf(prop);
+    }
+
+    /**
+     * @see javax.servlet.ServletConfig#getInitParameterNames()
+     */
+    public Enumeration<?> getInitParameterNames() {
+        List<?> keys = Arrays.asList(reference.getPropertyKeys());
+        return Collections.enumeration(keys);
+    }
 
-    public SlingServletConfig(ServletContext servletContext,
-            ServiceReference reference, String servletName) {
-        super(servletContext, reference, servletName);
+    /**
+     * @see javax.servlet.ServletConfig#getServletContext()
+     */
+    public ServletContext getServletContext() {
+        return servletContext;
     }
 
+    /**
+     * @see javax.servlet.ServletConfig#getServletName()
+     */
     public String getServletName() {
-        return getName();
+        return this.name;
     }
 }
\ No newline at end of file

Modified: sling/trunk/bundles/servlets/resolver/src/test/java/org/apache/sling/servlets/resolver/internal/SlingServletResolverTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/src/test/java/org/apache/sling/servlets/resolver/internal/SlingServletResolverTest.java?rev=929975&r1=929974&r2=929975&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/resolver/src/test/java/org/apache/sling/servlets/resolver/internal/SlingServletResolverTest.java
(original)
+++ sling/trunk/bundles/servlets/resolver/src/test/java/org/apache/sling/servlets/resolver/internal/SlingServletResolverTest.java
Thu Apr  1 13:57:39 2010
@@ -18,7 +18,9 @@
  */
 package org.apache.sling.servlets.resolver.internal;
 
-import static org.junit.Assert.*;
+import static org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERLVET_NAME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.lang.reflect.Field;
 import java.util.ArrayList;
@@ -41,7 +43,6 @@ import org.apache.sling.commons.testing.
 import org.apache.sling.commons.testing.sling.MockResource;
 import org.apache.sling.commons.testing.sling.MockResourceResolver;
 import org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest;
-import org.apache.sling.engine.EngineConstants;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.jcr.resource.JcrResourceResolverFactory;
 import org.apache.sling.servlets.resolver.internal.resource.MockServletResource;
@@ -112,7 +113,7 @@ public class SlingServletResolverTest {
             bundle, SlingServletResolverTest.this.servlet);
         MockServiceReference serviceReference = new MockServiceReference(bundle);
         serviceReference.setProperty(Constants.SERVICE_ID, 1L);
-        serviceReference.setProperty(EngineConstants.SLING_SERLVET_NAME,
+        serviceReference.setProperty(SLING_SERLVET_NAME,
             SERVLET_NAME);
         serviceReference.setProperty(
             ServletResolverConstants.SLING_SERVLET_PATHS, SERVLET_PATH);



Mime
View raw message