org.ikasan.framework.event.serialisation
Class DefaultMapMessageEventSerialiser

java.lang.Object
  extended by org.ikasan.framework.event.serialisation.DefaultMapMessageEventSerialiser
All Implemented Interfaces:
JmsMessageEventSerialiser<javax.jms.MapMessage>

public class DefaultMapMessageEventSerialiser
extends Object
implements JmsMessageEventSerialiser<javax.jms.MapMessage>

Default implementation for converting an Event to and from a MapMessage

Author:
Ikasan Development Team

Field Summary
protected static String ATTRIBUTE_PREFIX
           
protected static String EVENT_FIELD_ID
           
protected static String EVENT_FIELD_PRIORITY
           
protected static String EVENT_FIELD_SRC_SYSTEM
           
protected static String EVENT_FIELD_TIMESTAMP
           
protected static String PAYLOAD_CONTENT_SUFFIX
           
protected static String PAYLOAD_ID_SUFFIX
           
protected static String PAYLOAD_PREFIX
           
protected static String PAYLOAD_SPEC_SUFFIX
           
protected static String PAYLOAD_SRC_SYSTEM_SUFFIX
           
protected  PayloadFactory payloadFactory
          Payload factory, only needed for deserialisation
 
Constructor Summary
DefaultMapMessageEventSerialiser()
           
 
Method Summary
protected  Event demapEvent(javax.jms.MapMessage mapMessage, String moduleName, String componentName, List<Payload> payloads, List<String> eventFieldNames)
           
protected  Payload demapPayload(int payloadOrdinal, javax.jms.MapMessage mapMessage, List<String> payloadFieldNames)
           
 Event fromMessage(javax.jms.MapMessage mapMessage, String moduleName, String componentName)
          Deserialises a previously existing Event from a MapMessage
protected  List<List<String>> groupMapNames(Enumeration<String> mapNames)
          Helper method that groups the keys to all map entries into Lists by thier payload, and lists these in payload order, starting with a List of non payload (event level) fields.
 void setPayloadFactory(PayloadFactory payloadFactory)
          Allows the payloadFactory to be supplied.
 javax.jms.MapMessage toMessage(Event event, javax.jms.Session session)
          Serialises an Event to a MapMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAYLOAD_PREFIX

protected static final String PAYLOAD_PREFIX
See Also:
Constant Field Values

ATTRIBUTE_PREFIX

protected static final String ATTRIBUTE_PREFIX
See Also:
Constant Field Values

PAYLOAD_CONTENT_SUFFIX

protected static final String PAYLOAD_CONTENT_SUFFIX
See Also:
Constant Field Values

PAYLOAD_SRC_SYSTEM_SUFFIX

protected static final String PAYLOAD_SRC_SYSTEM_SUFFIX
See Also:
Constant Field Values

PAYLOAD_ID_SUFFIX

protected static final String PAYLOAD_ID_SUFFIX
See Also:
Constant Field Values

PAYLOAD_SPEC_SUFFIX

protected static final String PAYLOAD_SPEC_SUFFIX
See Also:
Constant Field Values

EVENT_FIELD_ID

protected static final String EVENT_FIELD_ID
See Also:
Constant Field Values

EVENT_FIELD_PRIORITY

protected static final String EVENT_FIELD_PRIORITY
See Also:
Constant Field Values

EVENT_FIELD_TIMESTAMP

protected static final String EVENT_FIELD_TIMESTAMP
See Also:
Constant Field Values

EVENT_FIELD_SRC_SYSTEM

protected static final String EVENT_FIELD_SRC_SYSTEM
See Also:
Constant Field Values

payloadFactory

protected PayloadFactory payloadFactory
Payload factory, only needed for deserialisation

Constructor Detail

DefaultMapMessageEventSerialiser

public DefaultMapMessageEventSerialiser()
Method Detail

fromMessage

public Event fromMessage(javax.jms.MapMessage mapMessage,
                         String moduleName,
                         String componentName)
                  throws javax.jms.JMSException,
                         EventDeserialisationException
Description copied from interface: JmsMessageEventSerialiser
Deserialises a previously existing Event from a MapMessage

Specified by:
fromMessage in interface JmsMessageEventSerialiser<javax.jms.MapMessage>
Parameters:
mapMessage - - message to deserialise
moduleName - - name of the module that is reconstituting the Event - this gets set on the Event
componentName - - name of the component/initiator that is reconstituting the Event - this gets set on the Event
Returns:
reconstituted Event
Throws:
javax.jms.JMSException - if we could not deserialise the event
EventDeserialisationException

demapEvent

protected Event demapEvent(javax.jms.MapMessage mapMessage,
                           String moduleName,
                           String componentName,
                           List<Payload> payloads,
                           List<String> eventFieldNames)
                    throws javax.jms.JMSException,
                           EventDeserialisationException
Throws:
javax.jms.JMSException
EventDeserialisationException

demapPayload

protected Payload demapPayload(int payloadOrdinal,
                               javax.jms.MapMessage mapMessage,
                               List<String> payloadFieldNames)
                        throws javax.jms.JMSException,
                               EventDeserialisationException
Throws:
javax.jms.JMSException
EventDeserialisationException

groupMapNames

protected List<List<String>> groupMapNames(Enumeration<String> mapNames)
Helper method that groups the keys to all map entries into Lists by thier payload, and lists these in payload order, starting with a List of non payload (event level) fields. Resultant list should be: entry(0) -> List of all Event level field names entry(1) -> List of all field names beginning with PAYLOAD_0 entry(2) -> List of all field names beginning with PAYLOAD_1 Note: this method will barf if there are non continuous PAYLOAD_X values

Parameters:
mapNames -
Returns:
complex List of Lists as described above

toMessage

public javax.jms.MapMessage toMessage(Event event,
                                      javax.jms.Session session)
                               throws javax.jms.JMSException
Description copied from interface: JmsMessageEventSerialiser
Serialises an Event to a MapMessage

Specified by:
toMessage in interface JmsMessageEventSerialiser<javax.jms.MapMessage>
Parameters:
event - The event to turn into a JMS MapMessage
session - The session
Returns:
Message - ready to go!
Throws:
javax.jms.JMSException
See Also:
JmsMessageEventSerialiser.toMessage(org.ikasan.framework.component.Event, javax.jms.Session)

setPayloadFactory

public void setPayloadFactory(PayloadFactory payloadFactory)
Allows the payloadFactory to be supplied. Only necessary for deserialisation

Parameters:
payloadFactory -


Copyright © 2007-2012 Ikasan. All Rights Reserved.