camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r586062 - in /activemq/camel/trunk: ./ apache-camel/ apache-camel/src/main/descriptors/ camel-core/ camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/converter/jaxp/ camel-core/src/main/java/org/ap...
Date Thu, 18 Oct 2007 18:39:41 GMT
Author: jstrachan
Date: Thu Oct 18 11:39:39 2007
New Revision: 586062

URL: http://svn.apache.org/viewvc?rev=586062&view=rev
Log:
added support for XStream data format for https://issues.apache.org/activemq/browse/CAMEL-183

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
  (with props)
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java
      - copied, changed from r585168, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLBeansDataFormat.java
    activemq/camel/trunk/components/camel-xstream/
    activemq/camel/trunk/components/camel-xstream/pom.xml   (with props)
    activemq/camel/trunk/components/camel-xstream/src/
    activemq/camel/trunk/components/camel-xstream/src/main/
    activemq/camel/trunk/components/camel-xstream/src/main/java/
    activemq/camel/trunk/components/camel-xstream/src/main/java/org/
    activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/
    activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/
    activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/
    activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/
    activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/XStreamDataFormat.java
  (with props)
    activemq/camel/trunk/components/camel-xstream/src/main/resources/
    activemq/camel/trunk/components/camel-xstream/src/main/resources/META-INF/
    activemq/camel/trunk/components/camel-xstream/src/main/resources/META-INF/services/
    activemq/camel/trunk/components/camel-xstream/src/main/resources/META-INF/services/org/
    activemq/camel/trunk/components/camel-xstream/src/main/resources/META-INF/services/org/apache/
    activemq/camel/trunk/components/camel-xstream/src/main/resources/META-INF/services/org/apache/camel/
    activemq/camel/trunk/components/camel-xstream/src/test/
    activemq/camel/trunk/components/camel-xstream/src/test/java/
    activemq/camel/trunk/components/camel-xstream/src/test/java/org/
    activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/
    activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/
    activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/
    activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/
    activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/UnmarshalThenMarshalTest.java
  (with props)
    activemq/camel/trunk/components/camel-xstream/src/test/resources/
    activemq/camel/trunk/components/camel-xstream/src/test/resources/log4j.properties   (with
props)
Modified:
    activemq/camel/trunk/apache-camel/pom.xml
    activemq/camel/trunk/apache-camel/src/main/descriptors/unix-bin.xml
    activemq/camel/trunk/apache-camel/src/main/descriptors/windows-bin.xml
    activemq/camel/trunk/camel-core/pom.xml
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataTypeExpression.java
    activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/dataformat/jaxb.index
    activemq/camel/trunk/components/pom.xml
    activemq/camel/trunk/pom.xml

Modified: activemq/camel/trunk/apache-camel/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/apache-camel/pom.xml?rev=586062&r1=586061&r2=586062&view=diff
==============================================================================
--- activemq/camel/trunk/apache-camel/pom.xml (original)
+++ activemq/camel/trunk/apache-camel/pom.xml Thu Oct 18 11:39:39 2007
@@ -153,6 +153,10 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-xmpp</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-xstream</artifactId>
+    </dependency>
 
     <dependency>
       <groupId>org.apache.camel</groupId>

Modified: activemq/camel/trunk/apache-camel/src/main/descriptors/unix-bin.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/apache-camel/src/main/descriptors/unix-bin.xml?rev=586062&r1=586061&r2=586062&view=diff
==============================================================================
--- activemq/camel/trunk/apache-camel/src/main/descriptors/unix-bin.xml (original)
+++ activemq/camel/trunk/apache-camel/src/main/descriptors/unix-bin.xml Thu Oct 18 11:39:39
2007
@@ -110,6 +110,7 @@
         <include>org.apache.camel:camel-velocity</include>
         <include>org.apache.camel:camel-xmlbeans</include>
         <include>org.apache.camel:camel-xmpp</include>
+        <include>org.apache.camel:camel-xstream</include>
         <include>commons-logging:commons-logging</include>
       </includes>
     </dependencySet>

Modified: activemq/camel/trunk/apache-camel/src/main/descriptors/windows-bin.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/apache-camel/src/main/descriptors/windows-bin.xml?rev=586062&r1=586061&r2=586062&view=diff
==============================================================================
--- activemq/camel/trunk/apache-camel/src/main/descriptors/windows-bin.xml (original)
+++ activemq/camel/trunk/apache-camel/src/main/descriptors/windows-bin.xml Thu Oct 18 11:39:39
2007
@@ -114,6 +114,7 @@
         <include>org.apache.camel:camel-spring</include>
         <include>org.apache.camel:camel-xmlbeans</include>
         <include>org.apache.camel:camel-xmpp</include>
