org.jboss.soa.esb.listeners.message
Class AbstractMessageComposer<T>

java.lang.Object
  extended by org.jboss.soa.esb.listeners.message.AbstractMessageComposer<T>
All Implemented Interfaces:
MessageComposer<T>
Direct Known Subclasses:
BasicMessageComposer, JBossRemotingGatewayListener.JBossRemotingMessageComposer

public abstract class AbstractMessageComposer<T>
extends java.lang.Object
implements MessageComposer<T>

An abstract MessageComposer implementation, containing a useful default implementation.

Implementations should be threadsafe (stateless) and must contain a public default constructor.

Author:
tom.fennelly@jboss.com

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.soa.esb.listeners.message.MessageComposer
MessageComposer.Factory
 
Constructor Summary
AbstractMessageComposer()
           
 
Method Summary
 Message compose(T messagePayload)
          Compose the message.
 java.lang.Object decompose(Message message, T originalInputMessagePayload)
          Decompose the message.
 ConfigTree getConfiguration()
          Get the composer configuration.
protected  MessagePayloadProxy getPayloadProxy()
           
protected abstract  void populateMessage(Message message, T messagePayload)
          Populate
 void setConfiguration(ConfigTree config)
          Set the composers configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMessageComposer

public AbstractMessageComposer()
Method Detail

setConfiguration

public void setConfiguration(ConfigTree config)
Set the composers configuration.

Specified by:
setConfiguration in interface MessageComposer<T>
Parameters:
config -

getConfiguration

public ConfigTree getConfiguration()
Get the composer configuration.

Returns:
The composer configuration.

compose

public Message compose(T messagePayload)
                throws MessageDeliverException
Compose the message.

Override to implement alternative Message construction strategy.

Specified by:
compose in interface MessageComposer<T>
Parameters:
messagePayload - Message payload to be packaged, or a channel specific container class for the message payload (e.g. a JMS message).
Returns:
ESB aware message instance.
Throws:
MessageDeliverException - Failed to compose message payload for delivery.

getPayloadProxy

protected MessagePayloadProxy getPayloadProxy()

decompose

public java.lang.Object decompose(Message message,
                                  T originalInputMessagePayload)
                           throws MessageDeliverException
Decompose the message.

This implementation simple calls Body.get(ActionUtils.POST_ACTION_DATA)}. Override to implement an alternative Message decomposition strategy.

Specified by:
decompose in interface MessageComposer<T>
Parameters:
message - The message to be decomposed.
originalInputMessagePayload - The original input message payload used to compose this (or ther original) message. The original message can sometimes contain information relevant during the decomposition process. Whether or not this parameter can be null depends on the MessageComposer implementation.
Returns:
The message "task object".
Throws:
MessageDeliverException

populateMessage

protected abstract void populateMessage(Message message,
                                        T messagePayload)
                                 throws MessageDeliverException
Populate

Parameters:
message - The message instance to be populated.
messagePayload - The message payload to to be populated into the message.
Throws:
MessageDeliverException - Unable to populate message with payload.