Author: davsclaus Date: Wed Feb 4 14:30:26 2009 New Revision: 740757 URL: http://svn.apache.org/viewvc?rev=740757&view=rev Log: Merged revisions 740663 via svnmerge from https://svn.apache.org/repos/asf/camel/trunk
........ r740663 | davsclaus | 2009-02-04 10:19:19 +0100 (Wed, 04 Feb 2009) | 1 line MR-46: Expose the saxon configuration on the exchange to allow eg type converters to get access to this configuration. ........ Modified: camel/branches/camel-1.x/ (props changed) camel/branches/camel-1.x/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java Propchange: camel/branches/camel-1.x/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Feb 4 14:30:26 2009 @@ -1 +1 @@ -/camel/trunk:739733,739904,740251,740295,740306,740596 +/camel/trunk:739733,739904,740251,740295,740306,740596,740663 Propchange: camel/branches/camel-1.x/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: camel/branches/camel-1.x/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java?rev=740757&r1=740756&r2=740757&view=diff ============================================================================== --- camel/branches/camel-1.x/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java (original) +++ camel/branches/camel-1.x/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java Wed Feb 4 14:30:26 2009 @@ -64,9 +64,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - - - /** * Creates an XQuery builder * @@ -100,8 +97,6 @@ public Object evaluate(Exchange exchange) { try { - initialize(); - if (LOG.isDebugEnabled()) { LOG.debug("Evaluation " + expression + " for exchange: " + exchange); } @@ -114,7 +109,7 @@ } else if (resultType.isAssignableFrom(Node.class)) { return evaluateAsDOM(exchange); } else { - // TODO figure out how to convert to the given type + throw new IllegalArgumentException("ResultType: " + resultType.getCanonicalName() + " not supported"); } } switch (resultsFormat) { @@ -138,27 +133,27 @@ } public List evaluateAsList(Exchange exchange) throws Exception { - initialize(); + initialize(exchange); return getExpression().evaluate(createDynamicContext(exchange)); } public Object evaluateAsStringSource(Exchange exchange) throws Exception { - initialize(); + initialize(exchange); String text = evaluateAsString(exchange); return new StringSource(text); } public Object evaluateAsBytesSource(Exchange exchange) throws Exception { - initialize(); + initialize(exchange); byte[] bytes = evaluateAsBytes(exchange); return new BytesSource(bytes); } public Node evaluateAsDOM(Exchange exchange) throws Exception { - initialize(); + initialize(exchange); DOMResult result = new DOMResult(); DynamicQueryContext context = createDynamicContext(exchange); @@ -168,7 +163,7 @@ } public byte[] evaluateAsBytes(Exchange exchange) throws Exception { - initialize(); + initialize(exchange); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); Result result = new StreamResult(buffer); @@ -178,7 +173,7 @@ } public String evaluateAsString(Exchange exchange) throws Exception { - initialize(); + initialize(exchange); StringWriter buffer = new StringWriter(); SequenceIterator iter = getExpression().iterator(createDynamicContext(exchange)); @@ -443,7 +438,7 @@ /** * Initializes this builder - <b>Must be invoked before evaluation</b>. */ - protected synchronized void initialize() throws XPathException, IOException { + protected synchronized void initialize(Exchange exchange) throws XPathException, IOException { // must use synchronized for concurrency issues and only let it initialize once if (!initialized.get()) { if (LOG.isDebugEnabled()) { @@ -465,6 +460,10 @@ initialized.set(true); } + + // let the configuration be accessible on the exchange as its shared for this evaulation + // and can be needed for 3rd part type converters or in some other situations + exchange.setProperty("CamelSaxonConfiguration", configuration); } }