activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r964087 - in /activemq/trunk: activemq-core/pom.xml activemq-core/src/main/java/org/apache/activemq/transport/stomp/JmsFrameTranslator.java activemq-core/src/main/java/org/apache/activemq/util/JettisonMappedXmlDriver.java pom.xml
Date Wed, 14 Jul 2010 15:51:37 GMT
Author: dejanb
Date: Wed Jul 14 15:51:37 2010
New Revision: 964087

URL: http://svn.apache.org/viewvc?rev=964087&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2825 - jettison 1.2

Added:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JettisonMappedXmlDriver.java
Modified:
    activemq/trunk/activemq-core/pom.xml
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/JmsFrameTranslator.java
    activemq/trunk/pom.xml

Modified: activemq/trunk/activemq-core/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/pom.xml?rev=964087&r1=964086&r2=964087&view=diff
==============================================================================
--- activemq/trunk/activemq-core/pom.xml (original)
+++ activemq/trunk/activemq-core/pom.xml Wed Jul 14 15:51:37 2010
@@ -33,6 +33,8 @@
   <properties>
     <activemq.osgi.import.pkg>
       com.thoughtworks.xstream*;resolution:=optional,
+      javax.xml.stream*;resolution:=optional,
+      org.codehaus.jettison*;resolution:=optional,
       org.apache.activeio*;resolution:=optional,
       org.apache.camel*;resolution:=optional,
       org.apache.commons.pool*;resolution:=optional,
@@ -155,6 +157,11 @@
       <artifactId>xstream</artifactId>
       <optional>true</optional>
     </dependency>        
+    <dependency>
+        <groupId>org.codehaus.jettison</groupId>
+        <artifactId>jettison</artifactId>
+        <optional>true</optional>
+    </dependency>       
 
     <!-- for XML parsing -->
     <dependency>
@@ -162,6 +169,11 @@
       <artifactId>xbean-spring</artifactId>
       <optional>true</optional>
     </dependency>
+    <dependency>
+      <groupId>stax</groupId>
+      <artifactId>stax-api</artifactId>
+      <optional>true</optional>
+    </dependency>
 
     <dependency>
       <groupId>org.springframework</groupId>
@@ -219,27 +231,17 @@
       <optional>false</optional>
       <type>test-jar</type>
     </dependency>
-	<dependency>
-		<groupId>org.codehaus.jettison</groupId>
-		<artifactId>jettison</artifactId>
-		<version>1.0</version>
-		<scope>test</scope>
-	</dependency>	
-	<dependency>
-		<groupId>stax</groupId>
-		<artifactId>stax-api</artifactId>
-		<scope>test</scope>
-	</dependency>
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-jms</artifactId>
       <scope>test</scope>
-    </dependency>    
+    </dependency>
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-test</artifactId>
       <scope>test</scope>
-    </dependency>    
+    </dependency>
+    
     <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/JmsFrameTranslator.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/JmsFrameTranslator.java?rev=964087&r1=964086&r2=964087&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/JmsFrameTranslator.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/JmsFrameTranslator.java
Wed Jul 14 15:51:37 2010
@@ -29,18 +29,16 @@ import org.apache.activemq.advisory.Advi
 import org.apache.activemq.command.ActiveMQMapMessage;
 import org.apache.activemq.command.ActiveMQMessage;
 import org.apache.activemq.command.ActiveMQObjectMessage;
-import org.apache.activemq.command.ConsumerId;
 import org.apache.activemq.command.DataStructure;
+import org.apache.activemq.util.JettisonMappedXmlDriver;
+import org.codehaus.jettison.mapped.Configuration;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 
-import com.sun.tools.javac.util.Log;
 import com.thoughtworks.xstream.XStream;
 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
 import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
-import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
-import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
 import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
 import com.thoughtworks.xstream.io.xml.XppReader;
 
@@ -174,7 +172,7 @@ public class JmsFrameTranslator extends 
 		StringWriter buffer = new StringWriter();
 		HierarchicalStreamWriter out;
 		if (transformation.toLowerCase().endsWith("json")) {
-			out = new JettisonMappedXmlDriver().createWriter(buffer);
+			out = new JettisonMappedXmlDriver(new Configuration(), false).createWriter(buffer);
 		} else {
 			out = new PrettyPrintWriter(buffer);
 		}

