incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r654526 - in /incubator/sling/trunk: samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/SampleContent/ samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/SamplePage/ samples/simple-demo/src/main/scripts/app...
Date Thu, 08 May 2008 13:53:04 GMT
Author: cziegeler
Date: Thu May  8 06:53:04 2008
New Revision: 654526

URL: http://svn.apache.org/viewvc?rev=654526&view=rev
Log:
SLING-247: Make SlingBindings available as request attribute, remove support for mapped objects
from taglib.

Modified:
    incubator/sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/SampleContent/html.jsp
    incubator/sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/SamplePage/html.jsp
    incubator/sling/trunk/samples/simple-demo/src/main/scripts/apps/sling/sample/html.jsp
    incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java
    incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java
    incubator/sling/trunk/scripting/jsp-taglib/src/main/resources/META-INF/taglib.tld
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java

Modified: incubator/sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/SampleContent/html.jsp
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/SampleContent/html.jsp?rev=654526&r1=654525&r2=654526&view=diff
==============================================================================
--- incubator/sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/SampleContent/html.jsp
(original)
+++ incubator/sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/SampleContent/html.jsp
Thu May  8 06:53:04 2008
@@ -23,9 +23,11 @@
 <%@page import="java.util.Iterator"%>
 <%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %>
 
-<%-- Ensure the presence of the ComponentAPI objects --%>
-<sling:defineObjects mappedObjectName="sampleContent" mappedObjectClass="SampleContent"
/>
-
+<%-- Ensure the presence of the Sling objects --%>
+<sling:defineObjects/>
+<%
+    final SampleContent sampleContent = resource.adaptTo(SampleContent.class);
+%>
 <h1><%= sampleContent.getTitle() %></h1>
 <p><%= sampleContent.getText() %></p>
 <table border="1" cellpadding="3" cellspacing="0">

Modified: incubator/sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/SamplePage/html.jsp
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/SamplePage/html.jsp?rev=654526&r1=654525&r2=654526&view=diff
==============================================================================
--- incubator/sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/SamplePage/html.jsp
(original)
+++ incubator/sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/apps/sling/SamplePage/html.jsp
Thu May  8 06:53:04 2008
@@ -23,9 +23,11 @@
 <%@page import="org.apache.sling.api.resource.SyntheticResource"%>
 <%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%>
 
-<%-- Ensure the presence of the ComponentAPI objects --%>
-<sling:defineObjects mappedObjectName="samplePage"
-	mappedObjectClass="SamplePage" />
+<%-- Ensure the presence of the Sling objects --%>
+<sling:defineObjects/>
+<%
+    final SamplePage samplePage = resource.adaptTo(SamplePage.class);
+%>
 <%-- This is a top level component, so we have to draw the html and head tags --%>
 <html>
 <head>

Modified: incubator/sling/trunk/samples/simple-demo/src/main/scripts/apps/sling/sample/html.jsp
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/samples/simple-demo/src/main/scripts/apps/sling/sample/html.jsp?rev=654526&r1=654525&r2=654526&view=diff
==============================================================================
--- incubator/sling/trunk/samples/simple-demo/src/main/scripts/apps/sling/sample/html.jsp
(original)
+++ incubator/sling/trunk/samples/simple-demo/src/main/scripts/apps/sling/sample/html.jsp
Thu May  8 06:53:04 2008
@@ -22,9 +22,11 @@
 <%@page import="org.apache.sling.api.resource.Resource"%>
 <%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %>
 
-<%-- Ensure the presence of the ComponentAPI objects --%>
-<sling:defineObjects mappedObjectName="sampleContent" mappedObjectClass="SampleContent"
/>
-
+<%-- Ensure the presence of the Sling objects --%>
+<sling:defineObjects/>
+<%
+    final SampleContent sampleContent = resource.adaptTo(SampleContent.class);
+%>
 <h1><%= sampleContent.getTitle() %></h1>
 <p><%= sampleContent.getText() %></p>
 <table border="1" cellpadding="3" cellspacing="0">

Modified: incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java?rev=654526&r1=654525&r2=654526&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java
(original)
+++ incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java
Thu May  8 06:53:04 2008
@@ -17,7 +17,6 @@
 package org.apache.sling.scripting.jsp.taglib;
 
 import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_LOG_NAME;
