incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r966198 - in /sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine: SlingServlet.java impl/SlingMainServlet.java
Date Wed, 21 Jul 2010 12:00:59 GMT
Author: bdelacretaz
Date: Wed Jul 21 12:00:59 2010
New Revision: 966198

URL: http://svn.apache.org/viewvc?rev=966198&view=rev
Log:
SLING-1603 - apply SLING-1603 patch

Added:
    sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine/SlingServlet.java
  (with props)
Modified:
    sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java

Added: sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine/SlingServlet.java
URL: http://svn.apache.org/viewvc/sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine/SlingServlet.java?rev=966198&view=auto
==============================================================================
--- sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine/SlingServlet.java
(added)
+++ sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine/SlingServlet.java
Wed Jul 21 12:00:59 2010
@@ -0,0 +1,33 @@
+package org.apache.sling.engine;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.sling.api.resource.ResourceResolver;
+
+/**
+ * Interface to the main Sling Servlet, that allows for running requests outside
+ * of the servlet container's HTTP request/response cycle.
+ */
+public interface SlingServlet {
+    /**
+     * Process an HTTP request
+     * 
+     * @param request
+     *            Usually a "synthetic" request, i.e. not supplied by servlet
+     *            container
+     * @param resource
+     *            Usually a "synthetic" response, i.e. not supplied by servlet
+     *            container
+     * @param resourceResolver
+     *            A "fresh" ResourceResolver is needed to process a request
+     *            outside of the HTTP request/response cycle. It is usually
+     *            created based on the AuthenticationInfo from the original
+     *            request.
+     */
+    void processRequest(HttpServletRequest request,
+            HttpServletResponse resource, ResourceResolver resourceResolver)
+            throws IOException;
+}
\ No newline at end of file

Propchange: sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine/SlingServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine/SlingServlet.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java
URL: http://svn.apache.org/viewvc/sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java?rev=966198&r1=966197&r2=966198&view=diff
==============================================================================
--- sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java
(original)
+++ sling/branches/SLING-1603-engine/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java
Wed Jul 21 12:00:59 2010
@@ -58,8 +58,10 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.servlets.ServletResolver;
 import org.apache.sling.commons.auth.AuthenticationSupport;
+import org.apache.sling.commons.auth.impl.SlingAuthenticator;
 import org.apache.sling.commons.mime.MimeTypeService;
 import org.apache.sling.commons.osgi.OsgiUtil;
+import org.apache.sling.engine.SlingServlet;
 import org.apache.sling.engine.impl.filter.RequestSlingFilterChain;
 import org.apache.sling.engine.impl.filter.SlingComponentFilterChain;
 import org.apache.sling.engine.impl.filter.SlingFilterChainHelper;
@@ -86,6 +88,7 @@ import org.slf4j.LoggerFactory;
  *
  * @scr.component immediate="true" label="%sling.name"
  *                description="%sling.description"
+ * @scr.service interface="org.apache.sling.engine.SlingServlet"               
  * @scr.property name="service.vendor" value="The Apache Software Foundation"
  * @scr.property name="service.description" value="Sling Servlet"
  * @scr.reference name="Filter" interface="javax.servlet.Filter"
@@ -93,7 +96,7 @@ import org.slf4j.LoggerFactory;
  */
 @SuppressWarnings("serial")
 public class SlingMainServlet extends GenericServlet implements ErrorHandler,
-        HttpContext {
+        HttpContext, SlingServlet {
 
     /** @scr.property valueRef="RequestData.DEFAULT_MAX_CALL_COUNTER" */
     public static final String PROP_MAX_CALL_COUNTER = "sling.max.calls";
@@ -180,6 +183,22 @@ public class SlingMainServlet extends Ge
 
     private Object printerRegistration;
 
+    // ---------- SlingServlet API -------------------------------------------------
+
+    public void processRequest(HttpServletRequest req, HttpServletResponse res,
+            ResourceResolver resourceResolver) throws IOException {
+        if (resourceResolver != null) {
+            log.debug("Using ResourceResolver provided by caller");
+            req.setAttribute(SlingAuthenticator.REQUEST_ATTRIBUTE_RESOLVER, resourceResolver);
+        } else if (req.getAttribute(SlingAuthenticator.REQUEST_ATTRIBUTE_RESOLVER) == null)
{
+            throw new IllegalArgumentException(
+                    "No ResourceResolver provided by caller, and "
+                            + SlingAuthenticator.REQUEST_ATTRIBUTE_RESOLVER
+                            + " request attribute is null");
+        }
+        service(req, res);
+    }
+
     // ---------- Servlet API -------------------------------------------------
 
     public void service(ServletRequest req, ServletResponse res)



Mime
View raw message