incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r618938 - in /incubator/sling/trunk: api/src/main/java/org/apache/sling/api/ api/src/main/java/org/apache/sling/api/wrappers/ scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/ sling/core/src/main/java/org/apache/sling/co...
Date Wed, 06 Feb 2008 09:42:47 GMT
Author: fmeschbe
Date: Wed Feb  6 01:42:44 2008
New Revision: 618938

URL: http://svn.apache.org/viewvc?rev=618938&view=rev
Log:
SLING-225 Add getRequestDispatcher(String, RequestDispatcherOptions) method

Modified:
    incubator/sling/trunk/api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java
    incubator/sling/trunk/api/src/main/java/org/apache/sling/api/wrappers/SlingHttpServletRequestWrapper.java
    incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/ScriptHelper.java
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/helper/SlingServletContext.java
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/request/SlingRequestDispatcher.java

Modified: incubator/sling/trunk/api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java?rev=618938&r1=618937&r2=618938&view=diff
==============================================================================
--- incubator/sling/trunk/api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java
(original)
+++ incubator/sling/trunk/api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java
Wed Feb  6 01:42:44 2008
@@ -58,7 +58,7 @@
 
     /**
      * Returns the {@link Resource} object on whose behalf the servlet acts.
-     *
+     * 
      * @return The <code>Resource</code> object of this request.
      */
     Resource getResource();
@@ -66,14 +66,14 @@
     /**
      * Returns the {@link ResourceResolver} which resolved the
      * {@link #getResource() resource} of this request.
-     *
+     * 
      * @return The resource resolver
      */
     ResourceResolver getResourceResolver();
 
     /**
      * Returns the {@link RequestPathInfo} pertaining to this request.
-     *
+     * 
      * @return the request path info.
      */
     RequestPathInfo getRequestPathInfo();
@@ -92,7 +92,7 @@
      * <p>
      * This method is a shortcut for
      * <code>getRequestParameterMap().getValue(String)</code>.
-     *
+     * 
      * @param name a <code>String</code> specifying the name of the parameter
      * @return a {@link RequestParameter} representing the single value of the
      *         parameter
@@ -111,7 +111,7 @@
      * <p>
      * This method is a shortcut for
      * <code>getRequestParameterMap().getValues(String)</code>.
-     *
+     * 
      * @param name a <code>String</code> containing the name of the parameter
      *            the value of which is requested
      * @return an array of {@link RequestParameter} objects containing the
@@ -129,7 +129,7 @@
      * {@link RequestParameter} array (<code>RequestParameter[]</code>).
      * <p>
      * If no parameters exist this method returns an empty <code>Map</code>.
-     *
+     * 
      * @return an immutable <code>Map</code> containing parameter names as
      *         keys and parameter values as map values, or an empty
      *         <code>Map</code> if no parameters exist. The keys in the
@@ -144,27 +144,49 @@
      * <code>RequestDispatcher</code> object can be used to include the
      * resource in a response.
      * <p>
-     * Returns <code>null</code> if a
-     * <code>RequestDispatcher</code> cannot be returned for any reason.
-     *
+     * Returns <code>null</code> if a <code>RequestDispatcher</code>
cannot
+     * be returned for any reason.
+     * 
+     * @param path a <code>String</code> specifying the pathname to the
+     *            resource. If it is relative, it must be relative against the
+     *            current servlet.
+     * @param options influence the rendering of the included Resource
+     * @return a <code>RequestDispatcher</code> object that acts as a wrapper
+     *         for the <code>resource</code> or <code>null</code>
if an
+     *         error occurs preparing the dispatcher.
+     */
+    RequestDispatcher getRequestDispatcher(String path,
+            RequestDispatcherOptions options);
+
+    /**
+     * Returns a <code>RequestDispatcher</code> object that acts as a wrapper
+     * for the resource located at the given resource. A
+     * <code>RequestDispatcher</code> object can be used to include the
+     * resource in a response.
+     * <p>
+     * Returns <code>null</code> if a <code>RequestDispatcher</code>
cannot
+     * be returned for any reason.
+     * 
      * @param resource The {@link Resource} instance whose response content may
      *            be included by the returned dispatcher.
-     * @param options influence the rendering of the included Resource            
+     * @param options influence the rendering of the included Resource
      * @return a <code>RequestDispatcher</code> object that acts as a wrapper
      *         for the <code>resource</code> or <code>null</code>
if an
      *         error occurs preparing the dispatcher.
      */