Added: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JettisonMappedXmlDriver.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JettisonMappedXmlDriver.java?rev=964087&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JettisonMappedXmlDriver.java
(added)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JettisonMappedXmlDriver.java
Wed Jul 14 15:51:37 2010
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2007, 2008 XStream Committers.
+ * All rights reserved.
+ *
+ * The software in this package is published under the terms of the BSD
+ * style license a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ * 
+ * Created on 30. March 2007 by Joerg Schaible
+ */
+package org.apache.activemq.util;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.codehaus.jettison.mapped.Configuration;
+import org.codehaus.jettison.mapped.MappedNamespaceConvention;
+import org.codehaus.jettison.mapped.MappedXMLInputFactory;
+import org.codehaus.jettison.mapped.MappedXMLOutputFactory;
+
+import com.thoughtworks.xstream.io.HierarchicalStreamDriver;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
+import com.thoughtworks.xstream.io.StreamException;
+import com.thoughtworks.xstream.io.json.JettisonStaxWriter;
+import com.thoughtworks.xstream.io.xml.QNameMap;
+import com.thoughtworks.xstream.io.xml.StaxReader;
+import com.thoughtworks.xstream.io.xml.StaxWriter;
+
+
+/**
+ * 
+ * Temporary used until XStream 1.3.2 is released
+ * 
+ * Simple XStream driver wrapping Jettison's Mapped reader and writer. Serializes object
from
+ * and to JSON.
+ * 
+ * @author Dejan Bosanac
+ */
+public class JettisonMappedXmlDriver implements HierarchicalStreamDriver {
+
+    private final MappedXMLOutputFactory mof;
+    private final MappedXMLInputFactory mif;
+    private final MappedNamespaceConvention convention;
+    private boolean useSerializeAsArray = true;
+
+    public JettisonMappedXmlDriver() {
+        this(new Configuration(), true);
+    }
+
+    public JettisonMappedXmlDriver(final Configuration config, final boolean useSerializeAsArray)
{
+        mof = new MappedXMLOutputFactory(config);
+        mif = new MappedXMLInputFactory(config);
+        convention = new MappedNamespaceConvention(config);
+        this.useSerializeAsArray = useSerializeAsArray;
+    }
+    
+    public HierarchicalStreamReader createReader(final Reader reader) {
+        try {
+            return new StaxReader(new QNameMap(), mif.createXMLStreamReader(reader));
+        } catch (final XMLStreamException e) {
+            throw new StreamException(e);
+        }
+    }
+
+    public HierarchicalStreamReader createReader(final InputStream input) {
+        try {
+            return new StaxReader(new QNameMap(), mif.createXMLStreamReader(input));
+        } catch (final XMLStreamException e) {
+            throw new StreamException(e);
+        }
+    }
+
+    public HierarchicalStreamWriter createWriter(final Writer writer) {
+        try {
+            if (useSerializeAsArray) {
+                return new JettisonStaxWriter(new QNameMap(), mof.createXMLStreamWriter(writer),
convention);
+            } else {
+                return new StaxWriter(new QNameMap(), mof.createXMLStreamWriter(writer));
+            }
+        } catch (final XMLStreamException e) {
+            throw new StreamException(e);
+        }
+    }
+
+    public HierarchicalStreamWriter createWriter(final OutputStream output) {
+        try {
+            if (useSerializeAsArray) {
+                return new JettisonStaxWriter(new QNameMap(), mof.createXMLStreamWriter(output),
convention);
+            } else {
+                return new StaxWriter(new QNameMap(), mof.createXMLStreamWriter(output));
+            }
+        } catch (final XMLStreamException e) {
+            throw new StreamException(e);
+        }
+    }
+
+}
\ No newline at end of file

Modified: activemq/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/pom.xml?rev=964087&r1=964086&r2=964087&view=diff
==============================================================================
--- activemq/trunk/pom.xml (original)
+++ activemq/trunk/pom.xml Wed Jul 14 15:51:37 2010
@@ -63,7 +63,7 @@
     <jdom-version>1.0</jdom-version>
     <jetty-version>7.0.1.v20091125</jetty-version>
     <jsp-version>2.1.v20100127</jsp-version>
-    <jettison-version>1.1</jettison-version>
+    <jettison-version>1.2</jettison-version>
     <jmock-version>2.5.1</jmock-version>
     <junit-version>4.5</junit-version>
     <jxta-version>2.0</jxta-version>
@@ -76,6 +76,7 @@
     <rome-version>0.8</rome-version>
     <slf4j-version>1.5.0</slf4j-version>
     <spring-oxm-version>1.5.8</spring-oxm-version>
+    <stax-api-version>1.0.1</stax-api-version>
     <stax-version>1.2.0</stax-version>
     <xalan-version>2.6.0</xalan-version>
     <xmlbeans-version>2.0.0-beta1</xmlbeans-version>
@@ -744,7 +745,7 @@
       <dependency>
         <groupId>stax</groupId>
         <artifactId>stax-api</artifactId>
-        <version>1.0.1</version>
+        <version>${stax-api-version}</version>
       </dependency>
       <dependency>
         <groupId>stax</groupId>



Mime
View raw message