org.apache.activemq.util.oxm
Class AbstractXMLMessageTransformer

java.lang.Object
  extended by org.apache.activemq.MessageTransformerSupport
      extended by org.apache.activemq.util.oxm.AbstractXMLMessageTransformer
All Implemented Interfaces:
MessageTransformer
Direct Known Subclasses:
OXMMessageTransformer, XStreamMessageTransformer

public abstract class AbstractXMLMessageTransformer
extends MessageTransformerSupport

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


Nested Class Summary
static class AbstractXMLMessageTransformer.MessageTransform
          Defines the type of transformation.
 
Field Summary
protected  AbstractXMLMessageTransformer.MessageTransform transformType
           
 
Constructor Summary
AbstractXMLMessageTransformer()
           
AbstractXMLMessageTransformer(AbstractXMLMessageTransformer.MessageTransform transformType)
           
 
Method Summary
 javax.jms.Message consumerTransform(javax.jms.Session session, javax.jms.MessageConsumer consumer, javax.jms.Message message)
          Transforms the given message inside the consumer before being dispatched to the client code
 AbstractXMLMessageTransformer.MessageTransform getTransformType()
           
protected abstract  java.lang.String marshall(javax.jms.Session session, javax.jms.ObjectMessage objectMessage)
          Marshalls the Object in the ObjectMessage to a string using XML encoding
protected  javax.jms.TextMessage objectToText(javax.jms.Session session, javax.jms.ObjectMessage objectMessage)
          Transforms an incoming ObjectMessage to an XML encoded TextMessage
 javax.jms.Message producerTransform(javax.jms.Session session, javax.jms.MessageProducer producer, javax.jms.Message message)
          Transforms the given message inside the producer before it is sent to the JMS bus.
 void setTransformType(AbstractXMLMessageTransformer.MessageTransform transformType)
           
protected  javax.jms.ObjectMessage textToObject(javax.jms.Session session, javax.jms.TextMessage textMessage)
          Transforms an incoming XML encoded TextMessage to an ObjectMessage
protected abstract  java.lang.Object unmarshall(javax.jms.Session session, javax.jms.TextMessage textMessage)
          Unmarshalls the XML encoded message in the TextMessage to an Object
 
Methods inherited from class org.apache.activemq.MessageTransformerSupport
copyProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transformType

protected AbstractXMLMessageTransformer.MessageTransform transformType
Constructor Detail

AbstractXMLMessageTransformer

public AbstractXMLMessageTransformer()

AbstractXMLMessageTransformer

public AbstractXMLMessageTransformer(AbstractXMLMessageTransformer.MessageTransform transformType)
Method Detail

consumerTransform

public javax.jms.Message consumerTransform(javax.jms.Session session,
                                           javax.jms.MessageConsumer consumer,
                                           javax.jms.Message message)
                                    throws javax.jms.JMSException
Description copied from interface: MessageTransformer
Transforms the given message inside the consumer before being dispatched to the client code

Throws:
javax.jms.JMSException

producerTransform

public javax.jms.Message producerTransform(javax.jms.Session session,
                                           javax.jms.MessageProducer producer,
                                           javax.jms.Message message)
                                    throws javax.jms.JMSException
Description copied from interface: MessageTransformer
Transforms the given message inside the producer before it is sent to the JMS bus.

Throws:
javax.jms.JMSException

getTransformType

public AbstractXMLMessageTransformer.MessageTransform getTransformType()

setTransformType

public void setTransformType(AbstractXMLMessageTransformer.MessageTransform transformType)

textToObject

protected javax.jms.ObjectMessage textToObject(javax.jms.Session session,
                                               javax.jms.TextMessage textMessage)
                                        throws javax.jms.JMSException
Transforms an incoming XML encoded TextMessage to an ObjectMessage

Parameters:
session - - JMS session currently being used
textMessage - - text message to transform to object message
Returns:
ObjectMessage
Throws:
javax.jms.JMSException

objectToText

protected javax.jms.TextMessage objectToText(javax.jms.Session session,
                                             javax.jms.ObjectMessage objectMessage)
                                      throws javax.jms.JMSException
Transforms an incoming ObjectMessage to an XML encoded TextMessage

Parameters:
session - - JMS session currently being used
objectMessage - - object message to transform to text message
Returns:
XML encoded TextMessage
Throws:
javax.jms.JMSException

marshall

protected abstract java.lang.String marshall(javax.jms.Session session,
                                             javax.jms.ObjectMessage objectMessage)
                                      throws javax.jms.JMSException
Marshalls the Object in the ObjectMessage to a string using XML encoding

Throws:
javax.jms.JMSException

unmarshall

protected abstract java.lang.Object unmarshall(javax.jms.Session session,
                                               javax.jms.TextMessage textMessage)
                                        throws javax.jms.JMSException
Unmarshalls the XML encoded message in the TextMessage to an Object

Throws:
javax.jms.JMSException


Copyright © 2005-2011 FuseSource, Corp.. All Rights Reserved.