incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r589647 - in /incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api: SlingHttpServletRequest.java request/RequestDispatcherOptions.java scripting/SlingScriptHelper.java
Date Mon, 29 Oct 2007 14:52:45 GMT
Author: bdelacretaz
Date: Mon Oct 29 07:52:41 2007
New Revision: 589647

URL: http://svn.apache.org/viewvc?rev=589647&view=rev
Log:
sling-api, add RequestDispatcherOptions to give more control of the include/forwarding mechanism

Added:
    incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/request/RequestDispatcherOptions.java
  (with props)
Modified:
    incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java
    incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/scripting/SlingScriptHelper.java

Modified: incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java?rev=589647&r1=589646&r2=589647&view=diff
==============================================================================
--- incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java
(original)
+++ incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java
Mon Oct 29 07:52:41 2007
@@ -26,6 +26,7 @@
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.sling.api.request.RequestDispatcherOptions;
 import org.apache.sling.api.request.RequestParameter;
 import org.apache.sling.api.request.RequestParameterMap;
 import org.apache.sling.api.request.RequestPathInfo;
@@ -143,14 +144,20 @@
      * <code>RequestDispatcher</code> object can be used to include the
      * resource in a response.
      * <p>
-     * This method returns <code>null</code> if a
+     * 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            
      * @return a <code>RequestDispatcher</code> object that acts as a wrapper
      *         for the <code>resource</code> or <code>null</code>
if an
-     *         error occurrs preparing the dispatcher.
+     *         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);
 

Added: incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/request/RequestDispatcherOptions.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/request/RequestDispatcherOptions.java?rev=589647&view=auto
==============================================================================
--- incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/request/RequestDispatcherOptions.java
(added)
+++ incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/request/RequestDispatcherOptions.java
Mon Oct 29 07:52:41 2007
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.api.request;
+
+import java.util.HashMap;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+
+/** <code>RequestDispatcherOptions</code> are used in the
+ *  {@link SlingHttpServletRequest#getRequestDispatcher SlingHttpServletRequest.getRequestDispatcher}

+ *  method, to give more control on some aspects of the include/forward  
+ *  mechanism.
+ *  
+ *  Typical use cases include:
+ *  <ul>
+ *      <li>
+ *          Forcing a resource type, to render a Resource in a specific way, 
+ *          like for example <em>render myself in a suitable way for a navigation box</em>.
+ *      </li>
+ *      <li>
+ *          Adding selectors when including a Resource, like for example <em>add
+ *          a "teaser" selector to the request that I'm including here</em>.
+ *      </li>
+ *  </ul>
+ *  
+ *  This class currently only inherits from Map, and defines some constants 
+ *  for well-known options.
+ */
+
+public class RequestDispatcherOptions extends HashMap <String,String> {
+    
+    /** When dispatching, use the value provided by this option as the resource type, 
+     *  instead of the one defined by the {@link Resource}.
+     */
+    public static final String OPT_FORCE_RESOURCE_TYPE = "forceResourceType";
+    
+    /** When dispatching, replace {@link RequestPathInfo} selectors by the 
+     *  value provided by this option.
+     */
+    public static final String OPT_REPLACE_SELECTORS = "replaceSelectors";
+    
+    /** When dispatching, add the value provided by this option to the
+     *  {@link RequestPathInfo} selectors.
+     */
+    public static final String OPT_ADD_SELECTORS = "addSelectors"; 
+
+    /** When dispatching, replace the {@link RequestPathInfo} suffix by
+     *  the value provided by this option
+     */
+    public static final String REPLACE_SUFFIX = "replaceSuffix"; 
+
+}

Propchange: incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/request/RequestDispatcherOptions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/request/RequestDispatcherOptions.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/scripting/SlingScriptHelper.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/scripting/SlingScriptHelper.java?rev=589647&r1=589646&r2=589647&view=diff
==============================================================================
--- incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/scripting/SlingScriptHelper.java
(original)
+++ incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/scripting/SlingScriptHelper.java
Mon Oct 29 07:52:41 2007
@@ -24,6 +24,7 @@
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.request.RequestDispatcherOptions;
 
 /**
  * The <code>SlingScriptHelper</code> interface defines the API of a helper
@@ -64,8 +65,14 @@
      * </pre>
      *
      * @param path The path to the resource to include.
+     * @param options influence the rendering of the included Resource            
      * @throws ServletException Forwarded from including the resource
      * @throws IOException Forwarded from including the resource
+     */
+    void include(String path,RequestDispatcherOptions options) throws ServletException, IOException;
+
+    /** Same as {@link #include(String,RequestDispatcherOptions)}, but using 
+     *  empty options.
      */
     void include(String path) throws ServletException, IOException;
 }



Mime
View raw message