You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/09/07 21:54:30 UTC

svn commit: r573680 - in /activemq/camel/trunk/components/camel-xmlbeans: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/camel/ src/main/java/org/apache/camel/converter/ src/main/java/org/apache/c...

Author: jstrachan
Date: Fri Sep  7 12:54:24 2007
New Revision: 573680

URL: http://svn.apache.org/viewvc?rev=573680&view=rev
Log:
added support for XMLBeans for CAMEL-138

Added:
    activemq/camel/trunk/components/camel-xmlbeans/
    activemq/camel/trunk/components/camel-xmlbeans/pom.xml   (with props)
    activemq/camel/trunk/components/camel-xmlbeans/src/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/java/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/XmlBeansConverter.java   (with props)
    activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/package.html   (with props)
    activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/META-INF/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/META-INF/LICENSE.txt
      - copied unchanged from r572881, activemq/camel/trunk/components/camel-jdbc/src/main/resources/META-INF/LICENSE.txt
    activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/META-INF/NOTICE.txt
      - copied unchanged from r572881, activemq/camel/trunk/components/camel-jdbc/src/main/resources/META-INF/NOTICE.txt
    activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/META-INF/services/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/META-INF/services/org/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/META-INF/services/org/apache/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/META-INF/services/org/apache/camel/
    activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
      - copied, changed from r572881, activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
    activemq/camel/trunk/components/camel-xmlbeans/src/test/
    activemq/camel/trunk/components/camel-xmlbeans/src/test/java/
    activemq/camel/trunk/components/camel-xmlbeans/src/test/java/org/
    activemq/camel/trunk/components/camel-xmlbeans/src/test/java/org/apache/
    activemq/camel/trunk/components/camel-xmlbeans/src/test/java/org/apache/camel/
    activemq/camel/trunk/components/camel-xmlbeans/src/test/java/org/apache/camel/converter/
    activemq/camel/trunk/components/camel-xmlbeans/src/test/java/org/apache/camel/converter/xmlbeans/
    activemq/camel/trunk/components/camel-xmlbeans/src/test/java/org/apache/camel/converter/xmlbeans/XmlBeansConverterTest.java   (with props)
    activemq/camel/trunk/components/camel-xmlbeans/src/test/resources/
    activemq/camel/trunk/components/camel-xmlbeans/src/test/resources/log4j.properties
      - copied, changed from r572881, activemq/camel/trunk/camel-core/src/test/resources/log4j.properties

Added: activemq/camel/trunk/components/camel-xmlbeans/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-xmlbeans/pom.xml?rev=573680&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-xmlbeans/pom.xml (added)
+++ activemq/camel/trunk/components/camel-xmlbeans/pom.xml Fri Sep  7 12:54:24 2007
@@ -0,0 +1,78 @@
+<?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-xmlbeans</artifactId>
+  <name>Camel :: XMLBeans</name>
+  <description>Camel XMLBeans support</description>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>xmlbeans</groupId>
+      <artifactId>xbean</artifactId>
+      <version>2.2.0</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>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-xmlbeans/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/XmlBeansConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/XmlBeansConverter.java?rev=573680&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/XmlBeansConverter.java (added)
+++ activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/XmlBeansConverter.java Fri Sep  7 12:54:24 2007
@@ -0,0 +1,106 @@
+/**
+ *
+ * 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.xmlbeans;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.nio.ByteBuffer;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+
+import org.apache.camel.Converter;
+import org.apache.camel.converter.IOConverter;
+import org.apache.camel.converter.NIOConverter;
+import org.apache.camel.converter.jaxp.XmlConverter;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+/**
+ * A <a href="http://activemq.apache.org/camel/type-coverter.html">Type Converter</a>
+ * of XMLBeans objects
+ *
+ * @version $Revision: 1.1 $
+ */
+@Converter
+public class XmlBeansConverter {
+    private XmlConverter xmlConverter = new XmlConverter();
+
+    @Converter
+    public static XmlObject toXmlObject(File value) throws IOException, XmlException {
+        return XmlObject.Factory.parse(value);
+    }
+
+    @Converter
+    public static XmlObject toXmlObject(Reader value) throws IOException, XmlException {
+        return XmlObject.Factory.parse(value);
+    }
+
+    @Converter
+    public static XmlObject toXmlObject(Node value) throws IOException, XmlException {
+        return XmlObject.Factory.parse(value);
+    }
+
+    @Converter
+    public static XmlObject toXmlObject(InputStream value) throws IOException, XmlException {
+        return XmlObject.Factory.parse(value);
+    }
+
+    @Converter
+    public static XmlObject toXmlObject(String value) throws IOException, XmlException {
+        return toXmlObject(IOConverter.toInputStream(value));
+    }
+
+    @Converter
+    public static XmlObject toXmlObject(byte[] value) throws IOException, XmlException {
+        return toXmlObject(IOConverter.toInputStream(value));
+    }
+
+    @Converter
+    public static XmlObject toXmlObject(ByteBuffer value) throws IOException, XmlException {
+        return toXmlObject(NIOConverter.toInputStream(value));
+    }
+
+    @Converter
+    public static XmlObject toXmlObject(XMLStreamReader value) throws IOException, XmlException {
+        return XmlObject.Factory.parse(value);
+    }
+
+    @Converter
+    public XmlObject toXmlObject(Source value) throws IOException, XmlException, TransformerException, ParserConfigurationException, SAXException {
+        Document document = getXmlConverter().toDOMDocument(value);
+        return toXmlObject(document);
+    }
+
+    // Properties
+    //-------------------------------------------------------------------------
+    public XmlConverter getXmlConverter() {
+        return xmlConverter;
+    }
+
+    public void setXmlConverter(XmlConverter xmlConverter) {
+        this.xmlConverter = xmlConverter;
+    }
+}

