diff --git a/activemq-optional/pom.xml b/activemq-optional/pom.xml
index 0978c009b6..6789c26c68 100755
--- a/activemq-optional/pom.xml
+++ b/activemq-optional/pom.xml
@@ -47,7 +47,8 @@
org.springframework
- spring-core
+ spring
+ ${spring-version}
aopalliance
@@ -92,7 +93,6 @@
commons-httpclient
commons-httpclient
-
commons-logging
commons-logging
@@ -132,6 +132,7 @@
stax-api
true
+
log4j
log4j
@@ -139,29 +140,9 @@
true
- org.springframework
- spring-beans
- test
-
-
- org.springframework
- spring-context
- test
-
-
- org.springframework
- spring-aop
- test
-
-
- org.springframework
- spring-jms
- test
-
-
- org.springframework
- spring-jms
- test
+ org.springframework.ws
+ spring-oxm-tiger
+ true
org.apache.xbean
@@ -171,9 +152,8 @@
org.codehaus.jettison
jettison
- 1.1
test
-
+
diff --git a/activemq-optional/src/main/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformer.java b/activemq-optional/src/main/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformer.java
new file mode 100644
index 0000000000..f12331afec
--- /dev/null
+++ b/activemq-optional/src/main/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformer.java
@@ -0,0 +1,149 @@
+/**
+ * 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.activemq.util.oxm;
+
+import java.io.Serializable;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.MessageTransformerSupport;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.HierarchicalStreamDriver;
+
+/**
+ * Abstract class used as a base for implementing transformers from object to text messages (in XML/JSON format)
+ * and vice versa using.
+ * Supports plugging of custom marshallers
+ */
+public abstract class AbstractXMLMessageTransformer extends
+ MessageTransformerSupport {
+
+ protected MessageTransform transformType;
+
+ /**
+ * Defines the type of transformation. If XML (default), - producer
+ * transformation transforms from Object to XML. - consumer transformation
+ * transforms from XML to Object. If OBJECT, - producer transformation
+ * transforms from XML to Object. - consumer transformation transforms from
+ * Object to XML. If ADAPTIVE, - producer transformation transforms from
+ * Object to XML, or XML to Object depending on the type of the original
+ * message - consumer transformation transforms from XML to Object, or
+ * Object to XML depending on the type of the original message
+ */
+ public enum MessageTransform {
+ XML, OBJECT, ADAPTIVE
+ };
+
+
+ public AbstractXMLMessageTransformer() {
+ this(MessageTransform.XML);
+ }
+
+ public AbstractXMLMessageTransformer(MessageTransform transformType) {
+ this.transformType = transformType;
+ }
+
+ public Message consumerTransform(Session session, MessageConsumer consumer, Message message) throws JMSException {
+ switch (transformType) {
+ case XML:
+ return (message instanceof TextMessage) ? textToObject(session, (TextMessage)message) : message;
+ case OBJECT:
+ return (message instanceof ObjectMessage) ? objectToText(session, (ObjectMessage)message) : message;
+ case ADAPTIVE:
+ return (message instanceof TextMessage) ? textToObject(session, (TextMessage)message) : (message instanceof ObjectMessage) ? objectToText(session, (ObjectMessage)message) : message;
+ default:
+ }
+ return message;
+ }
+
+ public Message producerTransform(Session session, MessageProducer producer, Message message) throws JMSException {
+ switch (transformType) {
+ case XML:
+ return (message instanceof ObjectMessage) ? objectToText(session, (ObjectMessage)message) : message;
+ case OBJECT:
+ return (message instanceof TextMessage) ? textToObject(session, (TextMessage)message) : message;
+ case ADAPTIVE:
+ return (message instanceof TextMessage) ? textToObject(session, (TextMessage)message) : (message instanceof ObjectMessage) ? objectToText(session, (ObjectMessage)message) : message;
+ default:
+ }
+ return message;
+ }
+
+ public MessageTransform getTransformType() {
+ return transformType;
+ }
+
+ public void setTransformType(MessageTransform transformType) {
+ this.transformType = transformType;
+ }
+
+ /**
+ * Transforms an incoming XML encoded {@link TextMessage} to an
+ * {@link ObjectMessage}
+ *
+ * @param session - JMS session currently being used
+ * @param textMessage - text message to transform to object message
+ * @return ObjectMessage
+ * @throws JMSException
+ */
+ protected ObjectMessage textToObject(Session session, TextMessage textMessage) throws JMSException {
+ Object object = unmarshall(session, textMessage);
+ if (object instanceof Serializable) {
+ ObjectMessage answer = session.createObjectMessage((Serializable)object);
+ copyProperties(textMessage, answer);
+ return answer;
+ } else {
+ throw new JMSException("Object is not serializable: " + object);
+ }
+ }
+
+ /**
+ * Transforms an incoming {@link ObjectMessage} to an XML encoded
+ * {@link TextMessage}
+ *
+ * @param session - JMS session currently being used
+ * @param objectMessage - object message to transform to text message
+ * @return XML encoded TextMessage
+ * @throws JMSException
+ */
+ protected TextMessage objectToText(Session session, ObjectMessage objectMessage) throws JMSException {
+ TextMessage answer = session.createTextMessage(marshall(session, objectMessage));
+ copyProperties(objectMessage, answer);
+ return answer;
+ }
+
+ /**
+ * Marshalls the Object in the {@link ObjectMessage} to a string using XML
+ * encoding
+ */
+ protected abstract String marshall(Session session, ObjectMessage objectMessage) throws JMSException;
+
+ /**
+ * Unmarshalls the XML encoded message in the {@link TextMessage} to an
+ * Object
+ */
+ protected abstract Object unmarshall(Session session, TextMessage textMessage) throws JMSException;
+
+}
diff --git a/activemq-optional/src/main/java/org/apache/activemq/util/oxm/OXMMessageTransformer.java b/activemq-optional/src/main/java/org/apache/activemq/util/oxm/OXMMessageTransformer.java
new file mode 100644
index 0000000000..e4c473a182
--- /dev/null
+++ b/activemq-optional/src/main/java/org/apache/activemq/util/oxm/OXMMessageTransformer.java
@@ -0,0 +1,78 @@
+/**
+ * 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.activemq.util.oxm;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.springframework.oxm.AbstractMarshaller;
+import org.springframework.oxm.Marshaller;
+import org.springframework.oxm.Unmarshaller;
+import org.springframework.xml.transform.StringResult;
+import org.springframework.xml.transform.StringSource;
+
+/**
+ * Transforms object messages to text messages and vice versa using {@link Spring OXM}
+ *
+ */
+public class OXMMessageTransformer extends AbstractXMLMessageTransformer {
+
+ /**
+ * OXM marshaller used to marshall/unmarshall messages
+ */
+ private AbstractMarshaller marshaller;
+
+ public AbstractMarshaller getMarshaller() {
+ return marshaller;
+ }
+
+ public void setMarshaller(AbstractMarshaller marshaller) {
+ this.marshaller = marshaller;
+ }
+
+ /**
+ * Marshalls the Object in the {@link ObjectMessage} to a string using XML
+ * encoding
+ */
+ protected String marshall(Session session, ObjectMessage objectMessage)
+ throws JMSException {
+ StringResult result = new StringResult();
+ try {
+ marshaller.marshal(objectMessage.getObject(), result);
+ return result.toString();
+ } catch (Exception e) {
+ throw new JMSException(e.getMessage());
+ }
+ }
+
+ /**
+ * Unmarshalls the XML encoded message in the {@link TextMessage} to an
+ * Object
+ */
+ protected Object unmarshall(Session session, TextMessage textMessage)
+ throws JMSException {
+ try {
+ return marshaller.unmarshal(new StringSource(textMessage.getText()));
+ } catch (Exception e) {
+ throw new JMSException(e.getMessage());
+ }
+ }
+
+}
diff --git a/activemq-optional/src/main/java/org/apache/activemq/util/oxm/XStreamMessageTransformer.java b/activemq-optional/src/main/java/org/apache/activemq/util/oxm/XStreamMessageTransformer.java
new file mode 100644
index 0000000000..488842c317
--- /dev/null
+++ b/activemq-optional/src/main/java/org/apache/activemq/util/oxm/XStreamMessageTransformer.java
@@ -0,0 +1,108 @@
+/**
+ * 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.activemq.util.oxm;
+
+import java.io.Serializable;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.HierarchicalStreamDriver;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
+import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
+import com.thoughtworks.xstream.io.xml.XppReader;
+
+/**
+ * Transforms object messages to text messages and vice versa using
+ * {@link XStream}
+ *
+ */
+public class XStreamMessageTransformer extends AbstractXMLMessageTransformer {
+
+ private XStream xStream;
+
+ /**
+ * Specialized driver to be used with stream readers and writers
+ */
+ private HierarchicalStreamDriver streamDriver;
+
+ // Properties
+ // -------------------------------------------------------------------------
+ public XStream getXStream() {
+ if (xStream == null) {
+ xStream = createXStream();
+ }
+ return xStream;
+ }
+
+ public void setXStream(XStream xStream) {
+ this.xStream = xStream;
+ }
+
+ public HierarchicalStreamDriver getStreamDriver() {
+ return streamDriver;
+ }
+
+ public void setStreamDriver(HierarchicalStreamDriver streamDriver) {
+ this.streamDriver = streamDriver;
+ }
+
+ // Implementation methods
+ // -------------------------------------------------------------------------
+ protected XStream createXStream() {
+ return new XStream();
+ }
+
+ /**
+ * Marshalls the Object in the {@link ObjectMessage} to a string using XML
+ * encoding
+ */
+ protected String marshall(Session session, ObjectMessage objectMessage) throws JMSException {
+ Serializable object = objectMessage.getObject();
+ StringWriter buffer = new StringWriter();
+ HierarchicalStreamWriter out;
+ if (streamDriver != null) {
+ out = streamDriver.createWriter(buffer);
+ } else {
+ out = new PrettyPrintWriter(buffer);
+ }
+ getXStream().marshal(object, out);
+ return buffer.toString();
+ }
+
+ /**
+ * Unmarshalls the XML encoded message in the {@link TextMessage} to an
+ * Object
+ */
+ protected Object unmarshall(Session session, TextMessage textMessage) throws JMSException {
+ HierarchicalStreamReader in;
+ if (streamDriver != null) {
+ in = streamDriver.createReader(new StringReader(textMessage.getText()));
+ } else {
+ in = new XppReader(new StringReader(textMessage.getText()));
+ }
+ return getXStream().unmarshal(in);
+ }
+
+}
diff --git a/activemq-optional/src/main/java/org/apache/activemq/util/xstream/XStreamMessageTransformer.java b/activemq-optional/src/main/java/org/apache/activemq/util/xstream/XStreamMessageTransformer.java
index 838a88fd8d..5a88c7bec1 100644
--- a/activemq-optional/src/main/java/org/apache/activemq/util/xstream/XStreamMessageTransformer.java
+++ b/activemq-optional/src/main/java/org/apache/activemq/util/xstream/XStreamMessageTransformer.java
@@ -28,6 +28,8 @@ import javax.jms.ObjectMessage;
import javax.jms.Session;
import javax.jms.TextMessage;
+import org.apache.activemq.MessageTransformerSupport;
+
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.HierarchicalStreamDriver;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
@@ -35,14 +37,15 @@ import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
import com.thoughtworks.xstream.io.xml.XppReader;
-import org.apache.activemq.MessageTransformerSupport;
-
/**
* Transforms object messages to text messages and vice versa using
* {@link XStream}
*
+ * @deprecated as of 5.3.0 release replaced by {@link org.apache.activemq.util.oxm.XStreamMessageTransformer}
+ *
* @version $Revision$
*/
+@Deprecated
public class XStreamMessageTransformer extends MessageTransformerSupport {
protected MessageTransform transformType;
diff --git a/activemq-optional/src/test/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformerTest.java b/activemq-optional/src/test/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformerTest.java
new file mode 100644
index 0000000000..20c2755b11
--- /dev/null
+++ b/activemq-optional/src/test/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformerTest.java
@@ -0,0 +1,241 @@
+/**
+ * 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.activemq.util.oxm;
+
+import static org.apache.activemq.util.oxm.AbstractXMLMessageTransformer.MessageTransform.ADAPTIVE;
+import static org.apache.activemq.util.oxm.AbstractXMLMessageTransformer.MessageTransform.OBJECT;
+import static org.apache.activemq.util.oxm.AbstractXMLMessageTransformer.MessageTransform.XML;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.ActiveMQMessageConsumer;
+import org.apache.activemq.MessageTransformer;
+import org.apache.activemq.util.xstream.SamplePojo;
+import org.apache.activemq.util.xstream.XStreamMessageTransformer;
+
+import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
+
+public abstract class AbstractXMLMessageTransformerTest extends TestCase {
+ protected ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+ protected Connection connection;
+ protected long timeout = 5000;
+
+ protected Connection createConnection(MessageTransformer transformer) throws Exception {
+ connectionFactory.setTransformer(transformer);
+ connection = connectionFactory.createConnection();
+ connection.start();
+ return connection;
+ }
+
+ protected abstract AbstractXMLMessageTransformer createTransformer();
+
+ public void testSendObjectMessageReceiveAsTextMessageAndObjectMessage() throws Exception {
+ AbstractXMLMessageTransformer transformer = createTransformer();
+ transformer.setTransformType(XML);
+ connection = createConnection(transformer);
+
+ // lets create the consumers
+ Session objectSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Destination destination = objectSession.createTopic(getClass().getName());
+ MessageConsumer objectConsumer = objectSession.createConsumer(destination);
+
+ Session textSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer textConsumer = textSession.createConsumer(destination);
+ // lets clear the transformer on this consumer so we see the message as
+ // it really is
+ ((ActiveMQMessageConsumer)textConsumer).setTransformer(null);
+
+ // send a message
+ Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = producerSession.createProducer(destination);
+
+ ObjectMessage request = producerSession.createObjectMessage(new SamplePojo("James", "London"));
+ producer.send(request);
+
+ // lets consume it as an object message
+ Message message = objectConsumer.receive(timeout);
+ assertNotNull("Should have received a message!", message);
+ assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage);
+ ObjectMessage objectMessage = (ObjectMessage)message;
+ Object object = objectMessage.getObject();
+ assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo);
+ SamplePojo body = (SamplePojo)object;
+ assertEquals("name", "James", body.getName());
+ assertEquals("city", "London", body.getCity());
+
+ // lets consume it as a text message
+ message = textConsumer.receive(timeout);
+ assertNotNull("Should have received a message!", message);
+ assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage);
+ TextMessage textMessage = (TextMessage)message;
+ String text = textMessage.getText();
+ assertTrue("Text should be non-empty!", text != null && text.length() > 0);
+ System.out.println("Received XML...");
+ System.out.println(text);
+ }
+
+ public void testSendTextMessageReceiveAsObjectMessageAndTextMessage() throws Exception {
+ AbstractXMLMessageTransformer transformer = createTransformer();
+ transformer.setTransformType(OBJECT);
+ connection = createConnection(transformer);
+
+ // lets create the consumers
+ Session textSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Destination destination = textSession.createTopic(getClass().getName());
+ MessageConsumer textConsumer = textSession.createConsumer(destination);
+
+ Session objectSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer objectConsumer = objectSession.createConsumer(destination);
+ // lets clear the transformer on this consumer so we see the message as
+ // it really is
+ ((ActiveMQMessageConsumer)objectConsumer).setTransformer(null);
+
+ // send a message
+ Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = producerSession.createProducer(destination);
+
+ String xmlText = ""
+ + "James"
+ + "London"
+ + "";
+
+ TextMessage request = producerSession.createTextMessage(xmlText);
+ producer.send(request);
+
+ Message message;
+ // lets consume it as a text message
+ message = textConsumer.receive(timeout);
+ assertNotNull("Should have received a message!", message);
+ assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage);
+ TextMessage textMessage = (TextMessage)message;
+ String text = textMessage.getText();
+ assertTrue("Text should be non-empty!", text != null && text.length() > 0);
+
+ // lets consume it as an object message
+ message = objectConsumer.receive(timeout);
+ assertNotNull("Should have received a message!", message);
+ assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage);
+ ObjectMessage objectMessage = (ObjectMessage)message;
+ Object object = objectMessage.getObject();
+ assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo);
+ SamplePojo body = (SamplePojo)object;
+ assertEquals("name", "James", body.getName());
+ assertEquals("city", "London", body.getCity());
+
+ }
+
+ public void testAdaptiveTransform() throws Exception {
+ AbstractXMLMessageTransformer transformer = createTransformer();
+ transformer.setTransformType(ADAPTIVE);
+ connection = createConnection(transformer);
+
+ // lets create the consumers
+ Session adaptiveSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Destination destination = adaptiveSession.createTopic(getClass().getName());
+ MessageConsumer adaptiveConsumer = adaptiveSession.createConsumer(destination);
+
+ Session origSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer origConsumer = origSession.createConsumer(destination);
+ // lets clear the transformer on this consumer so we see the message as
+ // it really is
+ ((ActiveMQMessageConsumer)origConsumer).setTransformer(null);
+
+ // Create producer
+ Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = producerSession.createProducer(destination);
+
+ Message message;
+ ObjectMessage objectMessage;
+ TextMessage textMessage;
+ SamplePojo body;
+ Object object;
+ String text;
+
+ // Send a text message
+ String xmlText = ""
+ + "James"
+ + "London"
+ + "";
+
+ TextMessage txtRequest = producerSession.createTextMessage(xmlText);
+ producer.send(txtRequest);
+
+ // lets consume it as a text message
+ message = adaptiveConsumer.receive(timeout);
+ assertNotNull("Should have received a message!", message);
+ assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage);
+ textMessage = (TextMessage)message;
+ text = textMessage.getText();
+ assertTrue("Text should be non-empty!", text != null && text.length() > 0);
+
+ // lets consume it as an object message
+ message = origConsumer.receive(timeout);
+ assertNotNull("Should have received a message!", message);
+ assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage);
+ objectMessage = (ObjectMessage)message;
+ object = objectMessage.getObject();
+ assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo);
+ body = (SamplePojo)object;
+ assertEquals("name", "James", body.getName());
+ assertEquals("city", "London", body.getCity());
+
+ // Send object message
+ ObjectMessage objRequest = producerSession.createObjectMessage(new SamplePojo("James", "London"));
+ producer.send(objRequest);
+
+ // lets consume it as an object message
+ message = adaptiveConsumer.receive(timeout);
+ assertNotNull("Should have received a message!", message);
+ assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage);
+ objectMessage = (ObjectMessage)message;
+ object = objectMessage.getObject();
+ assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo);
+ body = (SamplePojo)object;
+ assertEquals("name", "James", body.getName());
+ assertEquals("city", "London", body.getCity());
+
+ // lets consume it as a text message
+ message = origConsumer.receive(timeout);
+ assertNotNull("Should have received a message!", message);
+ assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage);
+ textMessage = (TextMessage)message;
+ text = textMessage.getText();
+ assertTrue("Text should be non-empty!", text != null && text.length() > 0);
+ System.out.println("Received XML...");
+ System.out.println(text);
+
+ }
+
+ protected void tearDown() throws Exception {
+ if (connection != null) {
+ connection.close();
+ }
+ }
+
+
+}
diff --git a/activemq-optional/src/test/java/org/apache/activemq/util/oxm/OXMMessageTransformTest.java b/activemq-optional/src/test/java/org/apache/activemq/util/oxm/OXMMessageTransformTest.java
new file mode 100644
index 0000000000..4a0a4a246f
--- /dev/null
+++ b/activemq-optional/src/test/java/org/apache/activemq/util/oxm/OXMMessageTransformTest.java
@@ -0,0 +1,30 @@
+/**
+ * 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.activemq.util.oxm;
+
+import org.springframework.oxm.xstream.XStreamMarshaller;
+
+public class OXMMessageTransformTest extends AbstractXMLMessageTransformerTest {
+
+ protected AbstractXMLMessageTransformer createTransformer() {
+ OXMMessageTransformer transformer = new OXMMessageTransformer();
+ transformer.setMarshaller(new XStreamMarshaller());
+ return transformer;
+ }
+
+}
diff --git a/activemq-optional/src/test/java/org/apache/activemq/util/oxm/XStreamMessageTransformTest.java b/activemq-optional/src/test/java/org/apache/activemq/util/oxm/XStreamMessageTransformTest.java
new file mode 100644
index 0000000000..76fcab3b9c
--- /dev/null
+++ b/activemq-optional/src/test/java/org/apache/activemq/util/oxm/XStreamMessageTransformTest.java
@@ -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.activemq.util.oxm;
+
+import static org.apache.activemq.util.oxm.AbstractXMLMessageTransformer.MessageTransform.ADAPTIVE;
+
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.ActiveMQMessageConsumer;
+import org.apache.activemq.util.xstream.SamplePojo;
+
+import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
+
+public class XStreamMessageTransformTest extends
+ AbstractXMLMessageTransformerTest {
+
+ protected AbstractXMLMessageTransformer createTransformer() {
+ return new XStreamMessageTransformer();
+ }
+
+ public void testStreamDriverTransform() throws Exception {
+ XStreamMessageTransformer transformer = (XStreamMessageTransformer) createTransformer();
+ transformer.setTransformType(ADAPTIVE);
+ transformer.setStreamDriver(new JettisonMappedXmlDriver());
+ connection = createConnection(transformer);
+
+ // lets create the consumers
+ Session adaptiveSession = connection.createSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+ Destination destination = adaptiveSession.createTopic(getClass()
+ .getName());
+ MessageConsumer adaptiveConsumer = adaptiveSession
+ .createConsumer(destination);
+
+ Session origSession = connection.createSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer origConsumer = origSession.createConsumer(destination);
+ // lets clear the transformer on this consumer so we see the message as
+ // it really is
+ ((ActiveMQMessageConsumer) origConsumer).setTransformer(null);
+
+ // Create producer
+ Session producerSession = connection.createSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = producerSession.createProducer(destination);
+
+ Message message;
+ ObjectMessage objectMessage;
+ TextMessage textMessage;
+ SamplePojo body;
+ Object object;
+ String text;
+
+ // Send a text message
+ String xmlText = "{\"org.apache.activemq.util.xstream.SamplePojo\":{\"name\":\"James\",\"city\":\"London\"}}";
+
+ TextMessage txtRequest = producerSession.createTextMessage(xmlText);
+ producer.send(txtRequest);
+
+ // lets consume it as a text message
+ message = adaptiveConsumer.receive(timeout);
+ assertNotNull("Should have received a message!", message);
+ assertTrue("Should be a TextMessage but was: " + message,
+ message instanceof TextMessage);
+ textMessage = (TextMessage) message;
+ text = textMessage.getText();
+ assertTrue("Text should be non-empty!", text != null
+ && text.length() > 0);
+
+ // lets consume it as an object message
+ message = origConsumer.receive(timeout);
+ assertNotNull("Should have received a message!", message);
+ assertTrue("Should be an ObjectMessage but was: " + message,
+ message instanceof ObjectMessage);
+ objectMessage = (ObjectMessage) message;
+ object = objectMessage.getObject();
+ assertTrue("object payload of wrong type: " + object,
+ object instanceof SamplePojo);
+ body = (SamplePojo) object;
+ assertEquals("name", "James", body.getName());
+ assertEquals("city", "London", body.getCity());
+
+ // Send object message
+ ObjectMessage objRequest = producerSession
+ .createObjectMessage(new SamplePojo("James", "London"));
+ producer.send(objRequest);
+
+ // lets consume it as an object message
+ message = adaptiveConsumer.receive(timeout);
+ assertNotNull("Should have received a message!", message);
+ assertTrue("Should be an ObjectMessage but was: " + message,
+ message instanceof ObjectMessage);
+ objectMessage = (ObjectMessage) message;
+ object = objectMessage.getObject();
+ assertTrue("object payload of wrong type: " + object,
+ object instanceof SamplePojo);
+ body = (SamplePojo) object;
+ assertEquals("name", "James", body.getName());
+ assertEquals("city", "London", body.getCity());
+
+ // lets consume it as a text message
+ message = origConsumer.receive(timeout);
+ assertNotNull("Should have received a message!", message);
+ assertTrue("Should be a TextMessage but was: " + message,
+ message instanceof TextMessage);
+ textMessage = (TextMessage) message;
+ text = textMessage.getText();
+ assertTrue("Text should be non-empty!", text != null
+ && text.length() > 0);
+ System.out.println("Received JSON...");
+ System.out.println(text);
+
+ }
+
+}
diff --git a/assembly/pom.xml b/assembly/pom.xml
index c3227b4bae..5e90b610f3 100755
--- a/assembly/pom.xml
+++ b/assembly/pom.xml
@@ -234,6 +234,14 @@
spring-webmvc
false
+
+ org.springframework.ws
+ spring-oxm-tiger
+
+
+ org.codehaus.jettison
+ jettison
+
org.mortbay.jetty
diff --git a/assembly/src/main/descriptors/common-bin.xml b/assembly/src/main/descriptors/common-bin.xml
index 4d073aaee7..da48b47e8c 100644
--- a/assembly/src/main/descriptors/common-bin.xml
+++ b/assembly/src/main/descriptors/common-bin.xml
@@ -202,6 +202,8 @@
xmlpull:xmlpull
org.apache.hadoop.zookeeper:zookeeper
org.codehaus.woodstox:wstx-asl
+ org.springframework.ws:spring-oxm-tiger
+ org.codehaus.jettison:jettison
diff --git a/pom.xml b/pom.xml
index 1d3534c142..1e5519fd05 100755
--- a/pom.xml
+++ b/pom.xml
@@ -62,6 +62,7 @@
1.7.2.2
1.0
6.1.9
+ 1.1
2.5.1
4.4
2.0
@@ -72,6 +73,7 @@
1.3
0.8
1.5.0
+ 1.5.8
1.2.0
2.6.0
2.0.0-beta1
@@ -92,7 +94,7 @@
${groupId}.${artifactId}
- 2.0.10
+ 2.0.9
http://activemq.apache.org
@@ -592,6 +594,11 @@
spring-test
${spring-version}
+
+ org.springframework.ws
+ spring-oxm-tiger
+ ${spring-oxm-version}
+
@@ -817,6 +824,11 @@
1.1
test
+
+ org.codehaus.jettison
+ jettison
+ ${jettison-version}
+
annogen