+        <include>org.apache.camel:camel-xstream</include>
         <include>commons-logging:commons-logging</include>
       </includes>
     </dependencySet>

Modified: activemq/camel/trunk/camel-core/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/pom.xml?rev=586062&r1=586061&r2=586062&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/pom.xml (original)
+++ activemq/camel/trunk/camel-core/pom.xml Thu Oct 18 11:39:39 2007
@@ -48,6 +48,14 @@
       <artifactId>jaxb-api</artifactId>
     </dependency>
 
+    <!-- we could move the StAX code into a separate module? -->
+    <dependency>
+      <groupId>stax</groupId>
+      <artifactId>stax-api</artifactId>
+      <optional>true</optional>
+      <scope>compile</scope>
+    </dependency>
+
     <!-- to allow Spring annotations to be used; could replace with the micro-jar later
-->
     <dependency>
       <groupId>org.springframework</groupId>

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataTypeExpression.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataTypeExpression.java?rev=586062&r1=586061&r2=586062&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataTypeExpression.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataTypeExpression.java
Thu Oct 18 11:39:39 2007
@@ -24,6 +24,7 @@
 import org.apache.camel.model.dataformat.JaxbDataFormat;
 import org.apache.camel.model.dataformat.SerializationDataFormat;
 import org.apache.camel.model.dataformat.XMLBeansDataFormat;
