01: package org.objectweb.celtix.jbi.transport;
02:
03: import java.io.ByteArrayInputStream;
04: import java.io.ByteArrayOutputStream;
05: import java.io.IOException;
06: import java.io.InputStream;
07: import java.util.logging.Logger;
08:
09: import javax.xml.transform.Source;
10: import javax.xml.transform.Transformer;
11: import javax.xml.transform.TransformerConfigurationException;
12: import javax.xml.transform.TransformerException;
13: import javax.xml.transform.TransformerFactory;
14: import javax.xml.transform.stream.StreamResult;
15:
16: public final class JBIMessageHelper {
17:
18: private static final Logger LOG = Logger
19: .getLogger(JBIMessageHelper.class.getName());
20:
21: private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory
22: .newInstance();
23:
24: private JBIMessageHelper() {
25: // complete
26: }
27:
28: public static InputStream convertMessageToInputStream(Source src)
29: throws IOException, TransformerConfigurationException,
30: TransformerException {
31:
32: final Transformer transformer = TRANSFORMER_FACTORY
33: .newTransformer();
34:
35: ByteArrayOutputStream baos = new ByteArrayOutputStream();
36: StreamResult result = new StreamResult(baos);
37: transformer.transform(src, result);
38: LOG.finest("received message: "
39: + new String(baos.toByteArray()));
40:
41: return new ByteArrayInputStream(baos.toByteArray());
42: }
43: }
|