Gents,
Cocoon 3 is using Cocoon Spring Configurator 2.1[1]; by default this is
triggered by an empty
<configurator:settings/>
in main applicationContext.xml.
In my project I need to:
1. always reload sitemap.xmap from the filesystem during development
2. catch the real cause of a ProcessingException (I was inspired by [2])
Hence I set something like as
<configurator:settings>
<configurator:property name="org.apache.cocoon.reloading.sitemap"
value="true"/>
<configurator:property
name="org.apache.cocoon.exception.ProcessingException.unroll" value="true"/>
</configurator:settings>
Then, I modified [3] and [4] in order to handle this kind of
configuration: the patch is attached to this e-mail.
Do you think this could be useful in general? If so I would commit gladly.
Cheers.
[1]
http://cocoon.apache.org/subprojects/configuration/1.0/spring-configurator/2.1/1304_1_1.html
[2] http://cocoon.apache.org/2.2/core-modules/core/2.2/1379_1_1.html
[3]
cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java
[4]
cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java
--
Francesco Chicchiriccò
Apache Cocoon Committer and PMC Member
http://people.apache.org/~ilgrosso/
Index: cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java
===================================================================
--- cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java (revisione 1140447)
+++ cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java (copia locale)
@@ -27,6 +27,7 @@
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.cocoon.configuration.Settings;
import org.apache.cocoon.pipeline.Pipeline;
import org.apache.cocoon.pipeline.component.Finisher;
@@ -38,6 +39,7 @@
import org.apache.cocoon.sitemap.util.ParameterHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
public class InvocationImpl implements Invocation {
@@ -62,6 +64,9 @@
private ObjectModel objectModel;
private boolean hasFinisher;
+
+ @Autowired
+ private Settings settings;
public InvocationImpl() {
}
@@ -319,7 +324,17 @@
*/
public void setThrowable(final Throwable throwable) {
Throwable cause = ExceptionHandler.getCause(throwable);
-
+ if (null != cause) {
+ final String unroll =
+ settings.getProperty("org.apache.cocoon.exception."
+ + cause.getClass().getSimpleName() + ".unroll");
+ if (unroll != null && "true".equalsIgnoreCase(unroll)) {
+ while (cause.getCause() != null) {
+ cause = cause.getCause();
+ }
+ }
+ }
+
this.objectModel.getCocoonObject().put("exception", cause);
ParameterHelper.setThrowable(this.parameters, cause);
Index: cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java
===================================================================
--- cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java (revisione 1140447)
+++ cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java (copia locale)
@@ -24,6 +24,7 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.cocoon.configuration.Settings;
import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.commons.logging.Log;
@@ -57,7 +58,11 @@
throws ServletException {
synchronized (this) {
- if (this.requestProcessor != null) {
+ final Settings settings = (Settings) WebAppContextUtils.
+ getCurrentWebApplicationContext().getBean(
+ Settings.class.getName());
+ if (!settings.isReloadingEnabled("sitemap")
+ && this.requestProcessor != null) {
return;
}