org.jboss.soa.esb.message.mapping
Class ObjectMapper

java.lang.Object
  extended by org.jboss.soa.esb.message.mapping.ObjectMapper

public class ObjectMapper
extends java.lang.Object

Extracts objects from an ESB message and puts them into a Map, which can be used for later processsing.

Author:
kurt.stam@jboss.com

Field Summary
static java.lang.String BODY_CONTENT
          Name to get the byte[] content
 
Constructor Summary
ObjectMapper()
           
 
Method Summary
 java.util.List<java.lang.Object> createObjectList(Message message, java.util.List<java.lang.String> messageObjectPathList)
          body.myObject will add 'myObject', while body.myObject.mySubObject will create an entry of 'mySubObject'.
 byte[] getBytes(java.io.Serializable object)
          Turns an object into a byte[].
 java.lang.Object getObjectFromMessage(Message message, java.lang.String expression)
          Extracts objects from the message, using a ESB Message Object Path.
 void setObjectOnMessage(Message message, java.lang.String expression, java.lang.Object object)
          Sets an object somewhere on the Message, based on the value of the expression.
 Message setObjectsOnMessage(Message message, java.util.Map<java.lang.Object,java.lang.String> expressionAndObject)
          Set objects on the message using a OGNL expression syntax to describe the position in the message where the object needs to be attached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BODY_CONTENT

public static java.lang.String BODY_CONTENT
Name to get the byte[] content

Constructor Detail

ObjectMapper

public ObjectMapper()
Method Detail

createObjectList

public java.util.List<java.lang.Object> createObjectList(Message message,
                                                         java.util.List<java.lang.String> messageObjectPathList)
                                                  throws ObjectMappingException
body.myObject will add 'myObject', while body.myObject.mySubObject will create an entry of 'mySubObject'. in the returned List.

Parameters:
message - - the message
messageObjectPathList - - the key represents the query to get the object from from the message.
Returns:
List of Objects.
Throws:
ObjectMappingException

setObjectsOnMessage

public Message setObjectsOnMessage(Message message,
                                   java.util.Map<java.lang.Object,java.lang.String> expressionAndObject)
                            throws ObjectMappingException
Set objects on the message using a OGNL expression syntax to describe the position in the message where the object needs to be attached.

Parameters:
message - - the message on which the objects will be placed
expressionAndObject - map containing objects with their expression
Returns:
the message with the objects attached.
Throws:
ObjectMappingException

getObjectFromMessage

public java.lang.Object getObjectFromMessage(Message message,
                                             java.lang.String expression)
                                      throws ObjectMappingException
Extracts objects from the message, using a ESB Message Object Path. The path should follow the syntax: location.objectname.... location : one of [body, property, attachment] objectname: name of the object name, attachments can be named or numbered, so for attachments this can be a number too. : optionally you traverse a bean graph by specifying bean names; examples : properties.Order, gets the property object named "Order" attachment.1, gets the first attachment Object attachment.FirstAttachment, gets the attachment named 'FirstAttachment' attachment.1.Order, calls getOrder() on the attached Object. body.BODY_CONTENT, gets the byte[] of the body. body.Order1.lineitem, obtains the object named "Order1" from the body of the message. Next it will call getLineitem() on this object. More elements can be added to the query to traverse the bean graph.

Parameters:
message - - an ESB Message.
expression - - path to the object.
Returns:
Object obtained from the message.
Throws:
ObjectMappingException

setObjectOnMessage

public void setObjectOnMessage(Message message,
                               java.lang.String expression,
                               java.lang.Object object)
                        throws ObjectMappingException
Sets an object somewhere on the Message, based on the value of the expression. The expression is OGNL based. MVEL is used to do the actual mapping.

Parameters:
message - - on which the object will be placed.
expression - - desribes the place in the Message where the object should be placed
object - - the object which will be attached to the message.
Throws:
ObjectMappingException

getBytes

public byte[] getBytes(java.io.Serializable object)
                throws ObjectMappingException
Turns an object into a byte[].

Parameters:
object - to be serialized to bytes.
Returns:
byte[] representation of the object passed in
Throws:
ObjectMappingException