incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r602072 - in /incubator/sling/trunk: scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/ scripting/jsp-taglib/src/main/resources/META-INF/ scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/util/ sling/sample/s...
Date Fri, 07 Dec 2007 11:32:34 GMT
Author: cziegeler
Date: Fri Dec  7 03:32:31 2007
New Revision: 602072

URL: http://svn.apache.org/viewvc?rev=602072&view=rev
Log:
Readding resource manager to taglib.

Modified:
    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/util/TagUtil.java
    incubator/sling/trunk/sling/sample/src/main/scripts/sling/scripts/org/apache/sling/sample/html.jsp

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=602072&r1=602071&r2=602072&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
Fri Dec  7 03:32:31 2007
@@ -29,6 +29,7 @@
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceManager;
 import org.apache.sling.api.services.ServiceLocator;
 
 /**
@@ -79,12 +80,20 @@
      */
     public static final String ATTR_SERVICE_LOCATOR_NAME = "serviceLocatorName";
 
+    /**
+     * The name of the tag attribute used to define the name of the
+     * ResourceManager scripting variable (value is "resourceManagerName").
+     */
+    public static final String ATTR_RESOURCE_MANAGER_NAME = "resourceManagerName";
+
     private static final String RENDER_REQUEST_CLASS = SlingHttpServletRequest.class.getName();
 
     private static final String RENDER_RESPONSE_CLASS = SlingHttpServletResponse.class.getName();
 
     private static final String RESOURCE_CLASS = Resource.class.getName();
 
+    private static final String RESOURCE_MANAGER_CLASS = ResourceManager.class.getName();
+
     private static final String NODE_CLASS = Node.class.getName();
 
     private static final String SERVICE_LOCATOR_CLASS = ServiceLocator.class.getName();
@@ -112,6 +121,9 @@
             null);
         addVar(varInfos, data, ATTR_MAPPED_OBJECT_NAME,
             DEFAULT_MAPPED_OBJECT_NAME, mappedObjectClass);
+
+        addVar(varInfos, data, ATTR_RESOURCE_MANAGER_NAME,
+            DEFAULT_RESOURCE_MANAGER_NAME, RESOURCE_MANAGER_CLASS);
 
         addVar(varInfos, data, ATTR_SERVICE_LOCATOR_NAME,
             DEFAULT_SERVICE_LOCATOR_NAME, SERVICE_LOCATOR_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=602072&r1=602071&r2=602072&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
Fri Dec  7 03:32:31 2007
@@ -22,6 +22,7 @@
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceManager;
 import org.apache.sling.scripting.jsp.util.TagUtil;
 
 /**
@@ -65,6 +66,12 @@
 
     /**
      * Default name for the scripting variable referencing the current
+     * <code>ResourceManager</code> (value is "resourceManager").
+     */
+    public static final String DEFAULT_RESOURCE_MANAGER_NAME = "resourceManager";
+
+    /**
+     * Default name for the scripting variable referencing the current
      * <code>ServiceLocator</code> (value is "serviceLocator").
      */
     public static final String DEFAULT_SERVICE_LOCATOR_NAME = "serviceLocator";
@@ -81,6 +88,8 @@
 
     private String mappedObjectClass = null;
 
+    private String resourceManagerName = DEFAULT_RESOURCE_MANAGER_NAME;
+
     private String serviceLocatorName = DEFAULT_SERVICE_LOCATOR_NAME;
 
     /**
@@ -96,6 +105,7 @@
      * <li><code>SlingHttpServletResponse</code>
      * <li>current <code>Resource</code>
      * <li>current <code>Node</code> (if resource is a NodeProvider)
+     * <li>current <code>ResourceManager</code>
      * <li>current <code>ServiceLocator</code>
      * </ul>
      *
@@ -106,10 +116,12 @@
         SlingHttpServletRequest req = TagUtil.getRequest(pageContext);
         SlingHttpServletResponse res = TagUtil.getResponse(pageContext);
         Resource resource = req.getResource();
+        ResourceManager resourceManager = TagUtil.getResourceManager(pageContext);
 
         pageContext.setAttribute(requestName, req);
         pageContext.setAttribute(responseName, res);
         pageContext.setAttribute(resourceName, resource);
+        pageContext.setAttribute(resourceManagerName, resourceManager);
         pageContext.setAttribute(serviceLocatorName, req.getServiceLocator());
 
         Node node = resource.adaptTo(Node.class);
@@ -152,6 +164,10 @@
 
     public void setMappedObjectClass(String name) {
         this.mappedObjectClass = name;
+    }
+
+    public void setResourceManagerName(String name) {
+        this.resourceManagerName = name;
     }
 
     public void setServiceLocatorName(String 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=602072&r1=602071&r2=602072&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 Fri
Dec  7 03:32:31 2007
@@ -129,6 +129,11 @@
             <rtexprvalue>false</rtexprvalue>
         </attribute>
         <attribute>
+            <name>resourceManagerName</name>
+            <required>false</required>
+            <rtexprvalue>false</rtexprvalue>
+        </attribute>
+        <attribute>
             <name>serviceLocatorName</name>
             <required>false</required>
             <rtexprvalue>false</rtexprvalue>

Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/util/TagUtil.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/util/TagUtil.java?rev=602072&r1=602071&r2=602072&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/util/TagUtil.java
(original)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/util/TagUtil.java
Fri Dec  7 03:32:31 2007
@@ -25,6 +25,7 @@
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.ResourceManager;
 import org.slf4j.Logger;
 
 /**
@@ -110,5 +111,14 @@
         }
 
         return (SlingHttpServletResponse) req;
+    }
+
+    public static ResourceManager getResourceManager(PageContext pageContext) {
+        try {
+            SlingHttpServletRequest request = getRequest(pageContext);
+            return (ResourceManager) request.getResourceResolver();
+        } catch (ClassCastException cce) {
+            throw new IllegalStateException("resource resolver wrong class");
+        }
     }
 }

Modified: incubator/sling/trunk/sling/sample/src/main/scripts/sling/scripts/org/apache/sling/sample/html.jsp
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/sample/src/main/scripts/sling/scripts/org/apache/sling/sample/html.jsp?rev=602072&r1=602071&r2=602072&view=diff
==============================================================================
--- incubator/sling/trunk/sling/sample/src/main/scripts/sling/scripts/org/apache/sling/sample/html.jsp
(original)
+++ incubator/sling/trunk/sling/sample/src/main/scripts/sling/scripts/org/apache/sling/sample/html.jsp
Fri Dec  7 03:32:31 2007
@@ -29,7 +29,7 @@
 <p><%= sampleContent.getText() %></p>
 <table border="1" cellpadding="3" cellspacing="0">
 <%
-	Iterator<Resource> ci = slingRequest.getResourceResolver().listChildren(resource);
+	Iterator<Resource> ci = resourceManager.listChildren(resource);
 	while (ci.hasNext()) {
 		Resource child = ci.next();
 		%><tr><td><sling:include resource="<%= child %>" /></td></tr><%



Mime
View raw message