Propchange: activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/XmlBeansConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/package.html?rev=573680&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/package.html (added)
+++ activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/package.html Fri Sep  7 12:54:24 2007
@@ -0,0 +1,26 @@
+<!--
+    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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+A <a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/TypeConverter.html">TypeConverter</a>
+methods for working with XMLBeans
+
+</body>
+</html>

Propchange: activemq/camel/trunk/components/camel-xmlbeans/src/main/java/org/apache/camel/converter/xmlbeans/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/META-INF/services/org/apache/camel/TypeConverter (from r572881, activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/META-INF/services/org/apache/camel/TypeConverter?p2=activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/META-INF/services/org/apache/camel/TypeConverter&p1=activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter&r1=572881&r2=573680&rev=573680&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter (original)
+++ activemq/camel/trunk/components/camel-xmlbeans/src/main/resources/META-INF/services/org/apache/camel/TypeConverter Fri Sep  7 12:54:24 2007
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.camel.converter
\ No newline at end of file
+org.apache.camel.converter.xmlbeans
\ No newline at end of file

Added: activemq/camel/trunk/components/camel-xmlbeans/src/test/java/org/apache/camel/converter/xmlbeans/XmlBeansConverterTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-xmlbeans/src/test/java/org/apache/camel/converter/xmlbeans/XmlBeansConverterTest.java?rev=573680&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-xmlbeans/src/test/java/org/apache/camel/converter/xmlbeans/XmlBeansConverterTest.java (added)
+++ activemq/camel/trunk/components/camel-xmlbeans/src/test/java/org/apache/camel/converter/xmlbeans/XmlBeansConverterTest.java Fri Sep  7 12:54:24 2007
@@ -0,0 +1,39 @@
+/**
+ *
+ * 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.xmlbeans;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class XmlBeansConverterTest extends ContextTestSupport {
+    public void testConvertToXmlObject() throws Exception {
+        Exchange exchange = createExchangeWithBody("<hello>world!</hello>");
+        Message in = exchange.getIn();
+        XmlObject object = in.getBody(XmlObject.class);
+        assertNotNull("Should have created an XmlObject!", object);
+
+        log.info("Found: " + object);
+        assertEquals("body as String", in.getBody(String.class), object.toString());
+
+    }
+}

Propchange: activemq/camel/trunk/components/camel-xmlbeans/src/test/java/org/apache/camel/converter/xmlbeans/XmlBeansConverterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: activemq/camel/trunk/components/camel-xmlbeans/src/test/resources/log4j.properties (from r572881, activemq/camel/trunk/camel-core/src/test/resources/log4j.properties)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-xmlbeans/src/test/resources/log4j.properties?p2=activemq/camel/trunk/components/camel-xmlbeans/src/test/resources/log4j.properties&p1=activemq/camel/trunk/camel-core/src/test/resources/log4j.properties&r1=572881&r2=573680&rev=573680&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/resources/log4j.properties (original)
+++ activemq/camel/trunk/components/camel-xmlbeans/src/test/resources/log4j.properties Fri Sep  7 12:54:24 2007
@@ -18,7 +18,7 @@
 #
 # The logging properties used during tests..
 #
-log4j.rootLogger=INFO, out
+log4j.rootLogger=INFO, stdout
 
 log4j.logger.org.apache.activemq.spring=WARN