This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1dec2f65fb961412841921021d8d7289f4039adf Author: Claus Ibsen <[email protected]> AuthorDate: Wed May 11 14:23:19 2022 +0200 CAMEL-18087: camel-core - Enable stream caching by default. (#7586) --- .../xmlsecurity/XMLSecurityDataFormat.java | 7 + .../camel/dataformat/xmlsecurity/TestHelper.java | 11 +- .../jaxp/CamelXmlJaxpBulkConverterLoader.java | 20 ++- .../apache/camel/converter/jaxp/XmlConverter.java | 146 +++++++++++---------- 4 files changed, 105 insertions(+), 79 deletions(-) diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java index 18e1539dd00..c20678bfe53 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java @@ -40,6 +40,7 @@ import javax.crypto.spec.DESedeKeySpec; import javax.crypto.spec.SecretKeySpec; import javax.xml.transform.dom.DOMSource; +import org.apache.camel.StreamCache; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -457,6 +458,12 @@ public class XMLSecurityDataFormat extends ServiceSupport implements DataFormat, public Object unmarshal(Exchange exchange, InputStream stream) throws Exception { Document encodedDocument = exchange.getContext().getTypeConverter().convertTo(Document.class, exchange, stream); + // we may access the message body on the exchange again when decoding, so we need to reset stream cache + Object body = exchange.getMessage().getBody(); + if (body instanceof StreamCache) { + ((StreamCache) body).reset(); + } + if (null != keyCipherAlgorithm && (keyCipherAlgorithm.equals(XMLCipher.RSA_v1dot5) || keyCipherAlgorithm.equals(XMLCipher.RSA_OAEP) || keyCipherAlgorithm.equals(XMLCipher.RSA_OAEP_11))) { diff --git a/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java b/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java index 83e2503d9b8..abc3089b9ba 100644 --- a/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java +++ b/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java @@ -23,6 +23,7 @@ import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; +import org.apache.camel.StreamCache; import org.w3c.dom.Document; import org.w3c.dom.NodeList; @@ -196,12 +197,16 @@ public class TestHelper { } private Document getDocumentForInMessage(Exchange exchange) { - byte[] body = exchange.getIn().getBody(byte[].class); - Document d = createDocumentfromInputStream(new ByteArrayInputStream(body), exchange.getContext()); + Object body = exchange.getIn().getBody(); + if (body instanceof StreamCache) { + ((StreamCache) body).reset(); + } + byte[] arr = exchange.getIn().getBody(byte[].class); + Document d = createDocumentFromInputStream(new ByteArrayInputStream(arr), exchange.getContext()); return d; } - private Document createDocumentfromInputStream(InputStream is, CamelContext context) { + private Document createDocumentFromInputStream(InputStream is, CamelContext context) { return context.getTypeConverter().convertTo(Document.class, is); } diff --git a/core/camel-xml-jaxp/src/generated/java/org/apache/camel/converter/jaxp/CamelXmlJaxpBulkConverterLoader.java b/core/camel-xml-jaxp/src/generated/java/org/apache/camel/converter/jaxp/CamelXmlJaxpBulkConverterLoader.java index 16d305f247e..1847e3f38c5 100644 --- a/core/camel-xml-jaxp/src/generated/java/org/apache/camel/converter/jaxp/CamelXmlJaxpBulkConverterLoader.java +++ b/core/camel-xml-jaxp/src/generated/java/org/apache/camel/converter/jaxp/CamelXmlJaxpBulkConverterLoader.java @@ -37,7 +37,7 @@ public final class CamelXmlJaxpBulkConverterLoader implements TypeConverterLoade @Override public int size() { - return 94; + return 95; } @Override @@ -207,6 +207,9 @@ public final class CamelXmlJaxpBulkConverterLoader implements TypeConverterLoade if (value instanceof byte[]) { return getXmlConverter().toDOMSource((byte[]) value); } + if (value instanceof org.apache.camel.StreamCache) { + return getXmlConverter().toDOMSource((org.apache.camel.StreamCache) value, exchange); + } if (value instanceof java.io.InputStream) { return getXmlConverter().toDOMSource((java.io.InputStream) value, exchange); } @@ -319,6 +322,9 @@ public final class CamelXmlJaxpBulkConverterLoader implements TypeConverterLoade if (value instanceof byte[]) { return getXmlConverter().toDOMDocument((byte[]) value, exchange); } + if (value instanceof org.apache.camel.StreamCache) { + return getXmlConverter().toDOMDocument((org.apache.camel.StreamCache) value, exchange); + } if (value instanceof java.io.InputStream) { return getXmlConverter().toDOMDocument((java.io.InputStream) value, exchange); } @@ -345,9 +351,6 @@ public final class CamelXmlJaxpBulkConverterLoader implements TypeConverterLoade return obj; } } - if (value instanceof org.apache.camel.StreamCache) { - return getXmlConverter().toDOMDocument((org.apache.camel.StreamCache) value, exchange); - } } else if (to == org.w3c.dom.Element.class) { if (value instanceof javax.xml.transform.Source) { return getXmlConverter().toDOMElement((javax.xml.transform.Source) value); @@ -535,6 +538,9 @@ public final class CamelXmlJaxpBulkConverterLoader implements TypeConverterLoade if (from == byte[].class) { return this; } + if (from == org.apache.camel.StreamCache.class) { + return this; + } if (from == java.io.InputStream.class) { return this; } @@ -647,6 +653,9 @@ public final class CamelXmlJaxpBulkConverterLoader implements TypeConverterLoade if (from == byte[].class) { return this; } + if (from == org.apache.camel.StreamCache.class) { + return this; + } if (from == java.io.InputStream.class) { return this; } @@ -668,9 +677,6 @@ public final class CamelXmlJaxpBulkConverterLoader implements TypeConverterLoade if (from == org.w3c.dom.NodeList.class) { return this; } - if (from == org.apache.camel.StreamCache.class) { - return this; - } } else if (to == org.w3c.dom.Element.class) { if (from == javax.xml.transform.Source.class) { return this; diff --git a/core/camel-xml-jaxp/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java b/core/camel-xml-jaxp/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java index 6fd77812f48..80f022d46c4 100644 --- a/core/camel-xml-jaxp/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java +++ b/core/camel-xml-jaxp/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java @@ -56,7 +56,6 @@ import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -import org.apache.camel.StreamCache; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -70,6 +69,7 @@ import org.xml.sax.XMLReader; import org.apache.camel.Converter; import org.apache.camel.Exchange; +import org.apache.camel.StreamCache; import org.apache.camel.support.CamelContextHelper; import org.apache.camel.support.builder.xml.StAX2SAXSource; import org.apache.camel.util.IOHelper; @@ -216,10 +216,16 @@ public class XmlConverter { return new DOMSource(document); } + @Converter(order = 10) + public Source toSource(StreamCache cache, Exchange exchange) { + byte[] arr = exchange.getContext().getTypeConverter().convertTo(byte[].class, exchange, cache); + return toSource(arr); + } + /** * Converts the given input Source into text */ - @Converter(order = 10) + @Converter(order = 11) public String toString(Source source, Exchange exchange) throws TransformerException { if (source == null) { return null; @@ -247,7 +253,7 @@ public class XmlConverter { /** * Converts the given input Source into bytes */ - @Converter(order = 11) + @Converter(order = 12) public byte[] toByteArray(Source source, Exchange exchange) throws TransformerException { if (source instanceof BytesSource) { return ((BytesSource) source).getData(); @@ -272,7 +278,7 @@ public class XmlConverter { * Converts the source instance to a {@link DOMSource} or returns null if the conversion is not supported (making it * easy to derive from this class to add new kinds of conversion). */ - @Converter(order = 12) + @Converter(order = 13) public DOMSource toDOMSource(String text) throws ParserConfigurationException, IOException, SAXException, TransformerException { Source source = toSource(text); @@ -283,7 +289,7 @@ public class XmlConverter { * Converts the source instance to a {@link DOMSource} or returns null if the conversion is not supported (making it * easy to derive from this class to add new kinds of conversion). */ - @Converter(order = 13) + @Converter(order = 14) public DOMSource toDOMSource(byte[] bytes) throws IOException, SAXException, ParserConfigurationException { InputStream is = new ByteArrayInputStream(bytes); try { @@ -297,7 +303,7 @@ public class XmlConverter { * Converts the source instance to a {@link SAXSource} or returns null if the conversion is not supported (making it * easy to derive from this class to add new kinds of conversion). */ - @Converter(order = 14) + @Converter(order = 15) public SAXSource toSAXSource(String source, Exchange exchange) throws IOException, SAXException, TransformerException { return toSAXSource(toSource(source), exchange); } @@ -306,7 +312,7 @@ public class XmlConverter { * Converts the source instance to a {@link StAXSource} or returns null if the conversion is not supported (making * it easy to derive from this class to add new kinds of conversion). */ - @Converter(order = 15) + @Converter(order = 16) public StAXSource toStAXSource(String source, Exchange exchange) throws XMLStreamException { XMLStreamReader r = new StaxConverter().createXMLStreamReader(new StringReader(source)); return new StAXSource(r); @@ -316,7 +322,7 @@ public class XmlConverter { * Converts the source instance to a {@link StAXSource} or returns null if the conversion is not supported (making * it easy to derive from this class to add new kinds of conversion). */ - @Converter(order = 16) + @Converter(order = 17) public StAXSource toStAXSource(byte[] in, Exchange exchange) throws XMLStreamException { XMLStreamReader r = new StaxConverter().createXMLStreamReader(new ByteArrayInputStream(in), exchange); return new StAXSource(r); @@ -326,7 +332,7 @@ public class XmlConverter { * Converts the source instance to a {@link SAXSource} or returns null if the conversion is not supported (making it * easy to derive from this class to add new kinds of conversion). */ - @Converter(order = 17) + @Converter(order = 18) public SAXSource toSAXSource(InputStream source, Exchange exchange) throws IOException, SAXException, TransformerException { return toSAXSource(toStreamSource(source), exchange); } @@ -335,7 +341,7 @@ public class XmlConverter { * Converts the source instance to a {@link SAXSource} or returns null if the conversion is not supported (making it * easy to derive from this class to add new kinds of conversion). */ - @Converter(order = 18) + @Converter(order = 19) public SAXSource toSAXSource(byte[] in, Exchange exchange) throws IOException, SAXException, TransformerException { return toSAXSource(toStreamSource(in, exchange), exchange); } @@ -344,7 +350,7 @@ public class XmlConverter { * Converts the source instance to a {@link StAXSource} or returns null if the conversion is not supported (making * it easy to derive from this class to add new kinds of conversion). */ - @Converter(order = 19) + @Converter(order = 20) public StAXSource toStAXSource(InputStream source, Exchange exchange) throws XMLStreamException { XMLStreamReader r = new StaxConverter().createXMLStreamReader(source, exchange); return new StAXSource(r); @@ -354,7 +360,7 @@ public class XmlConverter { * Converts the source instance to a {@link SAXSource} or returns null if the conversion is not supported (making it * easy to derive from this class to add new kinds of conversion). */ - @Converter(order = 20) + @Converter(order = 21) public SAXSource toSAXSource(File file, Exchange exchange) throws IOException, SAXException, TransformerException { InputStream is = IOHelper.buffered(new FileInputStream(file)); return toSAXSource(is, exchange); @@ -364,46 +370,46 @@ public class XmlConverter { * Converts the source instance to a {@link StAXSource} or returns null if the conversion is not supported (making * it easy to derive from this class to add new kinds of conversion). */ - @Converter(order = 21) + @Converter(order = 22) public StAXSource toStAXSource(File file, Exchange exchange) throws FileNotFoundException, XMLStreamException { InputStream is = IOHelper.buffered(new FileInputStream(file)); XMLStreamReader r = new StaxConverter().createXMLStreamReader(is, exchange); return new StAXSource(r); } - @Converter(order = 22) + @Converter(order = 23) public StreamSource toStreamSource(String in) { return new StreamSource(new ByteArrayInputStream(in.getBytes())); } - @Converter(order = 23) + @Converter(order = 24) public StreamSource toStreamSource(InputStream in) { return new StreamSource(in); } - @Converter(order = 24) + @Converter(order = 25) public StreamSource toStreamSource(Reader in) { return new StreamSource(in); } - @Converter(order = 25) + @Converter(order = 26) public StreamSource toStreamSource(File in) { return new StreamSource(in); } - @Converter(order = 26) + @Converter(order = 27) public StreamSource toStreamSource(byte[] in, Exchange exchange) throws TransformerException { InputStream is = exchange.getContext().getTypeConverter().convertTo(InputStream.class, exchange, in); return new StreamSource(is); } - @Converter(order = 27) + @Converter(order = 28) public StreamSource toStreamSource(ByteBuffer in, Exchange exchange) throws TransformerException { InputStream is = exchange.getContext().getTypeConverter().convertTo(InputStream.class, exchange, in); return new StreamSource(is); } - @Converter(order = 28) + @Converter(order = 29) public StreamSource toStreamSourceFromSAX(SAXSource source, Exchange exchange) throws TransformerException { InputSource inputSource = source.getInputSource(); if (inputSource != null) { @@ -418,19 +424,19 @@ public class XmlConverter { return new StringSource(result); } - @Converter(order = 29) + @Converter(order = 30) public StreamSource toStreamSourceFromDOM(DOMSource source, Exchange exchange) throws TransformerException { String result = toString(source, exchange); return new StringSource(result); } - @Converter(order = 30) + @Converter(order = 31) public StreamSource toStreamSourceFromStAX(StAXSource source, Exchange exchange) throws TransformerException { String result = toString(source, exchange); return new StringSource(result); } - @Converter(order = 31) + @Converter(order = 32) public SAXSource toSAXSourceFromStream(StreamSource source, Exchange exchange) throws SAXException { InputSource inputSource; if (source.getReader() != null) { @@ -465,7 +471,7 @@ public class XmlConverter { return new SAXSource(xmlReader, inputSource); } - @Converter(order = 32) + @Converter(order = 33) public Reader toReader(StreamSource source) { Reader r = source.getReader(); if (r == null) { @@ -474,7 +480,7 @@ public class XmlConverter { return r; } - @Converter(order = 33) + @Converter(order = 34) public Reader toReaderFromSource(Source src, Exchange exchange) throws TransformerException { StreamSource stSrc = toStreamSource(src, exchange); Reader r = stSrc.getReader(); @@ -484,7 +490,15 @@ public class XmlConverter { return r; } - @Converter(order = 34) + @Converter(order = 35) + public DOMSource toDOMSource(StreamCache cache, Exchange exchange) + throws ParserConfigurationException, IOException, SAXException { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + cache.writeTo(bos); + return toDOMSource(new ByteArrayInputStream(bos.toByteArray()), exchange); + } + + @Converter(order = 36) public DOMSource toDOMSource(InputStream is, Exchange exchange) throws ParserConfigurationException, IOException, SAXException { InputSource source = new InputSource(is); @@ -494,13 +508,13 @@ public class XmlConverter { return new DOMSource(document, systemId); } - @Converter(order = 35) + @Converter(order = 37) public DOMSource toDOMSource(File file, Exchange exchange) throws ParserConfigurationException, IOException, SAXException { InputStream is = IOHelper.buffered(new FileInputStream(file)); return toDOMSource(is, exchange); } - @Converter(order = 36) + @Converter(order = 38) public DOMSource toDOMSourceFromStream(StreamSource source, Exchange exchange) throws ParserConfigurationException, IOException, SAXException { Document document; @@ -523,33 +537,33 @@ public class XmlConverter { return new DOMSource(document, systemId); } - @Converter(order = 37) + @Converter(order = 39) public SAXSource toSAXSourceFromDOM(DOMSource source, Exchange exchange) throws TransformerException { String str = toString(source, exchange); StringReader reader = new StringReader(str); return new SAXSource(new InputSource(reader)); } - @Converter(order = 38) + @Converter(order = 40) public SAXSource toSAXSourceFromStAX(StAXSource source, Exchange exchange) throws TransformerException { String str = toString(source, exchange); StringReader reader = new StringReader(str); return new SAXSource(new InputSource(reader)); } - @Converter(order = 39) + @Converter(order = 41) public DOMSource toDOMSourceFromSAX(SAXSource source) throws TransformerException { return new DOMSource(toDOMNodeFromSAX(source)); } - @Converter(order = 40) + @Converter(order = 42) public DOMSource toDOMSourceFromStAX(StAXSource source) throws TransformerException { return new DOMSource(toDOMNodeFromStAX(source)); } - @Converter(order = 41) + @Converter(order = 43) public Node toDOMNodeFromSAX(SAXSource source) throws TransformerException { DOMResult result = new DOMResult(); @@ -557,7 +571,7 @@ public class XmlConverter { return result.getNode(); } - @Converter(order = 42) + @Converter(order = 44) public Node toDOMNodeFromStAX(StAXSource source) throws TransformerException { DOMResult result = new DOMResult(); @@ -571,7 +585,7 @@ public class XmlConverter { * @param nl the NodeList * @return the DOM Node */ - @Converter(order = 43, allowNull = true) + @Converter(order = 45, allowNull = true) public Node toDOMNodeFromSingleNodeList(NodeList nl) { return nl.getLength() == 1 ? nl.item(0) : null; } @@ -579,10 +593,10 @@ public class XmlConverter { /** * Create a DOM document from the given Node. * - * If the node is an document, just cast it, if the node is an root element, retrieve its owner element or create a + * If the node is a document, just cast it, if the node is an root element, retrieve its owner element or create a * new document and import the node. */ - @Converter(order = 44) + @Converter(order = 46) public Document toDOMDocument(final Node node) throws ParserConfigurationException, TransformerException { ObjectHelper.notNull(node, "node"); @@ -614,7 +628,7 @@ public class XmlConverter { /** * Converts the given Source into a W3C DOM node */ - @Converter(order = 45, allowNull = true) + @Converter(order = 47, allowNull = true) public Node toDOMNode(Source source) throws TransformerException, ParserConfigurationException, IOException, SAXException { DOMSource domSrc = toDOMSource(source, null); return domSrc != null ? domSrc.getNode() : null; @@ -623,7 +637,7 @@ public class XmlConverter { /** * Create a DOM element from the given source. */ - @Converter(order = 46) + @Converter(order = 48) public Element toDOMElement(Source source) throws TransformerException, ParserConfigurationException, IOException, SAXException { Node node = toDOMNode(source); @@ -634,7 +648,7 @@ public class XmlConverter { * Create a DOM element from the DOM node. Simply cast if the node is an Element, or return the root element if it * is a Document. */ - @Converter(order = 47) + @Converter(order = 49) public Element toDOMElement(Node node) throws TransformerException { // If the node is an document, return the root element if (node instanceof Document) { @@ -655,13 +669,20 @@ public class XmlConverter { * @param exchange is the exchange to be used when calling the converter * @return the parsed document */ - @Converter(order = 48) + @Converter(order = 50) public Document toDOMDocument(byte[] data, Exchange exchange) throws IOException, SAXException, ParserConfigurationException { DocumentBuilder documentBuilder = createDocumentBuilder(getDocumentBuilderFactory(exchange)); return documentBuilder.parse(new ByteArrayInputStream(data)); } + @Converter(order = 51) + public Document toDOMDocument(StreamCache cache, Exchange exchange) + throws IOException, SAXException, ParserConfigurationException { + InputStream is = exchange.getContext().getTypeConverter().convertTo(InputStream.class, exchange, cache); + return toDOMDocument(is, exchange); + } + /** * Converts the given {@link InputStream} to a DOM document * @@ -669,7 +690,7 @@ public class XmlConverter { * @param exchange is the exchange to be used when calling the converter * @return the parsed document */ - @Converter(order = 49) + @Converter(order = 52) public Document toDOMDocument(InputStream in, Exchange exchange) throws IOException, SAXException, ParserConfigurationException { DocumentBuilder documentBuilder = createDocumentBuilder(getDocumentBuilderFactory(exchange)); @@ -690,7 +711,7 @@ public class XmlConverter { * @param exchange is the exchange to be used when calling the converter * @return the parsed document */ - @Converter(order = 50) + @Converter(order = 53) public Document toDOMDocument(Reader in, Exchange exchange) throws IOException, SAXException, ParserConfigurationException { return toDOMDocument(new InputSource(in), exchange); } @@ -702,7 +723,7 @@ public class XmlConverter { * @param exchange is the exchange to be used when calling the converter * @return the parsed document */ - @Converter(order = 51) + @Converter(order = 54) public Document toDOMDocument(InputSource in, Exchange exchange) throws IOException, SAXException, ParserConfigurationException { DocumentBuilder documentBuilder = createDocumentBuilder(getDocumentBuilderFactory(exchange)); @@ -716,7 +737,7 @@ public class XmlConverter { * @param exchange is the exchange to be used when calling the converter * @return the parsed document */ - @Converter(order = 52) + @Converter(order = 55) public Document toDOMDocument(String text, Exchange exchange) throws IOException, SAXException, ParserConfigurationException { return toDOMDocument(new StringReader(text), exchange); @@ -729,7 +750,7 @@ public class XmlConverter { * @param exchange is the exchange to be used when calling the converter * @return the parsed document */ - @Converter(order = 53) + @Converter(order = 56) public Document toDOMDocument(File file, Exchange exchange) throws IOException, SAXException, ParserConfigurationException { DocumentBuilder documentBuilder = createDocumentBuilder(getDocumentBuilderFactory(exchange)); return documentBuilder.parse(file); @@ -738,7 +759,7 @@ public class XmlConverter { /** * Create a DOM document from the given source. */ - @Converter(order = 54) + @Converter(order = 57) public Document toDOMDocument(Source source) throws TransformerException, ParserConfigurationException, IOException, SAXException { Node node = toDOMNode(source); @@ -756,7 +777,7 @@ public class XmlConverter { * @param nl the NodeList * @return the DOM Document */ - @Converter(order = 55, allowNull = true) + @Converter(order = 58, allowNull = true) public Document toDOMDocumentFromSingleNodeList(NodeList nl) throws ParserConfigurationException, TransformerException { if (nl.getLength() == 1) { return toDOMDocument(nl.item(0)); @@ -769,22 +790,22 @@ public class XmlConverter { } } - @Converter(order = 56) + @Converter(order = 59) public InputStream toInputStream(DOMSource source, Exchange exchange) throws TransformerException { return new ByteArrayInputStream(toByteArray(source, exchange)); } - @Converter(order = 57) + @Converter(order = 60) public InputStream toInputStream(Document dom, Exchange exchange) throws TransformerException { return toInputStream(new DOMSource(dom), exchange); } - @Converter(order = 58) + @Converter(order = 61) public InputSource toInputSource(InputStream is, Exchange exchange) { return new InputSource(is); } - @Converter(order = 59) + @Converter(order = 62) public InputSource toInputSource(File file, Exchange exchange) throws FileNotFoundException { InputStream is = IOHelper.buffered(new FileInputStream(file)); return new InputSource(is); @@ -794,7 +815,7 @@ public class XmlConverter { * Converts the source instance to a {@link DOMSource} or returns null if the conversion is not supported (making it * easy to derive from this class to add new kinds of conversion). */ - @Converter(order = 60) + @Converter(order = 63) public DOMSource toDOMSource(Source source, Exchange exchange) throws ParserConfigurationException, IOException, SAXException, TransformerException { if (source instanceof DOMSource) { @@ -814,7 +835,7 @@ public class XmlConverter { * Converts the source instance to a {@link SAXSource} or returns null if the conversion is not supported (making it * easy to derive from this class to add new kinds of conversion). */ - @Converter(order = 61) + @Converter(order = 64) public SAXSource toSAXSource(Source source, Exchange exchange) throws IOException, SAXException, TransformerException { if (source instanceof SAXSource) { return (SAXSource) source; @@ -829,7 +850,7 @@ public class XmlConverter { } } - @Converter(order = 62) + @Converter(order = 65) public StreamSource toStreamSource(Source source, Exchange exchange) throws TransformerException { if (source instanceof StreamSource) { return (StreamSource) source; @@ -844,7 +865,7 @@ public class XmlConverter { } } - @Converter(order = 63) + @Converter(order = 66) public InputStream toInputStream(StreamSource source) throws IOException { InputStream is = source.getInputStream(); if (is == null) { @@ -855,19 +876,6 @@ public class XmlConverter { return is; } - @Converter(order = 64) - public Source toSource(StreamCache cache, Exchange exchange) { - byte[] arr = exchange.getContext().getTypeConverter().convertTo(byte[].class, exchange, cache); - return toSource(arr); - } - - @Converter(order = 65) - public Document toDOMDocument(StreamCache cache, Exchange exchange) - throws IOException, SAXException, ParserConfigurationException { - byte[] arr = exchange.getContext().getTypeConverter().convertTo(byte[].class, exchange, cache); - return toDOMDocument(arr, exchange); - } - /** * Converts the given Document to into text *