-    RequestDispatcher getRequestDispatcher(Resource resource, RequestDispatcherOptions options);
-    
-    /** Same as {@link #getRequestDispatcher(Resource,RequestDispatcherOptions)} but using
-     *  empty options.
+    RequestDispatcher getRequestDispatcher(Resource resource,
+            RequestDispatcherOptions options);
+
+    /**
+     * Same as {@link #getRequestDispatcher(Resource,RequestDispatcherOptions)}
+     * but using empty options.
      */
     RequestDispatcher getRequestDispatcher(Resource resource);
 
     /**
      * Returns the named cookie from the HTTP request or <code>null</code> if
      * no such cookie exists in the request.
-     *
+     * 
      * @param name The name of the cookie to return.
      * @return The named cookie or <code>null</code> if no such cookie exists.
      */
@@ -177,7 +199,7 @@
      * For included resources this method will returned the same string as
      * returned by the <code>ServletResponse.getContentType()</code> without
      * the character set.
-     *
+     * 
      * @return preferred MIME type of the response
      */
     String getResponseContentType();
@@ -192,14 +214,14 @@
      * containing a single entry which is the same string as returned by the
      * <code>ServletResponse.getContentType()</code> without the character
      * set.
-     *
+     * 
      * @return ordered list of MIME types for the response
      */
     Enumeration<String> getResponseContentTypes();
 
     /**
      * Returns the resource bundle for the given locale.
-     *
+     * 
      * @param locale the locale for which to retrieve the resource bundle. If
      *            this is <code>null</code>, the locale returned by
      *            {@link #getLocale()} is used to select the resource bundle.
@@ -214,7 +236,8 @@
 
     /**
      * Returns a {@link ServiceLocator} instance which may be queried for helper
-     * services such as the {@link org.apache.sling.api.resource.ResourceResolver},
+     * services such as the
+     * {@link org.apache.sling.api.resource.ResourceResolver},
      * {@link org.apache.sling.api.scripting.SlingScriptResolver} and
      * {@link org.apache.sling.api.servlets.ServletResolver}.
      */

Modified: incubator/sling/trunk/api/src/main/java/org/apache/sling/api/wrappers/SlingHttpServletRequestWrapper.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/wrappers/SlingHttpServletRequestWrapper.java?rev=618938&r1=618937&r2=618938&view=diff
==============================================================================
--- incubator/sling/trunk/api/src/main/java/org/apache/sling/api/wrappers/SlingHttpServletRequestWrapper.java
(original)
+++ incubator/sling/trunk/api/src/main/java/org/apache/sling/api/wrappers/SlingHttpServletRequestWrapper.java
Wed Feb  6 01:42:44 2008
@@ -69,8 +69,14 @@
         return getSlingRequest().getRequestDispatcher(resource);
     }
 
