org.addsimplicity.anicetus.io.jms
Class JsonMessageConverter

java.lang.Object
  extended by org.addsimplicity.anicetus.io.jms.JsonMessageConverter
All Implemented Interfaces:
org.springframework.jms.support.converter.MessageConverter

public class JsonMessageConverter
extends java.lang.Object
implements org.springframework.jms.support.converter.MessageConverter

The JSON message converter translates a telemetry artifact to a JMS text message with the payload formatted as a JSON string. The full object graph is translated to JSON. In addition, JMS headers are set from the telemetry artifact. The headers set are: JMSCorrelationID - Telemetry entity identifier. ReportingNode - The reporting host. OperationName - Set if present. Status - Set if present.

Author:
Dan Pritchett (driveawedge@yahoo.com)

Constructor Summary
JsonMessageConverter()
           
 
Method Summary
 java.lang.Object fromMessage(javax.jms.Message msg)
          Convert a JMS text message with a JSON payload to a telemetry artifact.
 TelemetryDecoder getDecoder()
          Get the current decoder.
 TelemetryEncoder getEncoder()
          Get the current encoder.
 void setDecoder(TelemetryDecoder decoder)
          Set the decoder.
 void setEncoder(TelemetryEncoder translator)
          Set the telmetry encoder.
 javax.jms.Message toMessage(java.lang.Object obj, javax.jms.Session jmsSess)
          Translate the telemetry to a JMS message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonMessageConverter

public JsonMessageConverter()
Method Detail

fromMessage

public java.lang.Object fromMessage(javax.jms.Message msg)
                             throws javax.jms.JMSException,
                                    org.springframework.jms.support.converter.MessageConversionException
Convert a JMS text message with a JSON payload to a telemetry artifact.

Specified by:
fromMessage in interface org.springframework.jms.support.converter.MessageConverter
Parameters:
msg - The JMS text message.
Returns:
the telemetry artifact.
Throws:
javax.jms.JMSException
org.springframework.jms.support.converter.MessageConversionException
See Also:
MessageConverter.fromMessage(javax.jms.Message)

getDecoder

public TelemetryDecoder getDecoder()
Get the current decoder.

Returns:
the current decoder.

getEncoder

public TelemetryEncoder getEncoder()
Get the current encoder.

Returns:
the telemetry encoder.

setDecoder

public void setDecoder(TelemetryDecoder decoder)
Set the decoder. By default the JsonDecoder is used.

Parameters:
decoder - The decoder to use for decoding messages.

setEncoder

public void setEncoder(TelemetryEncoder translator)
Set the telmetry encoder. By default the JsonEncoder is used.

Parameters:
translator - The encoder.

toMessage

public javax.jms.Message toMessage(java.lang.Object obj,
                                   javax.jms.Session jmsSess)
                            throws javax.jms.JMSException,
                                   org.springframework.jms.support.converter.MessageConversionException
Translate the telemetry to a JMS message. A JMS text message is used to contain the translated payload.

Specified by:
toMessage in interface org.springframework.jms.support.converter.MessageConverter
Parameters:
obj - The telemetry artifact.
jsmSess - The JMS session.
Returns:
a text message containing the translated payload.
Throws:
javax.jms.JMSException
org.springframework.jms.support.converter.MessageConversionException
See Also:
MessageConverter.toMessage(java.lang.Object, javax.jms.Session)


Copyright © 2009 Add Simplicity. All Rights Reserved.