You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2007/11/27 09:31:58 UTC

svn commit: r598553 - in /incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/scripting: DefaultSlingScriptResolver.java helper/ScriptHelper.java

Author: fmeschbe
Date: Tue Nov 27 00:31:58 2007
New Revision: 598553

URL: http://svn.apache.org/viewvc?rev=598553&view=rev
Log:
SLING-98 ScriptHelper must implement the Sling API SlingScriptHelper interface

Modified:
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/scripting/DefaultSlingScriptResolver.java
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/scripting/helper/ScriptHelper.java

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/scripting/DefaultSlingScriptResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/scripting/DefaultSlingScriptResolver.java?rev=598553&r1=598552&r2=598553&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/scripting/DefaultSlingScriptResolver.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/scripting/DefaultSlingScriptResolver.java Tue Nov 27 00:31:58 2007
@@ -94,7 +94,7 @@
             IOException {
         try {
             // the script helper
-            ScriptHelper helper = new ScriptHelper(req, resp);
+            ScriptHelper helper = new ScriptHelper(script, req, resp);
 
             // prepare the properties for the script
             Map<String, Object> props = new HashMap<String, Object>();
@@ -167,7 +167,7 @@
         String scriptFilename = scriptFilenameBuilder.buildScriptFilename(
             request.getMethod(),
             request.getRequestPathInfo().getSelectorString(),
-            request.getResponseContentType(), "*");
+            request.getRequestPathInfo().getExtension(), "*");
         String scriptPath = scriptFilenameBuilder.buildScriptPath(r);
 
         // SLING-72: if the scriptfilename contains a relative path, move that

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/scripting/helper/ScriptHelper.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/scripting/helper/ScriptHelper.java?rev=598553&r1=598552&r2=598553&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/scripting/helper/ScriptHelper.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/scripting/helper/ScriptHelper.java Tue Nov 27 00:31:58 2007
@@ -28,6 +28,9 @@
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.request.RequestDispatcherOptions;
+import org.apache.sling.api.scripting.SlingScript;
+import org.apache.sling.api.scripting.SlingScriptHelper;
 import org.apache.sling.api.wrappers.SlingHttpServletResponseWrapper;
 
 /** Simple script helper providing access to the (wrapped) response, the
@@ -35,17 +38,24 @@
  * class are made available to the scripts as the global <code>sling</code>
  * variable.
  */
-public class ScriptHelper {
+public class ScriptHelper implements SlingScriptHelper {
+
+    private final SlingScript script;
 
     private final SlingHttpServletRequest request;
 
     private final SlingHttpServletResponse response;
 
-    public ScriptHelper(SlingHttpServletRequest request, SlingHttpServletResponse response) {
+    public ScriptHelper(SlingScript script, SlingHttpServletRequest request, SlingHttpServletResponse response) {
+        this.script = script;
         this.request = request;
         this.response = new OnDemandWriterResponse(response);
     }
 
+    public SlingScript getScript() {
+        return script;
+    }
+
     public SlingHttpServletRequest getRequest() {
         return request;
     }
@@ -55,11 +65,18 @@
     }
 
     public void include(String path) throws ServletException, IOException {
+        include(path, null);
+    }
+
+    public void include(String path, RequestDispatcherOptions options)
+            throws ServletException, IOException {
+        // TODO: Implement for options !!
         RequestDispatcher dispatcher = getRequest().getRequestDispatcher(path);
         if (dispatcher != null) {
             dispatcher.include(getRequest(), getResponse());
         }
     }
+
 
     /** Simple Response wrapper returning an on-demand writer when asked for
      * a writer.