coliver 2003/04/05 21:00:14
Modified: src/scratchpad/src/org/apache/cocoon/transformation JXPathTransformer.java Log: Workaround for severe performance bug in JXPathContext.newContext(): which causes file system reads on every call (I've reported this to Dmitri) Revision Changes Path 1.5 +7 -2 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/transformation/JXPathTransformer.java Index: JXPathTransformer.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/transformation/JXPathTransformer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JXPathTransformer.java 6 Apr 2003 04:50:48 -0000 1.4 +++ JXPathTransformer.java 6 Apr 2003 05:00:13 -0000 1.5 @@ -68,6 +68,7 @@ import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.generation.Generator; import org.apache.commons.jxpath.JXPathContext; +import org.apache.commons.jxpath.JXPathContextFactory; import org.apache.commons.jxpath.Pointer; import org.apache.commons.jxpath.Variables; import org.apache.excalibur.source.Source; @@ -94,6 +95,9 @@ public class JXPathTransformer extends AbstractSAXTransformer implements Initializable, Generator { + private static final JXPathContextFactory + jxpathContextFactory = JXPathContextFactory.newInstance(); + public static final String JXPATH_NAMESPACE_URI = "http://cocoon.apache.org/transformation/jxpath/1.0"; public static final String JXPATH_FOR_EACH = "for-each"; @@ -421,8 +425,8 @@ } private void pushContext(Object contextObject) { - JXPathContext ctx; - contextStack.push(ctx = JXPathContext.newContext(contextObject)); + JXPathContext ctx = + jxpathContextFactory.newContext(null, contextObject); // Make web continuation available as an XPath variable // you would typically access its id: // @@ -451,6 +455,7 @@ public void undeclareVariable(String varName) { } }); + contextStack.push(ctx); } private void popContext() {