cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject svn commit: r1450217 - in /cocoon/cocoon3/trunk: cocoon-servlet/src/main/java/org/apache/cocoon/servlet/controller/ cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/ cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/ cocoon-sitemap/src/...
Date Tue, 26 Feb 2013 15:31:19 GMT
Author: ilgrosso
Date: Tue Feb 26 15:31:18 2013
New Revision: 1450217

URL: http://svn.apache.org/r1450217
Log:
Fixing StackOverflowError in STRenderer debug statement + minor cleanings

Modified:
    cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/controller/ControllerContextHelper.java
    cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/HttpContextHelper.java
    cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/ObjectModelProvider.java
    cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/SettingsHelper.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/SitemapParametersStack.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/objectmodel/ObjectModel.java
    cocoon/cocoon3/trunk/cocoon-stringtemplate/pom.xml
    cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/STRenderer.java
    cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateGenerator.java
    cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateReader.java
    cocoon/cocoon3/trunk/parent/pom.xml

Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/controller/ControllerContextHelper.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/controller/ControllerContextHelper.java?rev=1450217&r1=1450216&r2=1450217&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/controller/ControllerContextHelper.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/controller/ControllerContextHelper.java
Tue Feb 26 15:31:18 2013
@@ -24,19 +24,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * This class helps with storing and retrieving the controller context.
- * Internally it uses the current servlet request. Thanks to the servlet-service
- * framework, the current request becomes the parent of all sub-requests that
- * use e.g. the 'servlet:' protocol. This means that it is enough to store
- * objects that should be available in a sub-request into the current request.
+ * This class helps with storing and retrieving the controller context. Internally it uses
the current servlet request.
+ * Thanks to the servlet-service framework, the current request becomes the parent of all
sub-requests that use e.g. the
+ * 'servlet:' protocol. This means that it is enough to store objects that should be available
in a sub-request into the
+ * current request.
  */
 public final class ControllerContextHelper {
 
     /**
      * Logger.
      */
-    private static final Logger LOG =
-            LoggerFactory.getLogger(ControllerContextHelper.class);
+    private static final Logger LOG = LoggerFactory.getLogger(ControllerContextHelper.class);
 
     private static final String CONTEXT_OBJECT = ControllerContextHelper.class.getName();
 
@@ -46,52 +44,47 @@ public final class ControllerContextHelp
 
     /**
      * Retrieve the current controller context from the Cocoon parameters.
-     * 
+     *
      * @param parameters The Cocoon parameters map.
-     * @return The controller context map as being available in the current
-     *         servlet request.
+     * @return The controller context map as being available in the current servlet request.
      */
-    public static Map<String, Object> getContext(Map<String, ? extends Object>
parameters) {
-        HttpServletRequest request = HttpContextHelper.getRequest(parameters);
-        Object value = request.getAttribute(CONTEXT_OBJECT);
+    public static Map<String, Object> getContext(final Map<String, ? extends Object>
parameters) {
+        final HttpServletRequest request = HttpContextHelper.getRequest(parameters);
+        final Object value = request.getAttribute(CONTEXT_OBJECT);
 
         if (value instanceof Map) {
             return asControllerContext(value);
         }
 
         if (value != null) {
-            LOG.warn("The parameters contain an entry with the key " + CONTEXT_OBJECT + "
but it is not a map.");
+            LOG.warn("The parameters contain an entry with the key {} but it is not a map.",
CONTEXT_OBJECT);
         }
-        return Collections.emptyMap();
+        return Collections.<String, Object>emptyMap();
     }
 
     /**
      * Store the controller context (a {@link Map}) in the Cocoon parameters.
-     * 
-     * @param controllerContext The objects that should be available in the
-     *            child request.
+     *
+     * @param controllerContext The objects that should be available in the child request.
      * @param parameters The Cocoon parameters map.
      */
-    public static void storeContext(Map<String, Object> controllerContext, Map<String,
Object> parameters) {
-        HttpServletRequest request = HttpContextHelper.getRequest(parameters);
+    public static void storeContext(final Map<String, Object> controllerContext, final
Map<String, Object> parameters) {
+        final HttpServletRequest request = HttpContextHelper.getRequest(parameters);
         storeContext(controllerContext, request);
     }
 
     /**
-     * Store the controller context (a {@link Map} directly into the
-     * {@link HttpServletRequest}.
-     * 
-     * @param controllerContext The objects that should be available in the
-     *            child request.
-     * @param request The current request that becomes the parent of the next
-     *            request.
+     * Store the controller context (a {@link Map} directly into the {@link HttpServletRequest}.
+     *
+     * @param controllerContext The objects that should be available in the child request.
+     * @param request The current request that becomes the parent of the next request.
      */
-    public static void storeContext(Map<String, Object> controllerContext, HttpServletRequest
request) {
+    public static void storeContext(final Map<String, Object> controllerContext, final
HttpServletRequest request) {
         request.setAttribute(CONTEXT_OBJECT, controllerContext);
     }
 
     @SuppressWarnings("unchecked")
-    private static Map<String, Object> asControllerContext(Object controllerContext)
{
+    private static Map<String, Object> asControllerContext(final Object controllerContext)
{
         return (Map<String, Object>) controllerContext;
     }
 }

Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/HttpContextHelper.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/HttpContextHelper.java?rev=1450217&r1=1450216&r2=1450217&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/HttpContextHelper.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/HttpContextHelper.java
Tue Feb 26 15:31:18 2013
@@ -32,8 +32,8 @@ public class HttpContextHelper {
 
     private static final String HTTP_SERVLET_CONTEXT_KEY = ServletContext.class.getName();
 
-    public static HttpServletRequest getRequest(Map<String, ? extends Object> parameters)
{
-        Object parameter = parameters.get(HTTP_SERVLET_REQUEST_KEY);
+    public static HttpServletRequest getRequest(final Map<String, ? extends Object>
parameters) {
+        final Object parameter = parameters.get(HTTP_SERVLET_REQUEST_KEY);
         if (parameter instanceof HttpServletRequest) {
             return (HttpServletRequest) parameter;
         }
@@ -42,8 +42,8 @@ public class HttpContextHelper {
                 "A HttpServletRequest is not available. This might indicate an invocation
outside a servlet.");
     }
 
-    public static HttpServletResponse getResponse(Map<String, ? extends Object> parameters)
{
-        Object parameter = parameters.get(HTTP_SERVLET_RESPONSE_KEY);
+    public static HttpServletResponse getResponse(final Map<String, ? extends Object>
parameters) {
+        final Object parameter = parameters.get(HTTP_SERVLET_RESPONSE_KEY);
         if (parameter instanceof HttpServletResponse) {
             return (HttpServletResponse) parameter;
         }
@@ -52,8 +52,8 @@ public class HttpContextHelper {
                 "A HttpServletResponse is not available. This might indicate an invocation
outside a servlet.");
     }
 
-    public static ServletContext getServletContext(Map<String, ? extends Object> parameters)
{
-        Object parameter = parameters.get(HTTP_SERVLET_CONTEXT_KEY);
+    public static ServletContext getServletContext(final Map<String, ? extends Object>
parameters) {
+        final Object parameter = parameters.get(HTTP_SERVLET_CONTEXT_KEY);
         if (parameter instanceof ServletContext) {
             return (ServletContext) parameter;
         }
@@ -62,15 +62,21 @@ public class HttpContextHelper {
                 "The ServletContext is not available. This might indicate an invocation outside
a servlet.");
     }
 
-    public static void storeRequest(HttpServletRequest httpServletRequest, Map<String,
Object> parameters) {
+    public static void storeRequest(final HttpServletRequest httpServletRequest,
+            final Map<String, Object> parameters) {
+
         parameters.put(HTTP_SERVLET_REQUEST_KEY, httpServletRequest);
     }
 
-    public static void storeResponse(HttpServletResponse httpServletResponse, Map<String,
Object> parameters) {
+    public static void storeResponse(final HttpServletResponse httpServletResponse,
+            final Map<String, Object> parameters) {
+
         parameters.put(HTTP_SERVLET_RESPONSE_KEY, httpServletResponse);
     }
 
-    public static void storeServletContext(ServletContext servletContext, Map<String,
Object> parameters) {
+    public static void storeServletContext(final ServletContext servletContext,
+            final Map<String, Object> parameters) {
+
         parameters.put(HTTP_SERVLET_CONTEXT_KEY, servletContext);
     }
 }

Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/ObjectModelProvider.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/ObjectModelProvider.java?rev=1450217&r1=1450216&r2=1450217&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/ObjectModelProvider.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/ObjectModelProvider.java
Tue Feb 26 15:31:18 2013
@@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletReq
 import org.apache.cocoon.servlet.controller.ControllerContextHelper;
 import org.apache.cocoon.servletservice.util.ServletServiceRequest;
 import org.apache.cocoon.sitemap.objectmodel.ObjectModel;
+import org.springframework.util.StringUtils;
 
 public class ObjectModelProvider {
 
@@ -31,16 +32,16 @@ public class ObjectModelProvider {
         throw new AssertionError();
     }
 
-    public static ObjectModel provide(Map<String, Object> parameters) {
-        ObjectModel objectModel = new ObjectModel(parameters);
-        Map<String, Object> cocoon = objectModel.getCocoonObject();
+    public static ObjectModel provide(final Map<String, Object> parameters) {
+        final ObjectModel objectModel = new ObjectModel(parameters);
+        final Map<String, Object> cocoon = objectModel.getCocoonObject();
 
-        HttpServletRequest request = HttpContextHelper.getRequest(parameters);
+        final HttpServletRequest request = HttpContextHelper.getRequest(parameters);
         cocoon.put("request", new ObjectModelRequest(request));
         cocoon.put("response", HttpContextHelper.getResponse(parameters));
         cocoon.put("context", HttpContextHelper.getServletContext(parameters));
         cocoon.put("settings", SettingsHelper.getSettings(parameters));
-        Map<String, Object> controllerContext = ControllerContextHelper.getContext(parameters);
+        final Map<String, Object> controllerContext = ControllerContextHelper.getContext(parameters);
         if (controllerContext != null) {
             cocoon.put("controller", controllerContext);
         }
@@ -54,30 +55,21 @@ public class ObjectModelProvider {
      */
     public static class ObjectModelRequest extends HttpServletRequestWrapper {
 
-        public ObjectModelRequest(HttpServletRequest request) {
+        public ObjectModelRequest(final HttpServletRequest request) {
             super(request);
         }
 
-        public String get(String key) {
+        public String get(final String key) {
             return this.getParameter(key);
         }
 
         public String getEmulatedMethod() {
-            String alternativeMethod = this.getParameter("_method");
-
-            if (alternativeMethod != null && !alternativeMethod.equals("")) {
-                return alternativeMethod.toUpperCase();
-            }
-
-            return this.getMethod();
+            final String alternativeMethod = this.getParameter("_method");
+            return StringUtils.isEmpty(alternativeMethod) ? this.getMethod() : alternativeMethod.toUpperCase();
         }
 
         public boolean isSsf() {
-            if(this.getRequest() instanceof ServletServiceRequest) {
-                return true;
-            }
-
-            return false;
+            return (this.getRequest() instanceof ServletServiceRequest);
         }
     }
 }

Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/SettingsHelper.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/SettingsHelper.java?rev=1450217&r1=1450216&r2=1450217&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/SettingsHelper.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/util/SettingsHelper.java
Tue Feb 26 15:31:18 2013
@@ -20,21 +20,25 @@ import java.util.Map;
 
 import org.apache.cocoon.configuration.Settings;
 
-public class SettingsHelper {
+public final class SettingsHelper {
 
     private static final String SETTINGS_KEY = Settings.class.getName();
 
-    public static Settings getSettings(Map<String, ? extends Object> parameters) {
-        Object parameter = parameters.get(SETTINGS_KEY);
+    private SettingsHelper() {
+        // private constructor for utility classes
+    }
+
+    public static Settings getSettings(final Map<String, ? extends Object> parameters)
{
+        final Object parameter = parameters.get(SETTINGS_KEY);
         if (parameter instanceof Settings) {
             return (Settings) parameter;
         }
 
-        throw new IllegalStateException(
-                "A Settings object is not available. This might indicate that Cocoon 3 doesn't
run on top of the Cocoon Spring Configurator.");
+        throw new IllegalStateException("A Settings object is not available. "
+                + "This might indicate that Cocoon 3 doesn't run on top of the Cocoon Spring
Configurator.");
     }
 
-    public static void storeSettings(Settings settings, Map<String, Object> parameters)
{
+    public static void storeSettings(final Settings settings, final Map<String, Object>
parameters) {
         parameters.put(SETTINGS_KEY, settings);
     }
 }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/SitemapParametersStack.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/SitemapParametersStack.java?rev=1450217&r1=1450216&r2=1450217&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/SitemapParametersStack.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/SitemapParametersStack.java
Tue Feb 26 15:31:18 2013
@@ -26,20 +26,21 @@ import java.util.regex.Pattern;
 public class SitemapParametersStack {
 
     private static final Pattern ABSOLUTE_PARAMETER_PATTERN = Pattern.compile("([a-zA-z0-9]+)/(.+)");
+
     private static final String RELATIVE_LOCATION_PREFIX = "../";
-    private static final Pattern RELATIVE_PARAMETER_PATTERN = Pattern.compile("(("
-            + Pattern.quote(RELATIVE_LOCATION_PREFIX) + ")*)(.+)");
 
-    private Stack<Entry> entries = new Stack<Entry>();
+    private static final Pattern RELATIVE_PARAMETER_PATTERN =
+            Pattern.compile("((" + Pattern.quote(RELATIVE_LOCATION_PREFIX) + ")*)(.+)");
 
-    public Object getParameter(String parameterName) {
+    private Stack<Entry> entries = new Stack<Entry>();
 
-        Matcher absoluteParameterMatcher = ABSOLUTE_PARAMETER_PATTERN.matcher(parameterName);
+    public Object getParameter(final String parameterName) {
+        final Matcher absoluteParameterMatcher = ABSOLUTE_PARAMETER_PATTERN.matcher(parameterName);
         if (absoluteParameterMatcher.matches()) {
             return this.resolveAbsoluteParameter(parameterName, absoluteParameterMatcher);
         }
 
-        Matcher relativeParameterMatcher = RELATIVE_PARAMETER_PATTERN.matcher(parameterName);
+        final Matcher relativeParameterMatcher = RELATIVE_PARAMETER_PATTERN.matcher(parameterName);
         if (relativeParameterMatcher.matches()) {
             return this.resolveRelativeParameter(relativeParameterMatcher);
         }
@@ -52,11 +53,11 @@ public class SitemapParametersStack {
         this.entries.pop();
     }
 
-    public void pushParameters(String name, Map<String, ? extends Object> parameters)
{
+    public void pushParameters(final String name, final Map<String, ? extends Object>
parameters) {
         this.entries.push(new Entry(name, parameters));
     }
 
-    private Object resolveAbsoluteParameter(String parameterName, Matcher absoluteParameterMatcher)
{
+    private Object resolveAbsoluteParameter(final String parameterName, final Matcher absoluteParameterMatcher)
{
         final String entryName = absoluteParameterMatcher.group(1);
         final String name = absoluteParameterMatcher.group(2);
 
@@ -70,7 +71,7 @@ public class SitemapParametersStack {
                 + "' could not be resolved. There was no entry for the name '" + entryName
+ "'");
     }
 
-    private Object resolveRelativeParameter(Matcher relativeParameterMatcher) {
+    private Object resolveRelativeParameter(final Matcher relativeParameterMatcher) {
         final String levelPrefix = relativeParameterMatcher.group(2);
         final int level = levelPrefix == null
                 ? 0 : levelPrefix.length() / RELATIVE_LOCATION_PREFIX.length();
@@ -90,6 +91,7 @@ public class SitemapParametersStack {
     private class Entry {
 
         private String name;
+
         private Map<String, ? extends Object> parameters;
 
         public Entry(String name, Map<String, ? extends Object> parameters) {

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/objectmodel/ObjectModel.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/objectmodel/ObjectModel.java?rev=1450217&r1=1450216&r2=1450217&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/objectmodel/ObjectModel.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/objectmodel/ObjectModel.java
Tue Feb 26 15:31:18 2013
@@ -26,27 +26,27 @@ import org.apache.cocoon.sitemap.Sitemap
  */
 public class ObjectModel {
 
-    private static final String OM_KEY_COCOON = "cocoon";
+    public static final String OM_KEY_COCOON = "cocoon";
 
     private SitemapParametersStack sitemapParameters = new SitemapParametersStack();
 
     private final Map<String, Object> parameters;
 
-    public ObjectModel(Map<String, Object> parameters) {
+    public ObjectModel(final Map<String, Object> parameters) {
         super();
 
         this.parameters = parameters;
         this.parameters.put(OM_KEY_COCOON, new HashMap<String, Object>());
     }
 
-    public void put(String key, Object object) {
-        if ("cocoon".equals(key)) {
+    public void put(final String key, final Object object) {
+        if (OM_KEY_COCOON.equals(key)) {
             throw new IllegalArgumentException("The cocoon object can't be set.");
         }
         this.parameters.put(key, object);
     }
 
-    public Object get(String key) {
+    public Object get(final String key) {
         return this.parameters.get(key);
     }
 

Modified: cocoon/cocoon3/trunk/cocoon-stringtemplate/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-stringtemplate/pom.xml?rev=1450217&r1=1450216&r2=1450217&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-stringtemplate/pom.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-stringtemplate/pom.xml Tue Feb 26 15:31:18 2013
@@ -10,96 +10,100 @@
 
       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.
- -->
+ 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.
+-->
 <!-- $Id$ -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
-    <modelVersion>4.0.0</modelVersion>
-    <packaging>jar</packaging>
+  <modelVersion>4.0.0</modelVersion>
+  <packaging>jar</packaging>
 
-    <parent>
-        <groupId>org.apache.cocoon.parent</groupId>
-        <artifactId>cocoon-parent</artifactId>
-        <version>3.0.0-beta-1-SNAPSHOT</version>
-        <relativePath>../parent/pom.xml</relativePath>
-    </parent>
-
-    <groupId>org.apache.cocoon.stringtemplate</groupId>
-    <artifactId>cocoon-stringtemplate</artifactId>
+  <parent>
+    <groupId>org.apache.cocoon.parent</groupId>
+    <artifactId>cocoon-parent</artifactId>
     <version>3.0.0-beta-1-SNAPSHOT</version>
+    <relativePath>../parent/pom.xml</relativePath>
+  </parent>
+
+  <groupId>org.apache.cocoon.stringtemplate</groupId>
+  <artifactId>cocoon-stringtemplate</artifactId>
+  <version>3.0.0-beta-1-SNAPSHOT</version>
   
-    <name>Apache Cocoon 3: String Templates</name>
-    <description>String-Template support for Cocoon 3.</description>
+  <name>Apache Cocoon 3: String Templates</name>
+  <description>String-Template support for Cocoon 3.</description>
 
-    <dependencies>
-        <!-- Cocoon dependencies -->
-        <dependency>
-            <groupId>org.apache.cocoon.sax</groupId>
-            <artifactId>cocoon-sax</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cocoon.pipeline</groupId>
-            <artifactId>cocoon-pipeline</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cocoon.servlet</groupId>
-            <artifactId>cocoon-servlet</artifactId>
-            <optional>true</optional>
-        </dependency>
-
-        <!-- Other dependencies -->    
-        <dependency>
-            <groupId>org.antlr</groupId>
-            <artifactId>ST4</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-        </dependency>
+  <dependencies>
+    <!-- Cocoon dependencies -->
+    <dependency>
+      <groupId>org.apache.cocoon.sax</groupId>
+      <artifactId>cocoon-sax</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cocoon.pipeline</groupId>
+      <artifactId>cocoon-pipeline</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cocoon.servlet</groupId>
+      <artifactId>cocoon-servlet</artifactId>
+      <optional>true</optional>
+    </dependency>
+
+    <!-- Other dependencies -->    
+    <dependency>
+      <groupId>org.antlr</groupId>
+      <artifactId>ST4</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+    </dependency>
         
-        <!-- Logging -->
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-        </dependency>
+    <!-- Logging -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-classic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>jcl-over-slf4j</artifactId>
+    </dependency>
      
-        <!-- Test dependencies -->     
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>xmlunit</groupId>
-            <artifactId>xmlunit</artifactId>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
+    <!-- Test dependencies -->     
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>xmlunit</groupId>
+      <artifactId>xmlunit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
 </project>

Modified: cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/STRenderer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/STRenderer.java?rev=1450217&r1=1450216&r2=1450217&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/STRenderer.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/STRenderer.java
Tue Feb 26 15:31:18 2013
@@ -17,7 +17,10 @@
 package org.apache.cocoon.stringtemplate;
 
 import java.io.IOException;
+import java.io.PrintStream;
 import java.util.Map;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.commons.lang3.StringEscapeUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -58,8 +61,18 @@ public final class STRenderer {
                         ? StringEscapeUtils.escapeXml(entry.getValue().toString())
                         : entry.getValue());
 
-                LOG.debug("Passing pipeline parameter as attribute: key={}, value={}",
-                        entry.getKey(), entry.getValue());
+                if (LOG.isDebugEnabled()) {
+                    final String value;
+                    if (entry.getValue() instanceof Map) {
+                        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                        MapUtils.verbosePrint(new PrintStream(baos), null, parameters);
+                        baos.flush();
+                        value = baos.toString();
+                    } else {
+                        value = entry.getValue().toString();
+                    }
+                    LOG.debug("Passing parameter as ST attribute: key={}, value={}", entry.getKey(),
value);
+                }
             }
         }
 

Modified: cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateGenerator.java?rev=1450217&r1=1450216&r2=1450217&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateGenerator.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateGenerator.java
Tue Feb 26 15:31:18 2013
@@ -172,6 +172,7 @@ public class StringTemplateGenerator ext
      * @see org.apache.cocoon.pipeline.component.AbstractSAXProducer#setConfiguration(java.util.Map)
      */
     @Override
+    @SuppressWarnings("unchecked")
     public void setConfiguration(final Map<String, ? extends Object> parameters) {
         this.url = (URL) parameters.get("source");
         this.setup((Map<String, Object>) parameters);

Modified: cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateReader.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateReader.java?rev=1450217&r1=1450216&r2=1450217&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateReader.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateReader.java
Tue Feb 26 15:31:18 2013
@@ -33,10 +33,7 @@ import org.apache.cocoon.pipeline.compon
 import org.apache.cocoon.pipeline.component.Finisher;
 import org.apache.cocoon.pipeline.component.Starter;
 import org.apache.cocoon.pipeline.util.URLConnectionUtils;
-import org.apache.cocoon.servlet.controller.ControllerContextHelper;
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringEscapeUtils;
-import org.stringtemplate.v4.ST;
 
 public class StringTemplateReader extends AbstractPipelineComponent
         implements CachingPipelineComponent, Starter, Finisher {
@@ -88,26 +85,17 @@ public class StringTemplateReader extend
             throw new IllegalArgumentException(this.getClass().getSimpleName() + " has no
source.");
         }
 
+        InputStream inputStream = null;
         try {
-            final InputStream inputStream = this.source.openStream();
+            inputStream = this.source.openStream();
 
-            try {
-                final ST stringTemplate = new ST(IOUtils.toString(inputStream, "UTF-8"),
'$', '$');
-
-                final Map<String, Object> controllerContext = ControllerContextHelper.getContext(this.parameters);
-                for (Map.Entry<String, Object> eachEntry : controllerContext.entrySet())
{
-                    stringTemplate.add(eachEntry.getKey(),
-                            StringEscapeUtils.escapeXml(eachEntry.getValue().toString()));
-                }
-
-                final OutputStreamWriter writer = new OutputStreamWriter(this.outputStream);
-                writer.write(stringTemplate.render());
-                writer.flush();
-            } finally {
-                IOUtils.closeQuietly(inputStream);
-            }
+            final OutputStreamWriter writer = new OutputStreamWriter(this.outputStream);
+            writer.write(STRenderer.getInstance().render(IOUtils.toString(inputStream, "UTF-8"),
parameters));
+            writer.flush();
         } catch (IOException e) {
             throw new ProcessingException("Failed to produce result.", e);
+        } finally {
+            IOUtils.closeQuietly(inputStream);
         }
     }
 

Modified: cocoon/cocoon3/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/parent/pom.xml?rev=1450217&r1=1450216&r2=1450217&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/parent/pom.xml (original)
+++ cocoon/cocoon3/trunk/parent/pom.xml Tue Feb 26 15:31:18 2013
@@ -355,6 +355,11 @@
         <version>3.1</version>
       </dependency>
       <dependency>
+        <groupId>commons-collections</groupId>
+        <artifactId>commons-collections</artifactId>
+        <version>3.2.1</version>
+      </dependency>
+      <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>servlet-api</artifactId>
         <version>2.5</version>



Mime
View raw message