-import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_MAPPED_OBJECT_NAME;
 import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_NODE_NAME;
 import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_REQUEST_NAME;
 import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_RESOURCE_NAME;
@@ -71,18 +70,6 @@
     public static final String ATTR_NODE_NAME = "nodeName";
 
     /**
-     * The name of the tag attribute used to define the name of the mapped
-     * object scripting variable (value is "mappedObjectName").
-     */
-    public static final String ATTR_MAPPED_OBJECT_NAME = "mappedObjectName";
-
-    /**
-     * The name of the tag attribute used to define the type of the scripting
-     * variable to take for the mapped object (value is "mappedObjectClass").
-     */
-    public static final String ATTR_MAPPED_OBJECT_CLASS = "mappedObjectClass";
-
-    /**
      * The name of the tag attribute used to define the name of the
      * SlingScriptHelper scripting variable (value is "slingName").
      */
@@ -133,11 +120,6 @@
             RESOURCE_CLASS);
         addVar(varInfos, data, ATTR_NODE_NAME, DEFAULT_NODE_NAME, NODE_CLASS);
 
-        String mappedObjectClass = getValue(data, ATTR_MAPPED_OBJECT_CLASS,
-            null);
-        addVar(varInfos, data, ATTR_MAPPED_OBJECT_NAME,
-            DEFAULT_MAPPED_OBJECT_NAME, mappedObjectClass);
-
         addVar(varInfos, data, ATTR_RESOURCE_RESOLVER_NAME,
             DEFAULT_RESOURCE_RESOLVER_NAME, RESOURCE_RESOLVER_CLASS);
 

Modified: incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java?rev=654526&r1=654525&r2=654526&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java
(original)
+++ incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java
Thu May  8 06:53:04 2008
@@ -17,7 +17,6 @@
 package org.apache.sling.scripting.jsp.taglib;
 
 import javax.jcr.Node;
-import javax.script.Bindings;
 import javax.servlet.jsp.tagext.TagSupport;
 
 import org.apache.sling.api.resource.Resource;
@@ -57,13 +56,6 @@
     public static final String DEFAULT_NODE_NAME = "currentNode";
 
     /**
-     * Default name for the scripting variable referencing the mapped object
-     * underlying the current <code>Resource</code> object (value is
-     * "mappedObject").
-     */
-    public static final String DEFAULT_MAPPED_OBJECT_NAME = "object";
-
-    /**
      * Default name for the scripting variable referencing the log
      * <code>org.slf4j.Logger</code> (value is "log").
      */
@@ -89,10 +81,6 @@
 
     private String nodeName = DEFAULT_NODE_NAME;
 
-    private String mappedObjectName = DEFAULT_MAPPED_OBJECT_NAME;
-
-    private String mappedObjectClass = null;
-
     private String slingName = DEFAULT_SLING_NAME;
 
     private String logName = DEFAULT_LOG_NAME;
@@ -119,8 +107,8 @@
      * @return always {@link #EVAL_PAGE}.
      */
     public int doEndTag() {
-        final Bindings bindings = (Bindings)pageContext.getRequest().getAttribute(Bindings.class.getName());
-        final SlingScriptHelper scriptHelper = (SlingScriptHelper)bindings.get(SlingBindings.SLING);
+        final SlingBindings bindings = (SlingBindings)pageContext.getRequest().getAttribute(SlingBindings.class.getName());
+        final SlingScriptHelper scriptHelper = bindings.getSling();
 
         pageContext.setAttribute(requestName, scriptHelper.getRequest());
         pageContext.setAttribute(responseName, scriptHelper.getResponse());
@@ -128,20 +116,12 @@
         pageContext.setAttribute(resourceName, resource);
         pageContext.setAttribute(resourceResolverName, scriptHelper.getRequest().getResourceResolver());
         pageContext.setAttribute(slingName, scriptHelper);
-        pageContext.setAttribute(logName, bindings.get(SlingBindings.LOG));
+        pageContext.setAttribute(logName, bindings.getLog());
         final Node node = resource.adaptTo(Node.class);
         if (node != null) {
             pageContext.setAttribute(nodeName, node);
         }
 
-        // only access the mappedObject if the class is set
-        if (mappedObjectClass != null) {
-            Object mappedObject = resource.adaptTo(Object.class);
-            if (mappedObject != null) {
-                pageContext.setAttribute(mappedObjectName, mappedObject);
-            }
-        }
-
         return EVAL_PAGE;
     }
 
@@ -163,14 +143,6 @@
         this.nodeName = name;
     }
 
