You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ju...@apache.org on 2011/12/21 02:02:46 UTC
svn commit: r1221545 - in /sling/trunk/bundles:
api/src/main/java/org/apache/sling/api/
auth/core/src/main/java/org/apache/sling/auth/core/impl/
engine/src/main/java/org/apache/sling/engine/impl/
Author: justin
Date: Wed Dec 21 01:02:45 2011
New Revision: 1221545
URL: http://svn.apache.org/viewvc?rev=1221545&view=rev
Log:
SLING-2337 - introduce a flag which, if set as a request attribute, skips the session closing. Inline this constant into auth.core and engine so as to avoid requiring the new API bundle.
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/SlingConstants.java
sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java
Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/SlingConstants.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/SlingConstants.java?rev=1221545&r1=1221544&r2=1221545&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/SlingConstants.java (original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/SlingConstants.java Wed Dec 21 01:02:45 2011
@@ -87,6 +87,15 @@ public class SlingConstants {
public static final String ATTR_REQUEST_PATH_INFO = "org.apache.sling.api.include.request_path_info";
/**
+ * The name of a request attribute which, if present, indicates that the
+ * <code>ResourceResolver</code> created by the engine during authentication
+ * should not be automatically closed.
+ * <p>
+ * @since 2.3
+ */
+ public static final String ATTR_RESOURCE_RESOLVER_SKIP_CLOSE = "org.apache.sling.api.resource.ResourceResolver.skip.close";
+
+ /**
* The name of the request attribute containing the
* <code>HttpServletRequest.getRequestURI()</code> of the request which
* included the servlet currently being active underlying the
Modified: sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java?rev=1221545&r1=1221544&r2=1221545&view=diff
==============================================================================
--- sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java (original)
+++ sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java Wed Dec 21 01:02:45 2011
@@ -25,6 +25,7 @@ import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+
import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
@@ -49,6 +50,7 @@ import org.apache.sling.api.resource.Res
import org.apache.sling.auth.core.AuthUtil;
import org.apache.sling.auth.core.AuthenticationSupport;
import org.apache.sling.auth.core.impl.engine.EngineAuthenticationHandlerHolder;
+import org.apache.sling.auth.core.spi.AbstractAuthenticationHandler;
import org.apache.sling.auth.core.spi.AuthenticationFeedbackHandler;
import org.apache.sling.auth.core.spi.AuthenticationHandler;
import org.apache.sling.auth.core.spi.AuthenticationInfo;
@@ -180,6 +182,14 @@ public class SlingAuthenticator implemen
*/
private static final String AUTH_INFO_PROP_FEEDBACK_HANDLER = "$$sling.auth.AuthenticationFeedbackHandler$$";
+ /**
+ * Constant copied from <code>SlingConstants</code> to enable compatibility
+ * with older API bundle.
+ *
+ * TODO - remove once Sling API 2.3.0 has been released
+ */
+ private static final String ATTR_RESOURCE_RESOLVER_SKIP_CLOSE = "org.apache.sling.api.resource.ResourceResolver.skip.close";
+
@Reference
private ResourceResolverFactory resourceResolverFactory;
@@ -592,7 +602,9 @@ public class SlingAuthenticator implemen
ServletRequest request = sre.getServletRequest();
Object resolverAttr = request.getAttribute(REQUEST_ATTRIBUTE_RESOLVER);
if (resolverAttr instanceof ResourceResolver) {
- ((ResourceResolver) resolverAttr).close();
+ if (request.getAttribute(ATTR_RESOURCE_RESOLVER_SKIP_CLOSE) == null) {
+ ((ResourceResolver) resolverAttr).close();
+ }
request.removeAttribute(REQUEST_ATTRIBUTE_RESOLVER);
}
}
Modified: sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java?rev=1221545&r1=1221544&r2=1221545&view=diff
==============================================================================
--- sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java (original)
+++ sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java Wed Dec 21 01:02:45 2011
@@ -113,6 +113,14 @@ public class SlingMainServlet extends Ge
@Property
private static final String PROP_DEFAULT_PARAMETER_ENCODING = "sling.default.parameter.encoding";
+ /**
+ * Constant copied from <code>SlingConstants</code> to enable compatibility
+ * with older API bundle.
+ *
+ * TODO - remove once Sling API 2.3.0 has been released
+ */
+ private static final String ATTR_RESOURCE_RESOLVER_SKIP_CLOSE = "org.apache.sling.api.resource.ResourceResolver.skip.close";
+
@Reference
private HttpService httpService;
@@ -244,11 +252,12 @@ public class SlingMainServlet extends Ge
} finally {
-
- // close the resource resolver (not relying on servlet request
- // listener to do this for now; see SLING-1270)
- if (resolver != null) {
- resolver.close();
+ if (request.getAttribute(ATTR_RESOURCE_RESOLVER_SKIP_CLOSE) == null) {
+ // close the resource resolver (not relying on servlet request
+ // listener to do this for now; see SLING-1270)
+ if (resolver != null) {
+ resolver.close();
+ }
}
requestListenerManager.sendEvent( request, SlingRequestEvent.EventType.EVENT_DESTROY );