incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r984442 - in /sling/trunk/contrib/extensions/bgservlets: pom.xml src/main/java/org/apache/sling/bgservlets/impl/BackgroundRequestExecutionJob.java src/main/java/org/apache/sling/bgservlets/impl/BackgroundServletStarterFilter.java
Date Wed, 11 Aug 2010 15:28:10 GMT
Author: fmeschbe
Date: Wed Aug 11 15:28:10 2010
New Revision: 984442

URL: http://svn.apache.org/viewvc?rev=984442&view=rev
Log:
SLING-1640 Replace AuthenticationInfo request attribute with new ResourceResolver.clone method.
This allows removing the reference to the ResourceResolverFactory and the dependency on Commons
Auth.

Modified:
    sling/trunk/contrib/extensions/bgservlets/pom.xml
    sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/BackgroundRequestExecutionJob.java
    sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/BackgroundServletStarterFilter.java

Modified: sling/trunk/contrib/extensions/bgservlets/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/pom.xml?rev=984442&r1=984441&r2=984442&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/pom.xml (original)
+++ sling/trunk/contrib/extensions/bgservlets/pom.xml Wed Aug 11 15:28:10 2010
@@ -93,12 +93,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.sling</groupId>
-      <artifactId>org.apache.sling.commons.auth</artifactId>
-      <version>0.9.0-SNAPSHOT</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.sling</groupId>
       <artifactId>org.apache.sling.commons.testing</artifactId>
       <version>2.0.4-incubator</version>
       <scope>test</scope>

Modified: sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/BackgroundRequestExecutionJob.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/BackgroundRequestExecutionJob.java?rev=984442&r1=984441&r2=984442&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/BackgroundRequestExecutionJob.java
(original)
+++ sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/BackgroundRequestExecutionJob.java
Wed Aug 11 15:28:10 2010
@@ -28,7 +28,6 @@ import javax.servlet.http.HttpServletRes
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.bgservlets.BackgroundHttpServletRequest;
 import org.apache.sling.bgservlets.BackgroundHttpServletResponse;
 import org.apache.sling.bgservlets.JobData;
@@ -36,7 +35,6 @@ import org.apache.sling.bgservlets.JobPr
 import org.apache.sling.bgservlets.JobStatus;
 import org.apache.sling.bgservlets.JobStorage;
 import org.apache.sling.bgservlets.RuntimeState;
-import org.apache.sling.commons.auth.spi.AuthenticationInfo;
 import org.apache.sling.engine.SlingServlet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -57,27 +55,21 @@ class BackgroundRequestExecutionJob impl
     private final Date creationTime;
     private Date estimatedCompletionTime;
     private String progressMessage;
-    
+
     BackgroundRequestExecutionJob(SlingServlet slingServlet,
-            ResourceResolverFactory rrf, JobStorage storage, SlingHttpServletRequest request,
+            JobStorage storage, SlingHttpServletRequest request,
             HttpServletResponse hsr, String[] parametersToRemove)
             throws IOException, LoginException {
         this.request = new BackgroundHttpServletRequest(request,
                 parametersToRemove);
         this.slingServlet = slingServlet;
-        
+
         // Provide this as the RuntimeState for the background servlet
         this.request.setAttribute(RuntimeState.class.getName(), this);
 
         // Need a new ResourceResolver with the same credentials as the
         // current request, for the background request.
-        final AuthenticationInfo aa = (AuthenticationInfo) request
-                .getAttribute(AuthenticationInfo.class.getName());
-        if (aa == null) {
-            throw new IllegalArgumentException(
-                    "Missing AuthenticationInfo attribute");
-        }
-        resourceResolver = rrf.getResourceResolver(aa);
+        resourceResolver = request.getResourceResolver().clone(null);
 
         // Get JobData, defines path and used to save servlet output to the repository
         final Session s = resourceResolver.adaptTo(Session.class);
@@ -114,6 +106,9 @@ class BackgroundRequestExecutionJob impl
                 // TODO report errors in the background job's output
                 log.error("ServletResponseWrapper cleanup failed", ioe);
             }
+
+            // cleanup the resource resolver
+            resourceResolver.close();
         }
     }
 
@@ -136,7 +131,7 @@ class BackgroundRequestExecutionJob impl
     public Date getCreationTime() {
         return creationTime;
     }
-    
+
     public JobProgressInfo getProgressInfo() {
         return this;
     }
@@ -144,7 +139,7 @@ class BackgroundRequestExecutionJob impl
     public String getProgressMessage() {
         return progressMessage;
     }
-    
+
     public Date getEstimatedCompletionTime() {
         return estimatedCompletionTime;
     }

Modified: sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/BackgroundServletStarterFilter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/BackgroundServletStarterFilter.java?rev=984442&r1=984441&r2=984442&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/BackgroundServletStarterFilter.java
(original)
+++ sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/BackgroundServletStarterFilter.java
Wed Aug 11 15:28:10 2010
@@ -35,7 +35,6 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.bgservlets.ExecutionEngine;
 import org.apache.sling.bgservlets.JobStorage;
 import org.apache.sling.engine.SlingServlet;
@@ -48,8 +47,8 @@ import org.slf4j.LoggerFactory;
  * parameters are set. Must be placed early in the filter chain.
  */
 @Component(
-        metatype=true, 
-        label="%BackgroundServletStarterFilter.label", 
+        metatype=true,
+        label="%BackgroundServletStarterFilter.label",
         description="%BackgroundServletStarterFilter.description")
 @Service
 @Properties( {
@@ -66,12 +65,9 @@ public class BackgroundServletStarterFil
     private SlingServlet slingServlet;
 
     @Reference
-    private ResourceResolverFactory resourceResolverFactory;
-    
-    @Reference
     private JobStorage jobStorage;
-    
-    /** Name of the property that defines the request parameter name to 
+
+    /** Name of the property that defines the request parameter name to
      *  use to start a servlet in the background.
      */
     @Property(value="sling:bg")
@@ -89,7 +85,7 @@ public class BackgroundServletStarterFil
         }
         log.info("Request parameter {} will run servlets in the background", bgParamName);
     }
-    
+
     public void doFilter(final ServletRequest sreq,
             final ServletResponse sresp, final FilterChain chain)
             throws IOException, ServletException {
@@ -103,15 +99,15 @@ public class BackgroundServletStarterFil
                             + sresp.getClass().getName());
         }
         final HttpServletRequest request = (HttpServletRequest) sreq;
-        final SlingHttpServletRequest slingRequest = 
+        final SlingHttpServletRequest slingRequest =
             (request instanceof SlingHttpServletRequest ? (SlingHttpServletRequest) request
: null);
         final HttpServletResponse response = (HttpServletResponse) sresp;
         final String bgParam = sreq.getParameter(bgParamName);
         if (Boolean.valueOf(bgParam)) {
             try {
                 final BackgroundRequestExecutionJob job = new BackgroundRequestExecutionJob(
-                        slingServlet, resourceResolverFactory, jobStorage,
-                        slingRequest, response, new String[] { bgParamName });
+                    slingServlet, jobStorage, slingRequest, response,
+                    new String[] { bgParamName });
                 log.debug("{} parameter true, running request in the background ({})",
                         bgParamName, job);
                 if (slingRequest != null) {



Mime
View raw message