-    public RequestDispatcher getRequestDispatcher(Resource resource, RequestDispatcherOptions
options) {
+    public RequestDispatcher getRequestDispatcher(Resource resource,
+            RequestDispatcherOptions options) {
         return getSlingRequest().getRequestDispatcher(resource, options);
+    }
+
+    public RequestDispatcher getRequestDispatcher(String path,
+            RequestDispatcherOptions options) {
+        return getSlingRequest().getRequestDispatcher(path, options);
     }
 
     public RequestParameter getRequestParameter(String name) {

Modified: incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/ScriptHelper.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/ScriptHelper.java?rev=618938&r1=618937&r2=618938&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/ScriptHelper.java
(original)
+++ incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/ScriptHelper.java
Wed Feb  6 01:42:44 2008
@@ -44,9 +44,11 @@
 public class ScriptHelper implements SlingScriptHelper {
 
     private final SlingScript script;
+
     private final SlingHttpServletRequest request;
+
     private final SlingHttpServletResponse response;
-    
+
     private final Logger log = LoggerFactory.getLogger(ScriptHelper.class);
 
     public ScriptHelper(SlingScript script, SlingHttpServletRequest request,
@@ -75,19 +77,22 @@
      *             thrown while handling the include.
      */
     public void include(String path) {
-        include(path, null);
+        include(path, (RequestDispatcherOptions) null);
     }
 
     /** Include the output of another request, using specified options */
     public void include(String path, String options) {
         final RequestDispatcherOptionsParser parser = new RequestDispatcherOptionsParser();
-        final RequestDispatcherOptions opt = parser.parse(options); 
-        final RequestDispatcher dispatcher = getRequest().getRequestDispatcher(path);
-        
-        if (opt != null) {
-            getRequest().setAttribute(RequestDispatcherOptions.class.getName(), opt);
-        }
-        
+        final RequestDispatcherOptions opt = parser.parse(options);
+
+        include(path, opt);
+    }
+
+    /** Include the output of another request, using specified options */
+    public void include(String path, RequestDispatcherOptions options) {
+        final RequestDispatcher dispatcher = getRequest().getRequestDispatcher(
+            path, options);
+
         if (dispatcher != null) {
             try {
                 dispatcher.include(getRequest(), getResponse());

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java?rev=618938&r1=618937&r2=618938&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java
(original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java
Wed Feb  6 01:42:44 2008
@@ -106,9 +106,14 @@
      * @see javax.servlet.ServletRequestWrapper#getRequestDispatcher(java.lang.String)
      */
     public RequestDispatcher getRequestDispatcher(String path) {
-        return new SlingRequestDispatcher(path);
+        return new SlingRequestDispatcher(path, null);
     }
 
+    public RequestDispatcher getRequestDispatcher(String path,
+            RequestDispatcherOptions options) {
+        return new SlingRequestDispatcher(path, options);
+    }
+    
     /**
      * @see javax.servlet.ServletRequestWrapper#getLocale()
      */

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/helper/SlingServletContext.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/helper/SlingServletContext.java?rev=618938&r1=618937&r2=618938&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/helper/SlingServletContext.java
(original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/helper/SlingServletContext.java
Wed Feb  6 01:42:44 2008
@@ -234,7 +234,7 @@
             return null;
         }
 
-        return new SlingRequestDispatcher(path);
+        return new SlingRequestDispatcher(path, null);
     }
 
     /**

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/request/SlingRequestDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/request/SlingRequestDispatcher.java?rev=618938&r1=618937&r2=618938&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/request/SlingRequestDispatcher.java
(original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/request/SlingRequestDispatcher.java
Wed Feb  6 01:42:44 2008
@@ -41,11 +41,12 @@
 
     private String path;
 
-    public SlingRequestDispatcher(String path) {
+    public SlingRequestDispatcher(String path,
+            RequestDispatcherOptions options) {
         this.path = path;
+        this.options = options;
 
         this.resource = null;
-        this.options = null;
     }
 
     public SlingRequestDispatcher(Resource resource,
@@ -63,11 +64,6 @@
          *  and SLING-222, but haven't had time to do a proper review. This
          *  method might deserve a more extensive rewrite. 
          */
-        
-        // get options from request attribute if we don't have them yet
-        if(options == null) {
-            options = (RequestDispatcherOptions)request.getAttribute(RequestDispatcherOptions.class.getName());
-        }
         
         // this may throw an exception in case loading fails, which is
         // ok here, if no content is available at that path null is



Mime
View raw message