You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jo...@apache.org on 2008/04/02 05:45:02 UTC
svn commit: r643699 - in /cocoon/trunk:
blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/
blocks/cocoon-scratchpad/cocoon-scratchpad-impl/src/main/java/org/apache/cocoon/components/flow/java...
Author: joerg
Date: Tue Apr 1 20:44:59 2008
New Revision: 643699
URL: http://svn.apache.org/viewvc?rev=643699&view=rev
Log:
remove Log from WebContinuation, change display() to toString(), logging is done "externally"
Modified:
cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java
cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_WebContinuation.java
cocoon/trunk/blocks/cocoon-scratchpad/cocoon-scratchpad-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_Cocoon.java
cocoon/trunk/blocks/cocoon-scratchpad/cocoon-scratchpad-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_JavaScriptInterpreter.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-api/src/main/java/org/apache/cocoon/components/flow/WebContinuation.java
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java
Modified: cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java?rev=643699&r1=643698&r2=643699&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java (original)
+++ cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java Tue Apr 1 20:44:59 2008
@@ -32,15 +32,12 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.web.context.WebApplicationContext;
import org.apache.cocoon.components.ContextHelper;
import org.apache.cocoon.components.LifecycleHelper;
import org.apache.cocoon.components.flow.ContinuationsManager;
-import org.apache.cocoon.components.flow.Interpreter.Argument;
import org.apache.cocoon.components.flow.WebContinuation;
+import org.apache.cocoon.components.flow.Interpreter.Argument;
import org.apache.cocoon.configuration.Settings;
import org.apache.cocoon.core.container.spring.avalon.AvalonUtils;
import org.apache.cocoon.environment.ObjectModelHelper;
@@ -51,6 +48,9 @@
import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.cocoon.util.ClassUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.mozilla.javascript.JavaScriptException;
import org.mozilla.javascript.NativeJavaClass;
import org.mozilla.javascript.NativeJavaObject;
@@ -61,6 +61,8 @@
import org.mozilla.javascript.Wrapper;
import org.mozilla.javascript.continuations.Continuation;
+import org.springframework.web.context.WebApplicationContext;
+
/**
* Implementation of FOM (Flow Object Model).
*
@@ -99,6 +101,7 @@
this.lastContinuation = lastContinuation;
if (lastContinuation != null) {
fwk = new FOM_WebContinuation(lastContinuation);
+ fwk.setLogger(getLogger());
Scriptable scope = FOM_Cocoon.this.getParentScope();
fwk.setParentScope(scope);
fwk.setPrototype(getClassPrototype(scope, fwk.getClassName()));
@@ -687,7 +690,7 @@
return currentCall.avalonContext;
}
- private Log getLogger() {
+ protected Log getLogger() {
return logger;
}
@@ -751,14 +754,16 @@
/**
* Return this continuation if it is valid, or first valid parent
*/
- private FOM_WebContinuation findValidParent(FOM_WebContinuation wk) {
+ private FOM_WebContinuation findValidParent(final FOM_WebContinuation wk) {
if (wk != null) {
WebContinuation wc = wk.getWebContinuation();
while (wc != null && wc.disposed()) {
wc = wc.getParentContinuation();
}
if (wc != null) {
- return new FOM_WebContinuation(wc);
+ FOM_WebContinuation parentWk = new FOM_WebContinuation(wc);
+ parentWk.setLogger(getLogger());
+ return parentWk;
}
}
@@ -808,6 +813,7 @@
getInterpreter().getInterpreterID(),
null);
FOM_WebContinuation result = new FOM_WebContinuation(wk);
+ result.setLogger(getLogger());
result.setParentScope(getParentScope());
result.setPrototype(getClassPrototype(getParentScope(),
result.getClassName()));
Modified: cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java?rev=643699&r1=643698&r2=643699&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java (original)
+++ cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java Tue Apr 1 20:44:59 2008
@@ -27,17 +27,12 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+
import javax.servlet.http.HttpSession;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.commons.jxpath.JXPathIntrospector;
-import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl;
-import org.apache.excalibur.source.Source;
-import org.apache.regexp.RE;
-import org.apache.regexp.RECompiler;
-import org.apache.regexp.REProgram;
import org.apache.cocoon.ResourceNotFoundException;
import org.apache.cocoon.components.flow.CompilingInterpreter;
@@ -53,6 +48,15 @@
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
+import org.apache.commons.jxpath.JXPathIntrospector;
+import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl;
+
+import org.apache.excalibur.source.Source;
+
+import org.apache.regexp.RE;
+import org.apache.regexp.RECompiler;
+import org.apache.regexp.REProgram;
+
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.EcmaError;
@@ -690,6 +694,7 @@
}
cocoon.setParameters(parameters);
FOM_WebContinuation fom_wk = new FOM_WebContinuation(wk);
+ fom_wk.setLogger(getLogger());
fom_wk.setParentScope(kScope);
fom_wk.setPrototype(ScriptableObject.getClassPrototype(kScope,
fom_wk.getClassName()));
Modified: cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_WebContinuation.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_WebContinuation.java?rev=643699&r1=643698&r2=643699&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_WebContinuation.java (original)
+++ cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_WebContinuation.java Tue Apr 1 20:44:59 2008
@@ -21,6 +21,7 @@
import org.apache.cocoon.components.flow.ContinuationsManager;
import org.apache.cocoon.components.flow.WebContinuation;
+import org.apache.commons.logging.Log;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.NativeArray;
@@ -38,6 +39,7 @@
WebContinuation wk;
+ private Log logger;
static class UserObject {
boolean isBookmark;
@@ -58,6 +60,10 @@
this.wk = wk;
}
+ public void setLogger(Log logger) {
+ this.logger = logger;
+ }
+
// new FOM_WebContinuation([Continuation] continuation,
// [FOM_WebContinuation] parent,
// [Number] timeToLive)
@@ -91,6 +97,7 @@
FOM_WebContinuation result;
result = new FOM_WebContinuation(wk);
+ result.setLogger(cocoon.getLogger());
result.setParentScope(getTopLevelScope(scope));
result.setPrototype(getClassPrototype(scope, result.getClassName()));
return result;
@@ -136,6 +143,7 @@
}
FOM_WebContinuation pwk = new FOM_WebContinuation(parent);
+ pwk.setLogger(logger);
pwk.setParentScope(getParentScope());
pwk.setPrototype(getClassPrototype(getParentScope(),
pwk.getClassName()));
@@ -152,6 +160,7 @@
for (int i = 0; iter.hasNext(); i++) {
WebContinuation child = (WebContinuation)iter.next();
FOM_WebContinuation cwk = new FOM_WebContinuation(child);
+ cwk.setLogger(logger);
cwk.setParentScope(getParentScope());
cwk.setPrototype(getClassPrototype(getParentScope(),
cwk.getClassName()));
@@ -168,7 +177,9 @@
}
public void jsFunction_display() {
- wk.display();
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug(wk.toString());
+ }
}
public WebContinuation getWebContinuation() {
@@ -236,6 +247,7 @@
}
FOM_WebContinuation pwk = new FOM_WebContinuation(c);
+ pwk.setLogger(logger);
pwk.setParentScope(getParentScope());
pwk.setPrototype(getClassPrototype(getParentScope(), pwk.getClassName()));
return pwk;
@@ -247,4 +259,5 @@
public String toString() {
return "WC" + wk.getId();
}
+
}
Modified: cocoon/trunk/blocks/cocoon-scratchpad/cocoon-scratchpad-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_Cocoon.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-scratchpad/cocoon-scratchpad-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_Cocoon.java?rev=643699&r1=643698&r2=643699&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-scratchpad/cocoon-scratchpad-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_Cocoon.java (original)
+++ cocoon/trunk/blocks/cocoon-scratchpad/cocoon-scratchpad-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_Cocoon.java Tue Apr 1 20:44:59 2008
@@ -28,13 +28,11 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.cocoon.components.ContextHelper;
import org.apache.cocoon.components.flow.ContinuationsManager;
-import org.apache.cocoon.components.flow.Interpreter.Argument;
import org.apache.cocoon.components.flow.WebContinuation;
+import org.apache.cocoon.components.flow.Interpreter.Argument;
import org.apache.cocoon.environment.Cookie;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
@@ -42,6 +40,9 @@
import org.apache.cocoon.environment.Response;
import org.apache.cocoon.environment.Session;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.mozilla.javascript.JavaScriptException;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.Scriptable;
@@ -132,6 +133,7 @@
FOM_WebContinuation fom_wk =
new FOM_WebContinuation(wk);
+ fom_wk.setLogger(logger);
fom_wk.setParentScope(getParentScope());
fom_wk.setPrototype(getClassPrototype(getParentScope(),
fom_wk.getClassName()));
@@ -141,6 +143,7 @@
FOM_WebContinuation result = null;
if (wk != null) {
result = new FOM_WebContinuation(wk);
+ result.setLogger(logger);
result.setParentScope(getParentScope());
result.setPrototype(getClassPrototype(getParentScope(),
result.getClassName()));
@@ -930,6 +933,7 @@
interpreter.getInterpreterID(),
null);
FOM_WebContinuation result = new FOM_WebContinuation(wk);
+ result.setLogger(logger);
result.setParentScope(getParentScope());
result.setPrototype(getClassPrototype(getParentScope(),
result.getClassName()));
Modified: cocoon/trunk/blocks/cocoon-scratchpad/cocoon-scratchpad-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_JavaScriptInterpreter.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-scratchpad/cocoon-scratchpad-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_JavaScriptInterpreter.java?rev=643699&r1=643698&r2=643699&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-scratchpad/cocoon-scratchpad-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_JavaScriptInterpreter.java (original)
+++ cocoon/trunk/blocks/cocoon-scratchpad/cocoon-scratchpad-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_JavaScriptInterpreter.java Tue Apr 1 20:44:59 2008
@@ -25,6 +25,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import javax.servlet.http.HttpSession;
import org.apache.avalon.framework.CascadingRuntimeException;
@@ -35,10 +36,6 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
-import org.apache.commons.jxpath.JXPathIntrospector;
-import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.ResourceNotFoundException;
@@ -55,6 +52,12 @@
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
+import org.apache.commons.jxpath.JXPathIntrospector;
+import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl;
+
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+
import org.mozilla.javascript.Context;
import org.mozilla.javascript.EcmaError;
import org.mozilla.javascript.EvaluatorException;
@@ -685,6 +688,7 @@
cocoon.setParameters(parameters);
FOM_WebContinuation fom_wk =
new FOM_WebContinuation(wk);
+ fom_wk.setLogger(getLogger());
fom_wk.setParentScope(kScope);
fom_wk.setPrototype(ScriptableObject.getClassPrototype(kScope,
fom_wk.getClassName()));
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-api/src/main/java/org/apache/cocoon/components/flow/WebContinuation.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-api/src/main/java/org/apache/cocoon/components/flow/WebContinuation.java?rev=643699&r1=643698&r2=643699&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-api/src/main/java/org/apache/cocoon/components/flow/WebContinuation.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-api/src/main/java/org/apache/cocoon/components/flow/WebContinuation.java Tue Apr 1 20:44:59 2008
@@ -25,7 +25,6 @@
import org.apache.commons.collections.iterators.IteratorEnumeration;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
/**
* Representation of continuations in a Web environment.
@@ -45,15 +44,6 @@
public class WebContinuation implements Comparable {
/**
- * Logger to be used in {@link #display()}.
- *
- * <p>Not using here <code>org.apache.cocoon.util.AbstractLogEnabled</code>
- * because there is no dependency on cocoon-util, and want to avoid
- * calling LogFactory for each continuation.
- */
- private Log logger;
-
- /**
* The continuation this object represents.
*/
protected Object continuation;
@@ -151,14 +141,6 @@
}
}
- public final Log getLogger() {
- return this.logger;
- }
-
- public void setLogger(Log logger) {
- this.logger = logger;
- }
-
/**
* Get an attribute of this continuation
*
@@ -371,56 +353,6 @@
}
/**
- * Debugging method.
- *
- * <p>Assumes the receiving instance as the root of a tree and
- * displays the tree of continuations.
- */
- public void display() {
- getLogger().debug("\nWK: Tree" + display(0));
- }
-
- /**
- * Debugging method.
- *
- * <p>Displays the receiving instance as if it is at the
- * <code>indent</code> depth in the tree of continuations. Each
- * level is indented 2 spaces.
- *
- * @param depth an <code>int</code> value
- */
- protected String display(int depth) {
- StringBuffer tree = new StringBuffer("\n");
- for (int i = 0; i < depth; i++) {
- tree.append(" ");
- }
-
- tree.append("WK: WebContinuation ")
- .append(id)
- .append(" ExpireTime [");
-
- if ((lastAccessTime + timeToLive) < System.currentTimeMillis()) {
- tree.append("Expired");
- } else {
- tree.append(lastAccessTime + timeToLive);
- }
-
- tree.append("]");
-
- // REVISIT: is this needed for some reason?
- // System.out.print(spaces); System.out.println("WebContinuation " + id);
-
- int size = children.size();
- depth++;
-
- for (int i = 0; i < size; i++) {
- tree.append(((WebContinuation) children.get(i)).display(depth));
- }
-
- return tree.toString();
- }
-
- /**
* Update the continuation in the
*/
protected void updateLastAccessTime() {
@@ -467,4 +399,55 @@
getParentContinuation().getChildren().remove(this);
}
}
+
+ /**
+ * Debugging method.
+ *
+ * <p>Assumes the receiving instance as the root of a tree and
+ * displays the tree of continuations.
+ */
+ public String toString() {
+ return "\nWK: Tree" + display(0);
+ }
+
+ /**
+ * Debugging method.
+ *
+ * <p>Displays the receiving instance as if it is at the
+ * <code>indent</code> depth in the tree of continuations. Each
+ * level is indented 2 spaces.
+ *
+ * @param depth an <code>int</code> value
+ */
+ protected String display(int depth) {
+ StringBuffer tree = new StringBuffer("\n");
+ for (int i = 0; i < depth; i++) {
+ tree.append(" ");
+ }
+
+ tree.append("WK: WebContinuation ")
+ .append(id)
+ .append(" ExpireTime [");
+
+ if (hasExpired()) {
+ tree.append("Expired");
+ } else {
+ tree.append(lastAccessTime + timeToLive);
+ }
+
+ tree.append("]");
+
+ // REVISIT: is this needed for some reason?
+ // System.out.print(spaces); System.out.println("WebContinuation " + id);
+
+ int size = children.size();
+ depth++;
+
+ for (int i = 0; i < size; i++) {
+ tree.append(((WebContinuation) children.get(i)).display(depth));
+ }
+
+ return tree.toString();
+ }
+
}
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java?rev=643699&r1=643698&r2=643699&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java Tue Apr 1 20:44:59 2008
@@ -310,7 +310,6 @@
}
}
- wk.setLogger(getLogger());
return wk;
}
@@ -431,7 +430,7 @@
synchronized (this) {
final Iterator i = forest.iterator();
while (i.hasNext()) {
- ((WebContinuation) i.next()).display();
+ getLogger().debug(i.next().toString());
}
}
}