-    public void setMappedObjectName(String name) {
-        this.mappedObjectName = name;
-    }
-
-    public void setMappedObjectClass(String name) {
-        this.mappedObjectClass = name;
-    }
-
     public void setLogName(String name) {
         this.logName = name;
     }

Modified: incubator/sling/trunk/scripting/jsp-taglib/src/main/resources/META-INF/taglib.tld
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp-taglib/src/main/resources/META-INF/taglib.tld?rev=654526&r1=654525&r2=654526&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp-taglib/src/main/resources/META-INF/taglib.tld (original)
+++ incubator/sling/trunk/scripting/jsp-taglib/src/main/resources/META-INF/taglib.tld Thu
May  8 06:53:04 2008
@@ -124,16 +124,6 @@
             <rtexprvalue>false</rtexprvalue>
         </attribute>
         <attribute>
-            <name>mappedObjectName</name>
-            <required>false</required>
-            <rtexprvalue>false</rtexprvalue>
-        </attribute>
-        <attribute>
-            <name>mappedObjectClass</name>
-            <required>false</required>
-            <rtexprvalue>false</rtexprvalue>
-        </attribute>
-        <attribute>
             <name>resourceResolverName</name>
             <required>false</required>
             <rtexprvalue>false</rtexprvalue>

Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java?rev=654526&r1=654525&r2=654526&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
(original)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
Thu May  8 06:53:04 2008
@@ -31,6 +31,7 @@
 import org.apache.sling.api.SlingException;
 import org.apache.sling.api.SlingIOException;
 import org.apache.sling.api.SlingServletException;
+import org.apache.sling.api.scripting.SlingBindings;
 import org.apache.sling.api.scripting.SlingScript;
 import org.apache.sling.api.scripting.SlingScriptHelper;
 import org.apache.sling.jcr.api.SlingRepository;
@@ -128,7 +129,10 @@
         ioProvider.setRequestResourceResolver(scriptHelper.getRequest().getResourceResolver());
         try {
             JspServletWrapperAdapter jsp = getJspWrapperAdapter(scriptHelper);
-            jsp.service(bindings);
+            // create a SlingBindings object
+            final SlingBindings slingBindings = new SlingBindings();
+            slingBindings.putAll(bindings);
+            jsp.service(slingBindings);
         } finally {
             ioProvider.resetRequestResourceResolver();
         }

Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java?rev=654526&r1=654525&r2=654526&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java
(original)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java
Thu May  8 06:53:04 2008
@@ -18,14 +18,12 @@
 
 import java.io.IOException;
 
-import javax.script.Bindings;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.sling.api.SlingException;
 import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.SlingIOException;
 import org.apache.sling.api.SlingServletException;
 import org.apache.sling.api.scripting.SlingBindings;
@@ -53,12 +51,12 @@
      * @throws IllegalArgumentException if the Jasper Precompile controller
      *             request parameter has an illegal value.
      */
-    public void service(Bindings bindings) {
-        final SlingHttpServletRequest request = (SlingHttpServletRequest) bindings.get(SlingBindings.REQUEST);
-        final Object oldValue = request.getAttribute(Bindings.class.getName());
+    public void service(SlingBindings bindings) {
+        final SlingHttpServletRequest request = bindings.getRequest();
+        final Object oldValue = request.getAttribute(SlingBindings.class.getName());
         try {
-            request.setAttribute(Bindings.class.getName(), bindings);
-            service(request, (SlingHttpServletResponse)bindings.get(SlingBindings.RESPONSE),
preCompile(request));
+            request.setAttribute(SlingBindings.class.getName(), bindings);
+            service(request, bindings.getResponse(), preCompile(request));
         } catch (SlingException se) {
             // rethrow as is
             throw se;
@@ -67,7 +65,7 @@
         } catch (ServletException se) {
             throw new SlingServletException(se);
         } finally {
-            request.setAttribute(Bindings.class.getName(), oldValue);
+            request.setAttribute(SlingBindings.class.getName(), oldValue);
         }
     }
 



Mime
View raw message