+import org.apache.camel.model.dataformat.XStreamDataFormat;
 import org.apache.camel.spi.DataFormat;
 
 /**
@@ -57,6 +58,13 @@
      */
     public T jaxb() {
         return dataFormat(new JaxbDataFormat());
+    }
+
+    /**
+     * Uses the XStream data format
+     */
+    public T xstream() {
+        return dataFormat(new XStreamDataFormat());
     }
 
     /**

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java?rev=586062&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
(added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
Thu Oct 18 11:39:39 2007
@@ -0,0 +1,136 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.converter.jaxp;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+
+import org.apache.camel.Converter;
+
+/**
+ * A converter of StAX objects
+ *
+ * @version $Revision: 1.1 $
+ */
+@Converter
+public class StaxConverter {
+    private XMLInputFactory inputFactory;
+    private XMLOutputFactory outputFactory;
+
+    @Converter
+    public XMLEventWriter createXMLEventWriter(OutputStream out) throws XMLStreamException
{
+        return getOutputFactory().createXMLEventWriter(out);
+    }
+
+    @Converter
+    public XMLEventWriter createXMLEventWriter(Writer writer) throws XMLStreamException {
+        return getOutputFactory().createXMLEventWriter(writer);
+    }
+
+    @Converter
+    public XMLEventWriter createXMLEventWriter(Result result) throws XMLStreamException {
+        return getOutputFactory().createXMLEventWriter(result);
+    }
+
+    @Converter
+    public XMLStreamWriter createXMLStreamWriter(OutputStream outputStream) throws XMLStreamException
{
+        return getOutputFactory().createXMLStreamWriter(outputStream);
+    }
+
+    @Converter
+    public XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException
{
+        return getOutputFactory().createXMLStreamWriter(writer);
+    }
+
+    @Converter
+    public XMLStreamWriter createXMLStreamWriter(Result result) throws XMLStreamException
{
+        return getOutputFactory().createXMLStreamWriter(result);
+    }
+
+    @Converter
+    public XMLStreamReader createXMLStreamReader(InputStream in) throws XMLStreamException
{
+        return getInputFactory().createXMLStreamReader(in);
+    }
+
+    @Converter
+    public XMLStreamReader createXMLStreamReader(Reader in) throws XMLStreamException {
+        return getInputFactory().createXMLStreamReader(in);
+    }
+
+    @Converter
+    public XMLStreamReader createXMLStreamReader(Source in) throws XMLStreamException {
+        return getInputFactory().createXMLStreamReader(in);
+    }
+
+    @Converter
+    public XMLEventReader createXMLEventReader(InputStream in) throws XMLStreamException
{
+        return getInputFactory().createXMLEventReader(in);
+    }
+
+    @Converter
+    public XMLEventReader createXMLEventReader(Reader in) throws XMLStreamException {
+        return getInputFactory().createXMLEventReader(in);
+    }
+
+    @Converter
+    public XMLEventReader createXMLEventReader(XMLStreamReader in) throws XMLStreamException
{
+        return getInputFactory().createXMLEventReader(in);
+    }
+
+    @Converter
+    public XMLEventReader createXMLEventReader(Source in) throws XMLStreamException {
+        return getInputFactory().createXMLEventReader(in);
+    }
+
+    // Properties
+    //-------------------------------------------------------------------------
+
+    public XMLInputFactory getInputFactory() {
+        if (inputFactory == null) {
+            inputFactory = XMLInputFactory.newInstance();
+        }
+        return inputFactory;
+    }
+
+    public void setInputFactory(XMLInputFactory inputFactory) {
+        this.inputFactory = inputFactory;
+    }
+
+    public XMLOutputFactory getOutputFactory() {
+        if (outputFactory == null) {
+            outputFactory = XMLOutputFactory.newInstance();
+        }
+        return outputFactory;
+    }
+
+    public void setOutputFactory(XMLOutputFactory outputFactory) {
+        this.outputFactory = outputFactory;
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java
(from r585168, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLBeansDataFormat.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java?p2=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java&p1=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLBeansDataFormat.java&r1=585168&r2=586062&rev=586062&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLBeansDataFormat.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java
Thu Oct 18 11:39:39 2007
@@ -25,18 +25,18 @@
 import org.apache.camel.spi.DataFormat;
 
 /**
- * Represents the XMLBeans XML {@link DataFormat}
+ * Represents the XStream XML {@link DataFormat}
  *
  * @version $Revision: 1.1 $
  */
-@XmlRootElement(name = "xmlBeans")
+@XmlRootElement(name = "xstream")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class XMLBeansDataFormat extends DataFormatType {
+public class XStreamDataFormat extends DataFormatType {
     @XmlAttribute(required = false)
     private Boolean prettyPrint;
 
-    public XMLBeansDataFormat() {
-        super("org.apache.camel.converter.xmlbeans.XmlBeansDataFormat");
+    public XStreamDataFormat() {
+        super("org.apache.camel.dataformat.xstream.XStreamDataFormat");
     }
 
     public Boolean getPrettyPrint() {

Modified: activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/dataformat/jaxb.index
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/dataformat/jaxb.index?rev=586062&r1=586061&r2=586062&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/dataformat/jaxb.index
(original)
+++ activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/dataformat/jaxb.index
Thu Oct 18 11:39:39 2007
@@ -20,3 +20,4 @@
 JaxbDataFormat
 SerializationDataFormat
 XMLBeansDataFormat
+XStreamDataFormat

Added: activemq/camel/trunk/components/camel-xstream/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-xstream/pom.xml?rev=586062&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-xstream/pom.xml (added)
+++ activemq/camel/trunk/components/camel-xstream/pom.xml Thu Oct 18 11:39:39 2007
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-parent</artifactId>
+    <version>1.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-xstream</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: XStream</name>
+  <description>Camel XStream support</description>
+
+  <properties>
+    <camel.osgi.export.pkg>org.apache.camel.dataformat.xstream*</camel.osgi.export.pkg>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>xstream</groupId>
+      <artifactId>xstream</artifactId>
+      <version>1.1.3</version>
+    </dependency>
+    <dependency>
+      <groupId>stax</groupId>
+      <artifactId>stax-api</artifactId>
+    </dependency>
+
+    <!-- testing -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>xpp3</groupId>
+      <artifactId>xpp3</artifactId>
+      <version>1.1.3.3</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.woodstox</groupId>
+      <artifactId>wstx-asl</artifactId>
+      <version>3.2.1</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>
+
+

Propchange: activemq/camel/trunk/components/camel-xstream/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/XStreamDataFormat.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/XStreamDataFormat.java?rev=586062&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/XStreamDataFormat.java
(added)
+++ activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/XStreamDataFormat.java
Thu Oct 18 11:39:39 2007
@@ -0,0 +1,93 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.xstream;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+import com.thoughtworks.xstream.io.xml.QNameMap;
+import com.thoughtworks.xstream.io.xml.StaxWriter;
+import com.thoughtworks.xstream.io.xml.StaxReader;
+import org.apache.camel.Exchange;
+import org.apache.camel.converter.jaxp.StaxConverter;
+import org.apache.camel.spi.DataFormat;
+
+/**
+ * A <a href="http://activemq.apache.org/camel/data-format.html">data format</a>
+ * ({@link DataFormat}) using XmlBeans to marshal to and from XML
+ *
+ * @version $Revision: 1.1 $
+ */
+public class XStreamDataFormat implements DataFormat{
+
+    private XStream xstream;
+    private StaxConverter staxConverter;
+
+    public void marshal(Exchange exchange, Object body, OutputStream stream) throws Exception
{
+        HierarchicalStreamWriter writer = createHierarchicalStreamWriter(exchange, body,
stream);
+        getXStream().marshal(body, writer);
+    }
+
+    public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
+        HierarchicalStreamReader reader = createHierarchicalStreamReader(exchange, stream);
+        return getXStream().unmarshal(reader);
+    }
+
+    public XStream getXStream() {
+        if (xstream == null) {
+            xstream = createXStream();
+        }
+        return xstream;
+    }
+
+    public void setXStream(XStream xstream) {
+        this.xstream = xstream;
+    }
+
+    public StaxConverter getStaxConverter() {
+        if (staxConverter == null) {
+            staxConverter = new StaxConverter();
+        }
+        return staxConverter;
+    }
+
+    public void setStaxConverter(StaxConverter staxConverter) {
+        this.staxConverter = staxConverter;
+    }
+
+    protected XStream createXStream() {
+        return new XStream();
+    }
+
+    protected HierarchicalStreamWriter createHierarchicalStreamWriter(Exchange exchange,
Object body, OutputStream stream) throws XMLStreamException {
+        XMLStreamWriter xmlWriter = getStaxConverter().createXMLStreamWriter(stream);
+        return new StaxWriter(new QNameMap(), xmlWriter);
+    }
+
+    protected HierarchicalStreamReader createHierarchicalStreamReader(Exchange exchange,
InputStream stream) throws XMLStreamException {
+        XMLStreamReader xmlReader = getStaxConverter().createXMLStreamReader(stream);
+        return new StaxReader(new QNameMap(), xmlReader);
+    }
+}

Propchange: activemq/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/XStreamDataFormat.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/UnmarshalThenMarshalTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/UnmarshalThenMarshalTest.java?rev=586062&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/UnmarshalThenMarshalTest.java
(added)
+++ activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/UnmarshalThenMarshalTest.java
Thu Oct 18 11:39:39 2007
@@ -0,0 +1,72 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.xstream;
+
+import java.util.List;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class UnmarshalThenMarshalTest extends ContextTestSupport {
+    public void testSendXmlAndUnmarshal() throws Exception {
+
+        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+        resultEndpoint.expectedMessageCount(1);
+
+        PurchaseOrder expectedBody = new PurchaseOrder();
+        expectedBody.setAmount(20.0);
+        expectedBody.setName("Wine");
+        expectedBody.setPrice(5.0);
+
+        template.sendBody("direct:start", expectedBody);
+
+        resultEndpoint.assertIsSatisfied();
+
+        List<Exchange> list = resultEndpoint.getReceivedExchanges();
+        Exchange exchange = list.get(0);
+        Object actualBody = exchange.getIn().getBody();
+
+        log.debug("Received: " + actualBody);
+
+        System.out.println("Received " + actualBody);
+        assertEquals("Received body", expectedBody, actualBody);
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start").
+                        marshal().xstream().
+                        process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                System.out.println("marshalled: " + exchange.getIn().getBody(String.class));
+                                log.debug("marshalled: " + exchange.getIn().getBody(String.class));
+                            }
+                        }).
+                        unmarshal().xstream().
+                        to("mock:result");
+            }
+        };
+    }
+}

Propchange: activemq/camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/UnmarshalThenMarshalTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-xstream/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-xstream/src/test/resources/log4j.properties?rev=586062&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-xstream/src/test/resources/log4j.properties (added)
+++ activemq/camel/trunk/components/camel-xstream/src/test/resources/log4j.properties Thu
Oct 18 11:39:39 2007
@@ -0,0 +1,35 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+## 
+## http://www.apache.org/licenses/LICENSE-2.0
+## 
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, stdout
+
+log4j.logger.org.apache.activemq.spring=WARN
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/camel-test.log
+log4j.appender.out.append=true

Propchange: activemq/camel/trunk/components/camel-xstream/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/pom.xml?rev=586062&r1=586061&r2=586062&view=diff
==============================================================================
--- activemq/camel/trunk/components/pom.xml (original)
+++ activemq/camel/trunk/components/pom.xml Thu Oct 18 11:39:39 2007
@@ -67,6 +67,7 @@
     <module>camel-velocity</module>
     <module>camel-xmlbeans</module>
     <module>camel-xmpp</module>
+    <module>camel-xstream</module>
   </modules>
 
 </project>

Modified: activemq/camel/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/pom.xml?rev=586062&r1=586061&r2=586062&view=diff
==============================================================================
--- activemq/camel/trunk/pom.xml (original)
+++ activemq/camel/trunk/pom.xml Thu Oct 18 11:39:39 2007
@@ -349,6 +349,11 @@
         <artifactId>camel-xmpp</artifactId>
         <version>${camel-version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-xstream</artifactId>
+        <version>${camel-version}</version>
+      </dependency>
 
       <!-- testing jars -->
       <dependency>



Mime
View raw message