[jboss-svn-commits] JBL Code SVN: r14045 - in labs/jbossesb/trunk/product/rosetta: src/org/jboss/internal/soa/esb/message/format/serialized and 16 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Aug 6 05:27:58 EDT 2007


Author: mark.little at jboss.com
Date: 2007-08-06 05:27:57 -0400 (Mon, 06 Aug 2007)
New Revision: 14045

Added:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/BytesBodyImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/CommandBodyImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/MapBodyImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/ObjectBodyImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/TextBodyImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/BytesBodyImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/CommandBodyImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/MapBodyImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/ObjectBodyImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/TextBodyImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/BytesBody.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/CommandBody.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/IncompatibleModeException.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/InvalidPayloadException.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/MapBody.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/ObjectBody.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/OperationBody.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/Payload.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/TextBody.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/ContentManager.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/SerializedMessageFactory.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/XMLMessageFactory.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/helper/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/helper/content/
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/helper/content/SerializedContentManagerUnitTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/helper/content/XMLContentManagerUnitTest.java
Removed:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/BytesMessage.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/CommandMessage.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/IncompatibleModeException.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/InvalidPayloadException.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/MapMessage.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/ObjectMessage.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/Payload.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/TextMessage.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload/
Modified:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/SerializedMessagePlugin.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessagePlugin.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/format/MessageFactory.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/format/MessagePlugin.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/format/MessageType.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/ExampleMessagePlugin.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/payload/PayloadUnitTest.java
Log:
http://jira.jboss.com/jira/browse/JBESB-742

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java	2007-08-05 10:44:28 UTC (rev 14044)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -132,6 +132,19 @@
 		return null;
 	}
 
+	public Object createBodyType (Message m, String bodyType)
+	{
+		if (m == null)
+			throw new IllegalArgumentException();
+
+		MessagePlugin plugin = messageFormats.get(m.getType());
+
+		if (plugin != null)
+			return plugin.createBodyType(m, bodyType);
+		else
+			throw new IllegalArgumentException();
+	}
+	
 	private final Hashtable<URI, MessagePlugin> messageFormats = new Hashtable<URI, MessagePlugin>();
 
 }

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java	2007-08-05 10:44:28 UTC (rev 14044)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -35,149 +35,157 @@
 
 public class BodyImpl implements Body, java.io.Serializable
 {
-    private static final long serialVersionUID = 0x0;
+	private static final long serialVersionUID = 0x0;
 
-    public BodyImpl()
-    {
-	_content = null;
-	_objects = new Hashtable<String, Serializable>();
-    }
+	public BodyImpl()
+	{
+		_content = null;
+		_objects = new Hashtable<String, Serializable>();
+	}
 
-    public void setByteArray (byte[] content)
-    {
-	_content = content;
-    }
+	public void setByteArray(byte[] content)
+	{
+		_content = content;
+	}
 
-    public byte[] getByteArray ()
-    {
-	return _content;
-    }
+	public byte[] getByteArray()
+	{
+		return _content;
+	}
 
-    public void setContents (byte[] content)
-    {
-	setByteArray(content);
-    }
+	public void setContents(byte[] content)
+	{
+		setByteArray(content);
+	}
 
-    public byte[] getContents ()
-    {
-	return getByteArray();
-    }
+	public byte[] getContents()
+	{
+		return getByteArray();
+	}
 
-    public void add (Object value)
-    {
-	add(Body.DEFAULT_LOCATION, value);
-    }
+	public void add(Object value)
+	{
+		add(Body.DEFAULT_LOCATION, value);
+	}
 
-    public void add (String name, Object value)
-    {
-	AssertArgument.isNotNull(value, "value");
-	AssertArgument.isNotNull(name, "name");
+	public void add(String name, Object value)
+	{
+		AssertArgument.isNotNull(value, "value");
+		AssertArgument.isNotNull(name, "name");
 
-	if (value instanceof Serializable)
+		if (value instanceof Serializable)
+		{
+			synchronized (_objects)
+			{
+				_objects.put(name, (Serializable) value);
+			}
+		}
+		else
+			throw new IllegalArgumentException("Object must be Serializable.");
+	}
+
+	public Object get()
 	{
-	    synchronized (_objects)
-	    {
-		_objects.put(name, (Serializable) value);
-	    }
+		return get(Body.DEFAULT_LOCATION);
 	}
-	else
-	    throw new IllegalArgumentException("Object must be Serializable.");
-    }
 
-    public Object get ()
-    {
-	return get(Body.DEFAULT_LOCATION);
-    }
+	public Object get(String name)
+	{
+		AssertArgument.isNotNull(name, "name");
 
-    public Object get (String name)
-    {
-	AssertArgument.isNotNull(name, "name");
-	
-	synchronized (_objects)
-	{
-	    return _objects.get(name);
+		synchronized (_objects)
+		{
+			return _objects.get(name);
+		}
 	}
-    }
 
-    public String[] getNames ()
-    {
-	Set<String> keys = _objects.keySet();
-
-	if (keys != null)
+	public String[] getNames()
 	{
-	    String[] toReturn = new String[keys.size()];
+		Set<String> keys = _objects.keySet();
 
-	    return keys.toArray(toReturn);
+		if (keys != null)
+		{
+			String[] toReturn = new String[keys.size()];
+
+			return keys.toArray(toReturn);
+		}
+		else
+			return null;
 	}
-	else
-	    return null;
-    }
 
-    public Object remove (String name)
-    {
-	synchronized (_objects)
+	public Object remove(String name)
 	{
-	    return _objects.remove(name);
+		synchronized (_objects)
+		{
+			return _objects.remove(name);
+		}
 	}
-    }
 
-    public void replace (Body b)
-    {
-	if (b == null)
-	    throw new IllegalArgumentException();
+	public void replace(Body b)
+	{
+		if (b == null)
+			throw new IllegalArgumentException();
 
-	setByteArray(b.getByteArray());
+		setByteArray(b.getByteArray());
 
-	_objects = ((BodyImpl) b)._objects;
-    }
+		_objects = ((BodyImpl) b)._objects;
+	}
 
-    public void merge (Body b)
-    {
-	if (b == null)
-	    throw new IllegalArgumentException();
+	public void merge(Body b)
+	{
+		if (b == null)
+			throw new IllegalArgumentException();
 
-	byte[] toAdd = b.getByteArray();
+		byte[] toAdd = b.getByteArray();
 
-	if ((toAdd != null) && (toAdd.length > 0))
-	{
-	    if ((_content == null) || (_content.length == 0))
-	    {
-		_content = toAdd;
-	    }
-	    else
-	    {
-		int newSize = _content.length + toAdd.length;
-		byte[] buffer = new byte[newSize];
+		if ((toAdd != null) && (toAdd.length > 0))
+		{
+			if ((_content == null) || (_content.length == 0))
+			{
+				_content = toAdd;
+			}
+			else
+			{
+				int newSize = _content.length + toAdd.length;
+				byte[] buffer = new byte[newSize];
 
-		System.arraycopy(_content, 0, buffer, 0, _content.length);
-		System.arraycopy(toAdd, 0, buffer, _content.length,
-			toAdd.length);
+				System.arraycopy(_content, 0, buffer, 0, _content.length);
+				System.arraycopy(toAdd, 0, buffer, _content.length,
+						toAdd.length);
 
-		_content = buffer;
-	    }
+				_content = buffer;
+			}
+		}
 	}
-    }
 
-    public String toString ()
-    {
-	String toReturn = "body: [ ";
+	public String toString()
+	{
+		String toReturn = "body: [ ";
 
-	if (_content != null)
-	    toReturn += "byte[]: " + Util.format(new String(_content));
+		if (_content != null)
+			toReturn += "byte[]: " + Util.format(new String(_content));
 
-	if (_objects != null)
-	{
-	    if (_content != null)
-		toReturn += ", ";
+		if (_objects != null)
+		{
+			if (_content != null)
+				toReturn += ", ";
 
-	    toReturn += "objects: " + _objects.toString();
+			toReturn += "objects: " + _objects.toString();
+		}
+
+		return toReturn + " ]";
 	}
 
-	return toReturn + " ]";
-    }
+	// copy constructor.
+	
+	protected BodyImpl (BodyImpl orig)
+	{
+		_content = orig._content;
+		_objects = orig._objects;
+	}
+	
+	protected byte[] _content;
 
-    private byte[] _content;
+	protected Hashtable<String, Serializable> _objects;
 
-    private Hashtable<String, Serializable> _objects;
-
 }
\ No newline at end of file

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java	2007-08-05 10:44:28 UTC (rev 14044)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -126,6 +126,16 @@
 		+"\n"+_theFault.toString()+"\n"+_theAttachment.toString()+"\n"+_theProperties.toString()+" ]";
 	}
 	
+	// should be a capability on the base interface, but no changes for 4.2 ...
+	
+	void replaceBody (BodyImpl body)
+	{
+		if (body == null)
+			throw new IllegalArgumentException();
+		
+		_theBody = body;
+	}
+	
 	private HeaderImpl _theHeader = new HeaderImpl();
 	private ContextImpl _theContext = new ContextImpl();
 	private BodyImpl _theBody = new BodyImpl();

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/SerializedMessagePlugin.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/SerializedMessagePlugin.java	2007-08-05 10:44:28 UTC (rev 14044)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/SerializedMessagePlugin.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -2,7 +2,13 @@
 
 import java.net.URI;
 
+import org.jboss.internal.soa.esb.message.format.serialized.body.content.BytesBodyImpl;
+import org.jboss.internal.soa.esb.message.format.serialized.body.content.CommandBodyImpl;
+import org.jboss.internal.soa.esb.message.format.serialized.body.content.MapBodyImpl;
+import org.jboss.internal.soa.esb.message.format.serialized.body.content.ObjectBodyImpl;
+import org.jboss.internal.soa.esb.message.format.serialized.body.content.TextBodyImpl;
 import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.body.content.Payload;
 import org.jboss.soa.esb.message.format.MessagePlugin;
 import org.jboss.soa.esb.message.format.MessageType;
 
@@ -45,4 +51,42 @@
 	{
 		return MessageType.JAVA_SERIALIZED;
 	}
+	
+	public Object createBodyType (Message msg, String type)
+	{
+		Object theBody = null;
+		
+		if (type.equals(Payload.BYTES_BODY))
+		{
+			try
+			{
+				theBody = new BytesBodyImpl((BodyImpl) msg.getBody());
+			}
+			catch (Exception ex)
+			{
+				return null;
+			}
+		}
+		
+		if (type.equals(Payload.TEXT_BODY))
+			theBody = new TextBodyImpl((BodyImpl) msg.getBody());
+		
+		if (type.equals(Payload.OBJECT_BODY))
+			theBody = new ObjectBodyImpl((BodyImpl) msg.getBody());
+		
+		if (type.equals(Payload.MAP_BODY))
+			theBody = new MapBodyImpl((BodyImpl) msg.getBody());
+		
+		if (type.equals(Payload.COMMAND_BODY))
+			theBody = new CommandBodyImpl((BodyImpl) msg.getBody());
+		
+		if (theBody != null)
+		{
+			((MessageImpl) msg).replaceBody((BodyImpl) theBody);
+			
+			return theBody;
+		}
+		else
+			return msg.getBody();
+	}
 }

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/BytesBodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/BytesBodyImpl.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/BytesBodyImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,314 @@
+package org.jboss.internal.soa.esb.message.format.serialized.body.content;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.jboss.internal.soa.esb.message.format.serialized.BodyImpl;
+import org.jboss.soa.esb.message.body.content.BytesBody;
+import org.jboss.soa.esb.message.body.content.IncompatibleModeException;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+import org.jboss.soa.esb.message.body.content.Payload;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * The Message payload contains an arbitrary byte array that can be interpreted
+ * by the application as basic Java types.
+ * 
+ * The instance must be placed into either a read mode or write mode. You can
+ * switch between the two modes per instance, but each time you do it will reset
+ * the buffer.
+ * 
+ * When finished, you <i>must</i> flush the instance to the underlying payload
+ * implementation.
+ */
+
+public class BytesBodyImpl extends BodyImpl implements BytesBody
+{
+	private static final long serialVersionUID = 0xdeadbeef;
+
+	private static final int READ_MODE = 0;
+	private static final int WRITE_MODE = 1;
+	private static final int UNSET_MODE = 2;
+	
+	public BytesBodyImpl(BodyImpl payload) throws IOException
+	{
+		super(payload);
+		
+		super.add(Payload.CONTENT_TYPE, Payload.BYTES_BODY);
+	}
+	
+	public boolean readBoolean() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readBoolean();
+	}
+
+	public int readInt() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readInt();
+	}
+
+	public long readLong() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readLong();
+	}
+
+	public char readChar() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readChar();
+	}
+
+	public double readDouble() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readDouble();
+	}
+
+	public float readFloat() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readFloat();
+	}
+
+	public short readShort() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readShort();
+	}
+
+	public String readUTFString() throws IncompatibleModeException,
+			IOException, InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readUTF();
+	}
+
+	public void writeBoolean(boolean b) throws IncompatibleModeException,
+			IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeBoolean(b);
+	}
+
+	public void writeInt(int i) throws IncompatibleModeException, IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeInt(i);
+	}
+
+	public void writeLong(long l) throws IncompatibleModeException, IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeLong(l);
+	}
+
+	public void writeChar(char c) throws IncompatibleModeException, IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeChar(c);
+	}
+
+	public void writeDouble(double d) throws IncompatibleModeException,
+			IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+		
+		_outputStream.writeDouble(d);
+	}
+
+	public void writeFloat(float f) throws IncompatibleModeException,
+			IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeFloat(f);
+	}
+
+	public void writeShort(short s) throws IncompatibleModeException,
+			IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeShort(s);
+	}
+
+	public void writeUTFString(String s) throws IncompatibleModeException,
+			IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeUTF(s);
+	}
+
+	/**
+	 * Place the instance into read mode, so that the information within the
+	 * byte stream can be retrieved.
+	 * 
+	 * @throws IOException
+	 */
+
+	public void readMode() throws IOException
+	{
+		if (super.getByteArray() == null)
+			throw new IOException();
+		
+		_mode = READ_MODE;
+		_inputStream = new ObjectInputStream(new ByteArrayInputStream(super
+				.getByteArray()));
+		_outputStream = null;
+		_byteStream = null;
+	}
+
+	/**
+	 * Plce the instance into write mode, so that information may be placed
+	 * within the byte stream.
+	 * 
+	 * @throws IOException
+	 */
+
+	public void writeMode() throws IOException
+	{
+		_mode = WRITE_MODE;
+		_byteStream = new ByteArrayOutputStream();
+		_outputStream = new ObjectOutputStream(_byteStream);
+		_inputStream = null;
+	}
+
+	/**
+	 * Reset the internal buffer. The mode will remain the same.
+	 * 
+	 * @throws IOException
+	 */
+
+	public void reset() throws IOException
+	{
+		if (_mode == READ_MODE)
+			readMode();
+		else
+		{
+			if (_mode == WRITE_MODE)
+				writeMode();
+		}
+	}
+
+	/**
+	 * Flush the internal byte array through to the payload.
+	 * 
+	 * @throws IOException
+	 */
+
+	public void flush() throws IOException
+	{
+		if (_outputStream != null)
+		{
+			_outputStream.flush();
+			_outputStream.close();
+
+			super.setByteArray(_byteStream.toByteArray());
+		}
+		else
+		{
+			if (_inputStream != null)
+				_inputStream.close();
+		}
+	}
+
+	private final void valid() throws InvalidPayloadException
+	{
+		String type = (String) super.get(Payload.CONTENT_TYPE);
+		
+		if (type == null)
+			throw new InvalidPayloadException();
+		else
+		{
+			if (!type.equals(Payload.BYTES_BODY))
+				throw new InvalidPayloadException();
+		}
+	}
+
+	private int _mode = UNSET_MODE;
+
+	private ObjectOutputStream _outputStream;
+
+	private ObjectInputStream _inputStream;
+
+	private ByteArrayOutputStream _byteStream;
+
+}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/CommandBodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/CommandBodyImpl.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/CommandBodyImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,77 @@
+package org.jboss.internal.soa.esb.message.format.serialized.body.content;
+
+import org.jboss.internal.soa.esb.message.format.serialized.BodyImpl;
+import org.jboss.soa.esb.message.body.content.CommandBody;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+import org.jboss.soa.esb.message.body.content.Payload;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Similar to JMS, the Message payload only contains a serializable Object.
+ */
+
+public class CommandBodyImpl extends BodyImpl implements CommandBody
+{
+	private static final long serialVersionUID = 0xdeadbeef;
+	
+	public CommandBodyImpl (BodyImpl body)
+	{
+		super(body);
+		
+		add(Payload.CONTENT_TYPE, Payload.COMMAND_BODY);
+	}
+	
+	/**
+	 * Add the type element to the Body.
+	 * 
+	 * @param value
+	 *            the String to add.
+	 */
+
+	public void setType (String value)
+	{
+		if (value == null)
+			throw new IllegalArgumentException();
+
+		super.add(COMMAND_TYPE, value);
+	}
+
+	/**
+	 * Obtain the Text from the Body.
+	 * 
+	 * @return the String.
+	 */
+
+	public String getType () throws InvalidPayloadException
+	{
+		try
+		{
+			return (String) super.get(COMMAND_TYPE);
+		}
+		catch (ClassCastException ex)
+		{
+			throw new InvalidPayloadException(ex);
+		}
+	}
+
+}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/MapBodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/MapBodyImpl.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/MapBodyImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,219 @@
+package org.jboss.internal.soa.esb.message.format.serialized.body.content;
+
+import java.io.Serializable;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.jboss.internal.soa.esb.message.format.serialized.BodyImpl;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+import org.jboss.soa.esb.message.body.content.MapBody;
+import org.jboss.soa.esb.message.body.content.Payload;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * The Message payload contains a Map of serializable Objects that can be
+ * inserted and retrieved as a Map.
+ */
+
+public class MapBodyImpl extends BodyImpl implements MapBody
+{
+	private static final long serialVersionUID = 0xdeadbeef;
+
+	public MapBodyImpl (BodyImpl b)
+	{
+		super(b);
+		
+		add(Payload.CONTENT_TYPE, Payload.MAP_BODY);
+	}
+	
+	public void setMap (Map<String, Serializable> payload)
+	{
+		super._objects = new Hashtable<String, Serializable>();
+		
+		super._objects.putAll(payload);
+	}
+	
+	public boolean getBoolean (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((Boolean) get(name)).booleanValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public byte getByte (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((Byte) get(name)).byteValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public byte[] getBytes (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((String) get(name)).getBytes();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public float getFloat (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((Float) get(name)).floatValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public double getDouble (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((Double) get(name)).doubleValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public char getChar (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return (char) ((Byte) get(name)).byteValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public int getInt (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((Integer) get(name)).intValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public long getLong (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((Long) get(name)).longValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public String getString (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return (String) get(name);
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public Enumeration<String> getMapNames ()
+	{
+		return super._objects.keys();
+	}
+	
+	public boolean itemExists (String name)
+	{
+		return (boolean) (get(name) != null);
+	}
+	
+	public void setBoolean (String name, boolean val)
+	{
+		add(name, new Boolean(val));
+	}
+	
+	public void setByte (String name, byte val)
+	{
+		add(name, new Byte(val));
+	}
+	
+	public void setBytes (String name, byte[] val)
+	{
+		add(name, new String(val));
+	}
+	
+	public void setFloat (String name, float val)
+	{
+		add(name, new Double(val));
+	}
+	
+	public void setDouble (String name, double val)
+	{
+		add(name, new Double(val));
+	}
+	
+	public void setChar (String name, char val)
+	{
+		add(name, new Byte((byte) val));
+	}
+	
+	public void setInt (String name, int val)
+	{
+		add(name, new Integer(val));
+	}
+	
+	public void setLong (String name, long val)
+	{
+		add(name, new Long(val));
+	}
+	
+	public void setString (String name, String val)
+	{
+		add(name, val);
+	}
+}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/ObjectBodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/ObjectBodyImpl.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/ObjectBodyImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,88 @@
+package org.jboss.internal.soa.esb.message.format.serialized.body.content;
+
+import java.io.Serializable;
+
+import org.jboss.internal.soa.esb.message.format.serialized.BodyImpl;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+import org.jboss.soa.esb.message.body.content.ObjectBody;
+import org.jboss.soa.esb.message.body.content.Payload;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Similar to JMS, the Message payload only contains a serializable Object.
+ */
+
+public class ObjectBodyImpl extends BodyImpl implements ObjectBody
+{
+	private static final long serialVersionUID = 0xdeadbeef;
+
+	public static final String ELEMENT_NAME = "org.jboss.soa.esb.message.body.object.content";
+	
+	public ObjectBodyImpl (BodyImpl body)
+	{
+		super(body);
+		
+		add(Payload.CONTENT_TYPE, Payload.OBJECT_BODY);
+	}
+	
+	/**
+	 * Add the Object element to the Body.
+	 * 
+	 * @param value
+	 *            the Object to add.
+	 */
+
+	public void setObject(Serializable value)
+	{
+		if (value == null)
+			throw new IllegalArgumentException();
+		else
+			super.add(ELEMENT_NAME, value);
+	}
+
+	/**
+	 * Obtain the Object from the Body.
+	 * 
+	 * @return the Object.
+	 */
+
+	public Serializable getObject() throws InvalidPayloadException
+	{
+		try
+		{
+			Object ret = super.get(ELEMENT_NAME);
+
+			if (ret == null)
+				throw new InvalidPayloadException();
+
+			return (Serializable) ret;
+		}
+		catch (ClassCastException ex)
+		{
+			// not serializable
+
+			throw new InvalidPayloadException(ex);
+		}
+	}
+
+}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/TextBodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/TextBodyImpl.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/TextBodyImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,83 @@
+package org.jboss.internal.soa.esb.message.format.serialized.body.content;
+
+import org.jboss.internal.soa.esb.message.format.serialized.BodyImpl;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+import org.jboss.soa.esb.message.body.content.Payload;
+import org.jboss.soa.esb.message.body.content.TextBody;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Similar to JMS, the Message payload only contains a String.
+ */
+
+public class TextBodyImpl extends BodyImpl implements TextBody
+{
+	public static final String ELEMENT_NAME = "org.jboss.soa.esb.message.payload.text";
+
+	private static final long serialVersionUID = 0xdeadbeef;
+
+	public TextBodyImpl (BodyImpl b)
+	{
+		super(b);
+		
+		add(Payload.CONTENT_TYPE, Payload.TEXT_BODY);
+	}
+	
+	/**
+	 * Add the Text element to the Body.
+	 * 
+	 * @param value
+	 *            the String to add.
+	 */
+
+	public void setText(String value)
+	{
+		if (value == null)
+			throw new IllegalArgumentException();
+
+		super.add(ELEMENT_NAME, value);
+	}
+
+	/**
+	 * Obtain the Text from the Body.
+	 * 
+	 * @return the String.
+	 */
+
+	public String getText() throws InvalidPayloadException
+	{
+		try
+		{
+			Object ret = super.get(ELEMENT_NAME);
+
+			if (ret == null)
+				throw new InvalidPayloadException();
+
+			return (String) ret;
+		}
+		catch (ClassCastException ex)
+		{
+			throw new InvalidPayloadException(ex);
+		}
+	}
+}
\ No newline at end of file

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java	2007-08-05 10:44:28 UTC (rev 14044)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -43,285 +43,293 @@
 
 public class BodyImpl implements Body
 {
-    public static final String BODY_TAG = "Body";
+	public static final String BODY_TAG = "Body";
 
-    public static final String BYTES_TAG = "Bytes";
+	public static final String BYTES_TAG = "Bytes";
 
-    public static final String CONTENT_TAG = "Content";
+	public static final String CONTENT_TAG = "Content";
 
-    public static final String KEY_TAG = "Key";
+	public static final String KEY_TAG = "Key";
 
-    public static final String VALUE_TAG = "Value";
+	public static final String VALUE_TAG = "Value";
 
-    public BodyImpl()
-    {
-	_content = null;
-	_objects = new Hashtable<String, Object>();
-    }
+	public BodyImpl()
+	{
+		_content = null;
+		_objects = new Hashtable<String, Object>();
+	}
 
-    public void add (Object value)
-    {
-	add(Body.DEFAULT_LOCATION, value);
-    }
+	public void add(Object value)
+	{
+		add(Body.DEFAULT_LOCATION, value);
+	}
 
-    public void add (String name, Object value)
-    {
-	AssertArgument.isNotNull(value, "value");
-	AssertArgument.isNotNull(name, "name");
+	public void add(String name, Object value)
+	{
+		AssertArgument.isNotNull(value, "value");
+		AssertArgument.isNotNull(name, "name");
 
-	synchronized (_objects)
+		synchronized (_objects)
+		{
+			_objects.put(name, value);
+		}
+	}
+
+	public Object get()
 	{
-	    _objects.put(name, value);
+		return get(Body.DEFAULT_LOCATION);
 	}
-    }
 
-    public Object get ()
-    {
-	return get(Body.DEFAULT_LOCATION);
-    }
+	public Object get(String name)
+	{
+		AssertArgument.isNotNull(name, "name");
 
-    public Object get (String name)
-    {
-	AssertArgument.isNotNull(name, "name");
-	
-	synchronized (_objects)
-	{
-	    return _objects.get(name);
+		synchronized (_objects)
+		{
+			return _objects.get(name);
+		}
 	}
-    }
 
-    public String[] getNames ()
-    {
-	Set<String> keys = _objects.keySet();
-
-	if (keys != null)
+	public String[] getNames()
 	{
-	    String[] toReturn = new String[keys.size()];
+		Set<String> keys = _objects.keySet();
 
-	    return keys.toArray(toReturn);
+		if (keys != null)
+		{
+			String[] toReturn = new String[keys.size()];
+
+			return keys.toArray(toReturn);
+		}
+		else
+			return null;
 	}
-	else
-	    return null;
-    }
 
-    public Object remove (String name)
-    {
-	synchronized (_objects)
+	public Object remove(String name)
 	{
-	    return _objects.remove(name);
+		synchronized (_objects)
+		{
+			return _objects.remove(name);
+		}
 	}
-    }
 
-    public Element toXML (Element envelope) throws MarshalException
-    {
-	Document doc = envelope.getOwnerDocument();
-	Element bodyElement = doc.createElement(BODY_TAG);
+	public Element toXML(Element envelope) throws MarshalException
+	{
+		Document doc = envelope.getOwnerDocument();
+		Element bodyElement = doc.createElement(BODY_TAG);
 
-	envelope.appendChild(bodyElement);
+		envelope.appendChild(bodyElement);
 
-	if (_content != null)
-	{
-	    Element byteElement = doc.createElement(BYTES_TAG);
+		if (_content != null)
+		{
+			Element byteElement = doc.createElement(BYTES_TAG);
 
-	    byteElement.appendChild(doc.createCDATASection(Base64
-		    .encodeBytes(_content)));
+			byteElement.appendChild(doc.createCDATASection(Base64
+					.encodeBytes(_content)));
 
-	    bodyElement.appendChild(byteElement);
-	}
+			bodyElement.appendChild(byteElement);
+		}
 
-	/*
-         * This would normally be handled by an external adapter.
-         */
+		/*
+		 * This would normally be handled by an external adapter.
+		 */
 
-	Enumeration<String> keys = _objects.keys();
+		Enumeration<String> keys = _objects.keys();
 
-	while (keys.hasMoreElements())
-	{
-	    String key = keys.nextElement();
-	    Object value = _objects.get(key);
+		while (keys.hasMoreElements())
+		{
+			String key = keys.nextElement();
+			Object value = _objects.get(key);
 
-	    Element objElement = doc.createElement(CONTENT_TAG);
-	    Element keyElement = doc.createElement(KEY_TAG);
-	    Element valueElement = doc.createElement(VALUE_TAG);
+			Element objElement = doc.createElement(CONTENT_TAG);
+			Element keyElement = doc.createElement(KEY_TAG);
+			Element valueElement = doc.createElement(VALUE_TAG);
 
-	    keyElement.appendChild(doc.createCDATASection(Base64
-		    .encodeBytes(key.getBytes())));
+			keyElement.appendChild(doc.createCDATASection(Base64
+					.encodeBytes(key.getBytes())));
 
-	    objElement.appendChild(keyElement);
-	    objElement.appendChild(valueElement);
+			objElement.appendChild(keyElement);
+			objElement.appendChild(valueElement);
 
-	    if (MarshalUnmarshalManager.getInstance().marshal(valueElement,
-		    value))
-	    {
-		bodyElement.appendChild(objElement);
-	    }
-	    else
-		throw new MarshalException("Cannot pack object " + key);
+			if (MarshalUnmarshalManager.getInstance().marshal(valueElement,
+					value))
+			{
+				bodyElement.appendChild(objElement);
+			}
+			else
+				throw new MarshalException("Cannot pack object " + key);
+		}
+
+		return bodyElement;
 	}
 
-	return bodyElement;
-    }
+	public void fromXML(Element envelope) throws UnmarshalException
+	{
+		NodeList nl = envelope.getChildNodes();
 
-    public void fromXML (Element envelope) throws UnmarshalException
-    {
-	NodeList nl = envelope.getChildNodes();
+		for (int i = 0; i < nl.getLength(); i++)
+		{
+			/*
+			 * TODO
+			 * 
+			 * In the past, bugs in certain Dom implementations mean that
+			 * getElementsByName did not always work. Still the case? Plus this
+			 * way is quicker.
+			 */
 
-	for (int i = 0; i < nl.getLength(); i++)
-	{
-	    /*
-                 * TODO
-                 * 
-                 * In the past, bugs in certain Dom implementations mean that
-                 * getElementsByName did not always work. Still the case? Plus
-                 * this way is quicker.
-                 */
+			if (nl.item(i).getNodeName().equals(BODY_TAG))
+			{
+				NodeList children = nl.item(i).getChildNodes();
 
-	    if (nl.item(i).getNodeName().equals(BODY_TAG))
-	    {
-		NodeList children = nl.item(i).getChildNodes();
+				for (int j = 0; j < children.getLength(); j++)
+				{
+					Object xxx = children.item(j);
 
-		for (int j = 0; j < children.getLength(); j++)
-		{
-		    Object xxx = children.item(j);
+					if (!(xxx instanceof Element))
+						continue;
 
-		    if (!(xxx instanceof Element))
-			continue;
+					Element node = (Element) xxx;
 
-		    Element node = (Element) xxx;
+					if (node.getNodeName().equals(BYTES_TAG))
+					{
+						CDATASection cdata = (CDATASection) node
+								.getFirstChild();
 
-		    if (node.getNodeName().equals(BYTES_TAG))
-		    {
-			CDATASection cdata = (CDATASection) node
-				.getFirstChild();
+						// support empty byte (null files etc.)
 
-			// support empty byte (null files etc.)
+						if (cdata != null)
+							_content = Base64.decode(cdata.getWholeText());
+						else
+							_content = new byte[0];
+					}
+					else
+					{
+						if (node.getNodeName().equals(CONTENT_TAG))
+						{
+							final NodeList childList = node.getChildNodes();
 
-			if (cdata != null)
-			    _content = Base64.decode(cdata.getWholeText());
-			else
-			    _content = new byte[0];
-		    }
-		    else
-		    {
-			if (node.getNodeName().equals(CONTENT_TAG))
-			{
-			    final NodeList childList = node.getChildNodes();
+							String key = null;
+							Object value = null;
 
-			    String key = null;
-			    Object value = null;
+							for (int k = 0; k < childList.getLength(); k++)
+							{
+								if (childList.item(k).getNodeName().equals(
+										VALUE_TAG))
+									value = MarshalUnmarshalManager
+											.getInstance()
+											.unmarshal(
+													(Element) childList.item(k));
 
-			    for (int k = 0; k < childList.getLength(); k++)
-			    {
-				if (childList.item(k).getNodeName().equals(
-					VALUE_TAG))
-				    value = MarshalUnmarshalManager
-					    .getInstance()
-					    .unmarshal(
-						    (Element) childList.item(k));
+								if (childList.item(k).getNodeName().equals(
+										KEY_TAG))
+								{
+									CDATASection cdata = (CDATASection) childList
+											.item(k).getFirstChild();
 
-				if (childList.item(k).getNodeName().equals(
-					KEY_TAG))
-				{
-				    CDATASection cdata = (CDATASection) childList
-					    .item(k).getFirstChild();
+									key = new String(Base64.decode(cdata
+											.getWholeText()));
+								}
+							}
 
-				    key = new String(Base64.decode(cdata
-					    .getWholeText()));
+							if (value == null)
+								throw new UnmarshalException(
+										"Cannot unpack object "
+												+ node.getNodeName());
+							else
+								_objects.put(key, value);
+						}
+					}
 				}
-			    }
-
-			    if (value == null)
-				throw new UnmarshalException(
-					"Cannot unpack object "
-						+ node.getNodeName());
-			    else
-				_objects.put(key, value);
 			}
-		    }
 		}
-	    }
 	}
-    }
 
-    public void setByteArray (byte[] content)
-    {
-	_content = content;
-    }
+	public void setByteArray(byte[] content)
+	{
+		_content = content;
+	}
 
-    public byte[] getByteArray ()
-    {
-	return _content;
-    }
+	public byte[] getByteArray()
+	{
+		return _content;
+	}
 
-    public void setContents (byte[] content)
-    {
-	setByteArray(content);
-    }
+	public void setContents(byte[] content)
+	{
+		setByteArray(content);
+	}
 
-    public byte[] getContents ()
-    {
-	return getByteArray();
-    }
+	public byte[] getContents()
+	{
+		return getByteArray();
+	}
 
-    public void replace (Body b)
-    {
-	if (b == null)
-	    throw new IllegalArgumentException();
+	public void replace(Body b)
+	{
+		if (b == null)
+			throw new IllegalArgumentException();
 
-	setByteArray(b.getByteArray());
+		setByteArray(b.getByteArray());
 
-	_objects = ((BodyImpl) b)._objects;
-    }
+		_objects = ((BodyImpl) b)._objects;
+	}
 
-    public void merge (Body b)
-    {
-	if (b == null)
-	    throw new IllegalArgumentException();
+	public void merge(Body b)
+	{
+		if (b == null)
+			throw new IllegalArgumentException();
 
-	byte[] toAdd = b.getByteArray();
+		byte[] toAdd = b.getByteArray();
 
-	if ((toAdd != null) && (toAdd.length > 0))
-	{
-	    if ((_content == null) || (_content.length == 0))
-	    {
-		_content = toAdd;
-	    }
-	    else
-	    {
-		int newSize = _content.length + toAdd.length;
-		byte[] buffer = new byte[newSize];
+		if ((toAdd != null) && (toAdd.length > 0))
+		{
+			if ((_content == null) || (_content.length == 0))
+			{
+				_content = toAdd;
+			}
+			else
+			{
+				int newSize = _content.length + toAdd.length;
+				byte[] buffer = new byte[newSize];
 
-		System.arraycopy(_content, 0, buffer, 0, _content.length);
-		System.arraycopy(toAdd, 0, buffer, _content.length,
-			toAdd.length);
+				System.arraycopy(_content, 0, buffer, 0, _content.length);
+				System.arraycopy(toAdd, 0, buffer, _content.length,
+						toAdd.length);
 
-		_content = buffer;
-	    }
+				_content = buffer;
+			}
+		}
+
+		_objects.putAll(((BodyImpl) b)._objects);
 	}
 
-	_objects.putAll(((BodyImpl) b)._objects);
-    }
+	public String toString()
+	{
+		String toReturn = "body: [ ";
 
-    public String toString ()
-    {
-	String toReturn = "body: [ ";
+		if (_content != null)
+			toReturn += "byte[]: " + Util.format(new String(_content));
 
-	if (_content != null)
-	    toReturn += "byte[]: " + Util.format(new String(_content));
+		if (_objects != null)
+		{
+			if (_content != null)
+				toReturn += ", ";
 
-	if (_objects != null)
-	{
-	    if (_content != null)
-		toReturn += ", ";
+			toReturn += "objects: " + _objects.toString();
+		}
 
-	    toReturn += "objects: " + _objects.toString();
+		return toReturn + " ]";
 	}
 
-	return toReturn + " ]";
-    }
+	// copy constructor (almost - doesn't copy, just references).
+	
+	protected BodyImpl (BodyImpl copy)
+	{
+		_content = copy._content;
+		_objects = copy._objects;
+	}
+	
+	protected byte[] _content;
 
-    private byte[] _content;
+	protected Hashtable<String, Object> _objects;
 
-    private Hashtable<String, Object> _objects;
-
 }
\ No newline at end of file

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java	2007-08-05 10:44:28 UTC (rev 14044)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -33,6 +33,9 @@
 import org.jboss.soa.esb.message.Header;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.message.Properties;
+import org.jboss.soa.esb.message.body.content.MapBody;
+import org.jboss.soa.esb.message.body.content.Payload;
+import org.jboss.soa.esb.message.format.MessageFactory;
 import org.jboss.soa.esb.message.format.MessageType;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -193,6 +196,28 @@
 			_theFault.fromXML(envelope);
 			_theAttachment.fromXML(envelope);
 			_theProperties.fromXML(envelope);
+			
+			/*
+			 * Disclaimer: You are not expected to understand this (tm).
+			 * Best way of achieving this without changing any of the public
+			 * interfaces that may already exist.
+			 * 
+			 * TODO: change public interfaces in subsequent major revision.
+			 */
+			
+			String payloadType = Payload.bodyType(this);
+			
+			if ((payloadType != null) && (!payloadType.equals(Payload.RAW_BODY)))
+			{
+				try
+				{
+					_theBody = (BodyImpl) MessageFactory.getInstance().createBodyType(this, payloadType);
+				}
+				catch (Exception ex)
+				{
+					ex.printStackTrace();
+				}
+			}
 		}
 		catch (UnmarshalException ex)
 		{
@@ -206,6 +231,16 @@
 		}
 	}
 	
+	// should be a capability on the base interface, but no changes for 4.2 ...
+	
+	void replaceBody (BodyImpl body)
+	{
+		if (body == null)
+			throw new IllegalArgumentException();
+		
+		_theBody = body;
+	}
+	
 	// TODO add equality operator(s)
 	
 	private HeaderImpl _theHeader = new HeaderImpl();

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessagePlugin.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessagePlugin.java	2007-08-05 10:44:28 UTC (rev 14044)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessagePlugin.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -2,7 +2,13 @@
 
 import java.net.URI;
 
+import org.jboss.internal.soa.esb.message.format.xml.body.content.BytesBodyImpl;
+import org.jboss.internal.soa.esb.message.format.xml.body.content.CommandBodyImpl;
+import org.jboss.internal.soa.esb.message.format.xml.body.content.MapBodyImpl;
+import org.jboss.internal.soa.esb.message.format.xml.body.content.ObjectBodyImpl;
+import org.jboss.internal.soa.esb.message.format.xml.body.content.TextBodyImpl;
 import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.body.content.Payload;
 import org.jboss.soa.esb.message.format.MessagePlugin;
 import org.jboss.soa.esb.message.format.MessageType;
 
@@ -45,4 +51,44 @@
 	{
 		return MessageType.JBOSS_XML;
 	}
+	
+	public Object createBodyType (Message msg, String type)
+	{
+		Object theBody = null;
+		
+		if (type.equals(Payload.BYTES_BODY))
+		{
+			try
+			{
+				theBody = new BytesBodyImpl((BodyImpl) msg.getBody());
+			}
+			catch (Exception ex)
+			{
+				ex.printStackTrace();
+				
+				return null;
+			}
+		}
+		
+		if (type.equals(Payload.TEXT_BODY))
+			theBody = new TextBodyImpl((BodyImpl) msg.getBody());
+		
+		if (type.equals(Payload.OBJECT_BODY))
+			theBody = new ObjectBodyImpl((BodyImpl) msg.getBody());
+		
+		if (type.equals(Payload.MAP_BODY))
+			theBody = new MapBodyImpl((BodyImpl) msg.getBody());
+		
+		if (type.equals(Payload.COMMAND_BODY))
+			theBody = new CommandBodyImpl((BodyImpl) msg.getBody());
+
+		if (theBody != null)
+		{
+			((MessageImpl) msg).replaceBody((BodyImpl) theBody);
+			
+			return theBody;
+		}
+		else
+			return msg.getBody();
+	}
 }

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/BytesBodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/BytesBodyImpl.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/BytesBodyImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,312 @@
+package org.jboss.internal.soa.esb.message.format.xml.body.content;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.jboss.internal.soa.esb.message.format.xml.BodyImpl;
+import org.jboss.soa.esb.message.body.content.BytesBody;
+import org.jboss.soa.esb.message.body.content.IncompatibleModeException;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+import org.jboss.soa.esb.message.body.content.Payload;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * The Message payload contains an arbitrary byte array that can be interpreted
+ * by the application as basic Java types.
+ * 
+ * The instance must be placed into either a read mode or write mode. You can
+ * switch between the two modes per instance, but each time you do it will reset
+ * the buffer.
+ * 
+ * When finished, you <i>must</i> flush the instance to the underlying payload
+ * implementation.
+ */
+
+public class BytesBodyImpl extends BodyImpl implements BytesBody
+{
+	private static final int READ_MODE = 0;
+	private static final int WRITE_MODE = 1;
+	private static final int UNSET_MODE = 2;
+	
+	public BytesBodyImpl(BodyImpl payload) throws IOException
+	{
+		super(payload);
+		
+		super.add(Payload.CONTENT_TYPE, Payload.BYTES_BODY);
+	}
+	
+	public boolean readBoolean() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readBoolean();
+	}
+
+	public int readInt() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readInt();
+	}
+
+	public long readLong() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readLong();
+	}
+
+	public char readChar() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readChar();
+	}
+
+	public double readDouble() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readDouble();
+	}
+
+	public float readFloat() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readFloat();
+	}
+
+	public short readShort() throws IncompatibleModeException, IOException,
+			InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readShort();
+	}
+
+	public String readUTFString() throws IncompatibleModeException,
+			IOException, InvalidPayloadException
+	{
+		if (_mode != READ_MODE)
+			throw new IncompatibleModeException();
+
+		valid();
+
+		return _inputStream.readUTF();
+	}
+
+	public void writeBoolean(boolean b) throws IncompatibleModeException,
+			IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeBoolean(b);
+	}
+
+	public void writeInt(int i) throws IncompatibleModeException, IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeInt(i);
+	}
+
+	public void writeLong(long l) throws IncompatibleModeException, IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeLong(l);
+	}
+
+	public void writeChar(char c) throws IncompatibleModeException, IOException
+	{
+		if (_mode == WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeChar(c);
+	}
+
+	public void writeDouble(double d) throws IncompatibleModeException,
+			IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+		
+		_outputStream.writeDouble(d);
+	}
+
+	public void writeFloat(float f) throws IncompatibleModeException,
+			IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeFloat(f);
+	}
+
+	public void writeShort(short s) throws IncompatibleModeException,
+			IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeShort(s);
+	}
+
+	public void writeUTFString(String s) throws IncompatibleModeException,
+			IOException
+	{
+		if (_mode != WRITE_MODE)
+			throw new IncompatibleModeException();
+
+		_outputStream.writeUTF(s);
+	}
+
+	/**
+	 * Place the instance into read mode, so that the information within the
+	 * byte stream can be retrieved.
+	 * 
+	 * @throws IOException
+	 */
+
+	public void readMode() throws IOException
+	{
+		if (super.getByteArray() == null)
+			throw new IOException();
+		
+		_mode = READ_MODE;
+		_inputStream = new ObjectInputStream(new ByteArrayInputStream(super
+				.getByteArray()));
+		_outputStream = null;
+		_byteStream = null;
+	}
+
+	/**
+	 * Plce the instance into write mode, so that information may be placed
+	 * within the byte stream.
+	 * 
+	 * @throws IOException
+	 */
+
+	public void writeMode() throws IOException
+	{
+		_mode = WRITE_MODE;
+		_byteStream = new ByteArrayOutputStream();
+		_outputStream = new ObjectOutputStream(_byteStream);
+		_inputStream = null;
+	}
+
+	/**
+	 * Reset the internal buffer. The mode will remain the same.
+	 * 
+	 * @throws IOException
+	 */
+
+	public void reset() throws IOException
+	{
+		if (_mode == READ_MODE)
+			readMode();
+		else
+		{
+			if (_mode == WRITE_MODE)
+				writeMode();
+		}
+	}
+
+	/**
+	 * Flush the internal byte array through to the payload.
+	 * 
+	 * @throws IOException
+	 */
+
+	public void flush() throws IOException
+	{
+		if (_outputStream != null)
+		{
+			_outputStream.flush();
+			_outputStream.close();
+
+			super.setByteArray(_byteStream.toByteArray());
+		}
+		else
+		{
+			if (_inputStream != null)
+				_inputStream.close();
+		}
+	}
+
+	private final void valid() throws InvalidPayloadException
+	{
+		String type = (String) super.get(Payload.CONTENT_TYPE);
+		
+		if (type == null)
+			throw new InvalidPayloadException();
+		else
+		{
+			if (!type.equals(Payload.BYTES_BODY))
+				throw new InvalidPayloadException();
+		}
+	}
+
+	private int _mode = UNSET_MODE;
+
+	private ObjectOutputStream _outputStream;
+
+	private ObjectInputStream _inputStream;
+
+	private ByteArrayOutputStream _byteStream;
+
+}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/CommandBodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/CommandBodyImpl.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/CommandBodyImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,76 @@
+package org.jboss.internal.soa.esb.message.format.xml.body.content;
+
+import org.jboss.internal.soa.esb.message.format.xml.BodyImpl;
+import org.jboss.soa.esb.message.body.content.CommandBody;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+import org.jboss.soa.esb.message.body.content.Payload;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Similar to JMS, the Message payload only contains a serializable Object.
+ */
+
+public class CommandBodyImpl extends BodyImpl implements CommandBody
+{
+	
+	public CommandBodyImpl (BodyImpl body)
+	{
+		super(body);
+		
+		add(Payload.CONTENT_TYPE, Payload.COMMAND_BODY);
+	}
+	
+	/**
+	 * Add the type element to the Body.
+	 * 
+	 * @param value
+	 *            the String to add.
+	 */
+
+	public void setType (String value)
+	{
+		if (value == null)
+			throw new IllegalArgumentException();
+
+		super.add(COMMAND_TYPE, value);
+	}
+
+	/**
+	 * Obtain the Text from the Body.
+	 * 
+	 * @return the String.
+	 */
+
+	public String getType () throws InvalidPayloadException
+	{
+		try
+		{
+			return (String) super.get(COMMAND_TYPE);
+		}
+		catch (ClassCastException ex)
+		{
+			throw new InvalidPayloadException(ex);
+		}
+	}
+
+}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/MapBodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/MapBodyImpl.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/MapBodyImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,219 @@
+package org.jboss.internal.soa.esb.message.format.xml.body.content;
+
+import java.io.Serializable;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.jboss.internal.soa.esb.message.format.xml.BodyImpl;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+import org.jboss.soa.esb.message.body.content.MapBody;
+import org.jboss.soa.esb.message.body.content.Payload;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * The Message payload contains a Map of serializable Objects that can be
+ * inserted and retrieved as a Map.
+ */
+
+public class MapBodyImpl extends BodyImpl implements MapBody
+{
+	private static final long serialVersionUID = 0xdeadbeef;
+
+	public MapBodyImpl (BodyImpl b)
+	{
+		super(b);
+		
+		add(Payload.CONTENT_TYPE, Payload.MAP_BODY);
+	}
+	
+	public void setMap (Map<String, Serializable> payload)
+	{
+		super._objects = new Hashtable<String, Object>();
+		
+		super._objects.putAll(payload);
+	}
+	
+	public boolean getBoolean (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((Boolean) get(name)).booleanValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public byte getByte (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((Byte) get(name)).byteValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public byte[] getBytes (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((String) get(name)).getBytes();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public float getFloat (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((Float) get(name)).floatValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public double getDouble (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((Double) get(name)).doubleValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public char getChar (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return (char) ((Byte) get(name)).byteValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public int getInt (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((Integer) get(name)).intValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public long getLong (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return ((Long) get(name)).longValue();
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public String getString (String name) throws InvalidPayloadException
+	{
+		try
+		{
+			return (String) get(name);
+		}
+		catch (Exception ex)
+		{
+			throw new InvalidPayloadException();
+		}
+	}
+	
+	public Enumeration<String> getMapNames ()
+	{
+		return super._objects.keys();
+	}
+	
+	public boolean itemExists (String name)
+	{
+		return (boolean) (get(name) != null);
+	}
+	
+	public void setBoolean (String name, boolean val)
+	{
+		add(name, new Boolean(val));
+	}
+	
+	public void setByte (String name, byte val)
+	{
+		add(name, new Byte(val));
+	}
+	
+	public void setBytes (String name, byte[] val)
+	{
+		add(name, new String(val));
+	}
+	
+	public void setFloat (String name, float val)
+	{
+		add(name, new Double(val));
+	}
+	
+	public void setDouble (String name, double val)
+	{
+		add(name, new Double(val));
+	}
+	
+	public void setChar (String name, char val)
+	{
+		add(name, new Byte((byte) val));
+	}
+	
+	public void setInt (String name, int val)
+	{
+		add(name, new Integer(val));
+	}
+	
+	public void setLong (String name, long val)
+	{
+		add(name, new Long(val));
+	}
+	
+	public void setString (String name, String val)
+	{
+		add(name, val);
+	}
+}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/ObjectBodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/ObjectBodyImpl.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/ObjectBodyImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,88 @@
+package org.jboss.internal.soa.esb.message.format.xml.body.content;
+
+import java.io.Serializable;
+
+import org.jboss.internal.soa.esb.message.format.xml.BodyImpl;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+import org.jboss.soa.esb.message.body.content.ObjectBody;
+import org.jboss.soa.esb.message.body.content.Payload;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Similar to JMS, the Message payload only contains a serializable Object.
+ */
+
+public class ObjectBodyImpl extends BodyImpl implements ObjectBody
+{
+	private static final long serialVersionUID = 0xdeadbeef;
+
+	public static final String ELEMENT_NAME = "org.jboss.soa.esb.message.body.object.content";
+	
+	public ObjectBodyImpl (BodyImpl body)
+	{
+		super(body);
+		
+		add(Payload.CONTENT_TYPE, Payload.OBJECT_BODY);
+	}
+	
+	/**
+	 * Add the Object element to the Body.
+	 * 
+	 * @param value
+	 *            the Object to add.
+	 */
+
+	public void setObject(Serializable value)
+	{
+		if (value == null)
+			throw new IllegalArgumentException();
+		else
+			super.add(ELEMENT_NAME, value);
+	}
+
+	/**
+	 * Obtain the Object from the Body.
+	 * 
+	 * @return the Object.
+	 */
+
+	public Serializable getObject() throws InvalidPayloadException
+	{
+		try
+		{
+			Object ret = super.get(ELEMENT_NAME);
+
+			if (ret == null)
+				throw new InvalidPayloadException();
+
+			return (Serializable) ret;
+		}
+		catch (ClassCastException ex)
+		{
+			// not serializable
+
+			throw new InvalidPayloadException(ex);
+		}
+	}
+
+}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/TextBodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/TextBodyImpl.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/TextBodyImpl.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,83 @@
+package org.jboss.internal.soa.esb.message.format.xml.body.content;
+
+import org.jboss.internal.soa.esb.message.format.xml.BodyImpl;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+import org.jboss.soa.esb.message.body.content.Payload;
+import org.jboss.soa.esb.message.body.content.TextBody;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Similar to JMS, the Message payload only contains a String.
+ */
+
+public class TextBodyImpl extends BodyImpl implements TextBody
+{
+	public static final String ELEMENT_NAME = "org.jboss.soa.esb.message.payload.text";
+
+	private static final long serialVersionUID = 0xdeadbeef;
+
+	public TextBodyImpl (BodyImpl b)
+	{
+		super(b);
+		
+		add(Payload.CONTENT_TYPE, Payload.TEXT_BODY);
+	}
+	
+	/**
+	 * Add the Text element to the Body.
+	 * 
+	 * @param value
+	 *            the String to add.
+	 */
+
+	public void setText(String value)
+	{
+		if (value == null)
+			throw new IllegalArgumentException();
+
+		super.add(ELEMENT_NAME, value);
+	}
+
+	/**
+	 * Obtain the Text from the Body.
+	 * 
+	 * @return the String.
+	 */
+
+	public String getText() throws InvalidPayloadException
+	{
+		try
+		{
+			Object ret = super.get(ELEMENT_NAME);
+
+			if (ret == null)
+				throw new InvalidPayloadException();
+
+			return (String) ret;
+		}
+		catch (ClassCastException ex)
+		{
+			throw new InvalidPayloadException(ex);
+		}
+	}
+}
\ No newline at end of file

Copied: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content (from rev 13995, labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload)

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/BytesBody.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/BytesBody.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/BytesBody.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,123 @@
+package org.jboss.soa.esb.message.body.content;
+
+import java.io.IOException;
+
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.body.content.BytesBody;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * The Message payload contains an arbitrary byte array that can be interpreted
+ * by the application as basic Java types.
+ * 
+ * The instance must be placed into either a read mode or write mode. You can
+ * switch between the two modes per instance, but each time you do it will reset
+ * the buffer.
+ * 
+ * When finished, you <i>must</i> flush the instance to the underlying payload
+ * implementation.
+ */
+
+public interface BytesBody extends Body
+{
+	
+	public boolean readBoolean() throws IncompatibleModeException, IOException,
+			InvalidPayloadException;
+	
+	public int readInt() throws IncompatibleModeException, IOException,
+			InvalidPayloadException;
+	
+	public long readLong() throws IncompatibleModeException, IOException,
+			InvalidPayloadException;
+	
+	public char readChar() throws IncompatibleModeException, IOException,
+			InvalidPayloadException;
+	
+	public double readDouble() throws IncompatibleModeException, IOException,
+			InvalidPayloadException;
+
+	public float readFloat() throws IncompatibleModeException, IOException,
+			InvalidPayloadException;
+
+	public short readShort() throws IncompatibleModeException, IOException,
+			InvalidPayloadException;
+
+	public String readUTFString() throws IncompatibleModeException,
+			IOException, InvalidPayloadException;
+	
+	public void writeBoolean(boolean b) throws IncompatibleModeException,
+			IOException;
+	
+	public void writeInt(int i) throws IncompatibleModeException, IOException;
+
+	public void writeLong(long l) throws IncompatibleModeException, IOException;
+
+	public void writeChar(char c) throws IncompatibleModeException, IOException;
+
+	public void writeDouble(double d) throws IncompatibleModeException,
+			IOException;
+
+	public void writeFloat(float f) throws IncompatibleModeException,
+			IOException;
+	
+	public void writeShort(short s) throws IncompatibleModeException,
+			IOException;
+
+	public void writeUTFString(String s) throws IncompatibleModeException,
+			IOException;
+	
+	/**
+	 * Place the instance into read mode, so that the information within the
+	 * byte stream can be retrieved.
+	 * 
+	 * @throws IOException
+	 */
+
+	public void readMode() throws IOException;
+
+	/**
+	 * Plce the instance into write mode, so that information may be placed
+	 * within the byte stream.
+	 * 
+	 * @throws IOException
+	 */
+
+	public void writeMode() throws IOException;
+
+	/**
+	 * Reset the internal buffer. The mode will remain the same.
+	 * 
+	 * @throws IOException
+	 */
+
+	public void reset() throws IOException;
+
+	/**
+	 * Flush the internal byte array through to the payload.
+	 * 
+	 * @throws IOException
+	 */
+
+	public void flush() throws IOException;
+
+}
\ No newline at end of file

Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/BytesMessage.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload/BytesMessage.java	2007-08-03 12:53:42 UTC (rev 13995)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/BytesMessage.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -1,320 +0,0 @@
-package org.jboss.soa.esb.message.payload;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.payload.BytesMessage;
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated 
- * by the @authors tag. All rights reserved. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author mark.little at jboss.com
- */
-
-/**
- * The Message payload contains an arbitrary byte array that can be interpreted
- * by the application as basic Java types.
- * 
- * The instance must be placed into either a read mode or write mode. You can switch
- * between the two modes per instance, but each time you do it will reset the buffer.
- * 
- * When finished, you <i>must</i> flush the instance to the underlying payload implementation.
- */
-
-public class BytesMessage
-{
-    private static final long serialVersionUID = 0xdeadbeef;
-    
-    public static final String ELEMENT_NAME = "org.jboss.soa.esb.message.payload.bytes";
-    
-    public boolean readBoolean () throws IncompatibleModeException, IOException, InvalidPayloadException
-    {
-	if (!_readMode)
-	    throw new IncompatibleModeException();
-	
-	valid();
-	
-	return _inputStream.readBoolean();
-    }
-
-    public int readInt () throws IncompatibleModeException, IOException, InvalidPayloadException
-    {
-	if (!_readMode)
-	    throw new IncompatibleModeException();
-	
-	valid();
-	
-	return _inputStream.readInt();
-    }
-    
-    public long readLong () throws IncompatibleModeException, IOException, InvalidPayloadException
-    {
-	if (!_readMode)
-	    throw new IncompatibleModeException();
-	
-	valid();
-	
-	return _inputStream.readLong();
-    }
-    
-    public char readChar () throws IncompatibleModeException, IOException, InvalidPayloadException
-    {
-	if (!_readMode)
-	    throw new IncompatibleModeException();
-	
-	valid();
-	
-	return _inputStream.readChar();
-    }
-    
-    public double readDouble () throws IncompatibleModeException, IOException, InvalidPayloadException
-    {
-	if (!_readMode)
-	    throw new IncompatibleModeException();
-	
-	valid();
-	
-	return _inputStream.readDouble();
-    }
-    
-    public float readFloat () throws IncompatibleModeException, IOException, InvalidPayloadException
-    {
-	if (!_readMode)
-	    throw new IncompatibleModeException();
-	
-	valid();
-	
-	return _inputStream.readFloat();
-    }
-    
-    public short readShort () throws IncompatibleModeException, IOException, InvalidPayloadException
-    {
-	if (!_readMode)
-	    throw new IncompatibleModeException();
-	
-	valid();
-	
-	return _inputStream.readShort();
-    }
-    
-    public String readUTFString () throws IncompatibleModeException, IOException, InvalidPayloadException
-    {
-	if (!_readMode)
-	    throw new IncompatibleModeException();
-	
-	valid();
-	
-	return _inputStream.readUTF();
-    }
-    
-    public void writeBoolean (boolean b) throws IncompatibleModeException, IOException
-    {
-	if (_readMode)
-	    throw new IncompatibleModeException();
-	
-	init();
-	
-	_outputStream.writeBoolean(b);
-    }
-    
-    public void writeInt (int i) throws IncompatibleModeException, IOException
-    {
-	if (_readMode)
-	    throw new IncompatibleModeException();
-	
-	init();
-	
-	_outputStream.writeInt(i);
-    }
-    
-    public void writeLong (long l) throws IncompatibleModeException, IOException
-    {
-	if (_readMode)
-	    throw new IncompatibleModeException();
-	
-	init();
-	
-	_outputStream.writeLong(l);
-    }
-    
-    public void writeChar (char c) throws IncompatibleModeException, IOException
-    {
-	if (_readMode)
-	    throw new IncompatibleModeException();
-	
-	init();
-	
-	_outputStream.writeChar(c);
-    }
-    
-    public void writeDouble (double d) throws IncompatibleModeException, IOException
-    {
-	if (_readMode)
-	    throw new IncompatibleModeException();
-	
-	init();
-	
-	_outputStream.writeDouble(d);
-    }
-    
-    public void writeFloat (float f) throws IncompatibleModeException, IOException
-    {
-	if (_readMode)
-	    throw new IncompatibleModeException();
-	
-	init();
-	
-	_outputStream.writeFloat(f);
-    }
-    
-    public void writeShort (short s) throws IncompatibleModeException, IOException
-    {
-	if (_readMode)
-	    throw new IncompatibleModeException();
-	
-	init();
-	
-	_outputStream.writeShort(s);
-    }
-    
-    public void writeUTFString (String s) throws IncompatibleModeException, IOException
-    {
-	if (_readMode)
-	    throw new IncompatibleModeException();
-	
-	init();
-	
-	_outputStream.writeUTF(s);
-    }
-    
-    /**
-     * Place the instance into read mode, so that the information within the
-     * byte stream can be retrieved.
-     * 
-     * @throws IOException
-     */
-    
-    public void readMode () throws IOException
-    {
-	flush();
-	
-	_readMode = true;
-	_inputStream = new ObjectInputStream(new ByteArrayInputStream(_payload.getByteArray()));
-	_outputStream = null;
-	_byteStream = null;
-    }
-    
-    /**
-     * Plce the instance into write mode, so that information may be placed within
-     * the byte stream.
-     * 
-     * @throws IOException
-     */
-    
-    public void writeMode () throws IOException
-    {
-	flush();
-	
-	_readMode = false;
-	_byteStream = new ByteArrayOutputStream();
-	_outputStream = new ObjectOutputStream(_byteStream);
-	_inputStream = null;
-    }
-    
-    /**
-     * Reset the internal buffer. The mode will remain the same.
-     * @throws IOException
-     */
-    
-    public void reset () throws IOException
-    {
-	if (_readMode)
-	    readMode();
-	else
-	    writeMode();
-    }
-    
-    /**
-     * Flush the internal byte array through to the payload.
-     * 
-     * @throws IOException
-     */
-    
-    public void flush () throws IOException
-    {
-	if (_outputStream != null)
-	{
-	    _outputStream.flush();
-	    _outputStream.close();
-	    
-	    _payload.setByteArray(_byteStream.toByteArray());
-	}
-	else
-	{
-	    if (_inputStream != null)
-		_inputStream.close();
-	}
-    }
-    
-    public static final boolean isBytesMessage (Body payload)
-    {
-	try
-	{
-	    return (payload.get(ELEMENT_NAME) != null);
-	}
-	catch (Exception ex)
-	{
-	    return false;
-	}
-    }
-    
-    BytesMessage (Body payload) throws IOException
-    {
-	_payload = payload;
-	
-	if (payload.getByteArray() != null)
-	    readMode();
-	else
-	    writeMode();
-    }
-	
-    private final void init ()
-    {
-	if (_payload.get(ELEMENT_NAME) == null)
-	    _payload.add(ELEMENT_NAME, true);
-    }
-    
-    private final void valid () throws InvalidPayloadException
-    {
-	if (_payload.get(ELEMENT_NAME) == null)
-	    throw new InvalidPayloadException();
-    }
-    
-    private Body _payload;
-    
-    private boolean _readMode;
-    
-    private ObjectOutputStream _outputStream;
-    private ObjectInputStream _inputStream;
-    private ByteArrayOutputStream _byteStream;
-
-}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/CommandBody.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/CommandBody.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/CommandBody.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,53 @@
+package org.jboss.soa.esb.message.body.content;
+
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.body.content.CommandBody;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Similar to JMS, the Message payload only contains a serializable Object.
+ */
+
+public interface CommandBody extends Body
+{
+	public static final String COMMAND_TYPE = "org.jboss.soa.esb.message.payload.command.type";
+
+	/**
+	 * Add the type element to the Body.
+	 * 
+	 * @param value
+	 *            the String to add.
+	 */
+
+	public void setType (String value);
+
+	/**
+	 * Obtain the Text from the Body.
+	 * 
+	 * @return the String.
+	 */
+
+	public String getType () throws InvalidPayloadException;
+
+}
\ No newline at end of file

Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/CommandMessage.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload/CommandMessage.java	2007-08-03 12:53:42 UTC (rev 13995)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/CommandMessage.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -1,133 +0,0 @@
-package org.jboss.soa.esb.message.payload;
-
-import java.io.Serializable;
-
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.payload.InvalidPayloadException;
-import org.jboss.soa.esb.message.payload.CommandMessage;
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated 
- * by the @authors tag. All rights reserved. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author mark.little at jboss.com
- */
-
-/**
- * Similar to JMS, the Message payload only contains a serializable Object.
- */
-
-public class CommandMessage
-{
-	public static final String ELEMENT_NAME = "org.jboss.soa.esb.message.payload.command";
-
-	public static final String COMMAND_TYPE = "org.jboss.soa.esb.message.payload.command.type";
-
-	private static final long serialVersionUID = 0xdeadbeef;
-
-	/**
-	 * Add the Object element to the Body.
-	 * 
-	 * @param value
-	 *            the Object to add.
-	 */
-
-	public void setObject(Serializable value)
-	{
-		if (value == null)
-			throw new IllegalArgumentException();
-		else
-			_payload.add(ELEMENT_NAME, value);
-	}
-
-	/**
-	 * Obtain the Object from the Body.
-	 * 
-	 * @return the Object.
-	 */
-
-	public Serializable getObject() throws InvalidPayloadException
-	{
-		try
-		{
-			Object ret = _payload.get(ELEMENT_NAME);
-
-			if (ret == null)
-				throw new InvalidPayloadException();
-
-			return (Serializable) ret;
-		}
-		catch (ClassCastException ex)
-		{
-			// not serializable
-
-			throw new InvalidPayloadException(ex);
-		}
-	}
-
-	/**
-	 * Add the type element to the Body.
-	 * 
-	 * @param value
-	 *            the String to add.
-	 */
-
-	public void setType (String value)
-	{
-		if (value == null)
-			throw new IllegalArgumentException();
-
-		_payload.add(COMMAND_TYPE, value);
-	}
-
-	/**
-	 * Obtain the Text from the Body.
-	 * 
-	 * @return the String.
-	 */
-
-	public String getType () throws InvalidPayloadException
-	{
-		try
-		{
-			return (String) _payload.get(COMMAND_TYPE);
-		}
-		catch (ClassCastException ex)
-		{
-			throw new InvalidPayloadException(ex);
-		}
-	}
-
-	public static final boolean isCommandMessage(Body payload)
-	{
-		try
-		{
-			return (payload.get(ELEMENT_NAME) != null);
-		}
-		catch (Exception ex)
-		{
-			return false;
-		}
-	}
-
-	CommandMessage(Body payload)
-	{
-		_payload = payload;
-	}
-
-	private Body _payload;
-}
\ No newline at end of file

Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/IncompatibleModeException.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload/IncompatibleModeException.java	2007-08-03 12:53:42 UTC (rev 13995)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/IncompatibleModeException.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -1,51 +0,0 @@
-package org.jboss.soa.esb.message.payload;
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated 
- * by the @authors tag. All rights reserved. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author mark.little at jboss.com
- */
-
-/**
- * Thrown if trying to read on a write-only buffer, or vice versa.
- */
-
-public class IncompatibleModeException extends Exception
-{
-	private static final long serialVersionUID = 0xE124;
-	
-	public IncompatibleModeException()
-	{
-		super();
-	}
-
-	public IncompatibleModeException(String s)
-	{
-		super(s);
-	}
-
-	public IncompatibleModeException (Exception ex)
-	{
-		super(ex);
-	}
-
-	public IncompatibleModeException (String message, Exception ex)
-	{
-		super(ex);
-	}
-}

Copied: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/IncompatibleModeException.java (from rev 14044, labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload/IncompatibleModeException.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/IncompatibleModeException.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/IncompatibleModeException.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,51 @@
+package org.jboss.soa.esb.message.body.content;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Thrown if trying to read on a write-only buffer, or vice versa.
+ */
+
+public class IncompatibleModeException extends Exception
+{
+	private static final long serialVersionUID = 0xE124;
+	
+	public IncompatibleModeException()
+	{
+		super();
+	}
+
+	public IncompatibleModeException(String s)
+	{
+		super(s);
+	}
+
+	public IncompatibleModeException (Exception ex)
+	{
+		super(ex);
+	}
+
+	public IncompatibleModeException (String message, Exception ex)
+	{
+		super(ex);
+	}
+}

Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/InvalidPayloadException.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload/InvalidPayloadException.java	2007-08-03 12:53:42 UTC (rev 13995)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/InvalidPayloadException.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -1,51 +0,0 @@
-package org.jboss.soa.esb.message.payload;
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated 
- * by the @authors tag. All rights reserved. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author mark.little at jboss.com
- */
-
-/**
- * Thrown if unmarshalling fails.
- */
-
-public class InvalidPayloadException extends Exception
-{
-	private static final long serialVersionUID = 0xE124;
-	
-	public InvalidPayloadException()
-	{
-		super();
-	}
-
-	public InvalidPayloadException(String s)
-	{
-		super(s);
-	}
-
-	public InvalidPayloadException (Exception ex)
-	{
-		super(ex);
-	}
-
-	public InvalidPayloadException (String message, Exception ex)
-	{
-		super(ex);
-	}
-}

Copied: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/InvalidPayloadException.java (from rev 14044, labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload/InvalidPayloadException.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/InvalidPayloadException.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/InvalidPayloadException.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,51 @@
+package org.jboss.soa.esb.message.body.content;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Thrown if unmarshalling fails.
+ */
+
+public class InvalidPayloadException extends Exception
+{
+	private static final long serialVersionUID = 0xE124;
+	
+	public InvalidPayloadException()
+	{
+		super();
+	}
+
+	public InvalidPayloadException(String s)
+	{
+		super(s);
+	}
+
+	public InvalidPayloadException (Exception ex)
+	{
+		super(ex);
+	}
+
+	public InvalidPayloadException (String message, Exception ex)
+	{
+		super(ex);
+	}
+}

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/MapBody.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/MapBody.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/MapBody.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,65 @@
+package org.jboss.soa.esb.message.body.content;
+
+import java.io.Serializable;
+import java.util.Enumeration;
+import java.util.Map;
+
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+import org.jboss.soa.esb.message.body.content.MapBody;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * The Message payload contains a Map of serializable Objects that can be
+ * inserted and retrieved as a Map.
+ */
+
+public interface MapBody extends Body
+{
+	public void setMap (Map<String, Serializable> payload);
+	
+	public boolean getBoolean (String name) throws InvalidPayloadException;
+	public byte getByte (String name) throws InvalidPayloadException;
+	public byte[] getBytes (String name) throws InvalidPayloadException;
+	public float getFloat (String name) throws InvalidPayloadException;
+	public double getDouble (String name) throws InvalidPayloadException;
+	public char getChar (String name) throws InvalidPayloadException;
+	public int getInt (String name) throws InvalidPayloadException;
+	public long getLong (String name) throws InvalidPayloadException;
+	public String getString (String name) throws InvalidPayloadException;
+	
+	public Enumeration<String> getMapNames ();
+	
+	public boolean itemExists (String name);
+	
+	public void setBoolean (String name, boolean val);
+	public void setByte (String name, byte val);
+	public void setBytes (String name, byte[] val);
+	public void setFloat (String name, float val);
+	public void setDouble (String name, double val);
+	public void setChar (String name, char val);
+	public void setInt (String name, int val);
+	public void setLong (String name, long val);
+	public void setString (String name, String val);
+
+}
\ No newline at end of file

Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/MapMessage.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload/MapMessage.java	2007-08-03 12:53:42 UTC (rev 13995)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/MapMessage.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -1,107 +0,0 @@
-package org.jboss.soa.esb.message.payload;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.payload.InvalidPayloadException;
-import org.jboss.soa.esb.message.payload.MapMessage;
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated 
- * by the @authors tag. All rights reserved. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author mark.little at jboss.com
- */
-
-/**
- * The Message payload contains a Map of serializable Objects that can be
- * inserted and retrieved as a Map.
- */
-
-public class MapMessage
-{
-    private static final long serialVersionUID = 0xdeadbeef;
-
-    public static final String ELEMENT_NAME = "org.jboss.soa.esb.message.payload.map";
-    
-    public void setMap (Map<String, Serializable> map)
-    {
-	if (map == null)
-	    throw new IllegalArgumentException();
-
-	_payload.add(ELEMENT_NAME, map.size());
-	
-	Set<String> keys = map.keySet();
-	Iterator<String> iter = keys.iterator();
-
-	while (iter.hasNext())
-	{
-	    String key = iter.next();
-	    Serializable object = map.get(key);
-
-	    _payload.add(key, object);
-	}
-    }
-
-    public Map<String, Serializable> getMap () throws InvalidPayloadException
-    {
-	if (_payload.get(ELEMENT_NAME) == null)
-	    throw new InvalidPayloadException();
-	
-	HashMap<String, Serializable> map = new HashMap<String, Serializable>();
-	String[] names = _payload.getNames();
-	
-	// assume all objects in message are from the map
-	
-	try
-	{
-        	for (int i = 0; i < names.length; i++)
-        	{
-        	    map.put(names[i], (Serializable) _payload.get(names[i]));
-        	}
-	}
-	catch (ClassCastException ex)
-	{
-	    throw new InvalidPayloadException(ex);
-	}
-	
-	return map;
-    }
-    
-    public static final boolean isMapMessage (Body payload)
-    {
-	try
-	{
-	    return (payload.get(ELEMENT_NAME) != null);
-	}
-	catch (Exception ex)
-	{
-	    return false;
-	}
-    }
-    
-    MapMessage (Body payload)
-    {
-	_payload = payload;
-    }
-    
-    private Body _payload;
-}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/ObjectBody.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/ObjectBody.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/ObjectBody.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,51 @@
+package org.jboss.soa.esb.message.body.content;
+
+import java.io.Serializable;
+
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+import org.jboss.soa.esb.message.body.content.ObjectBody;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Similar to JMS, the Message payload only contains a serializable Object.
+ */
+
+public interface ObjectBody extends Body
+{
+    /**
+     * Add the Object element to the Body.
+     * 
+     * @param value the Object to add.
+     */
+    
+    public void setObject (Serializable value);
+ 
+    /**
+     * Obtain the Object from the Body.
+     * 
+     * @return the Object.
+     */
+    
+    public Serializable getObject () throws InvalidPayloadException;
+}
\ No newline at end of file

Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/ObjectMessage.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload/ObjectMessage.java	2007-08-03 12:53:42 UTC (rev 13995)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/ObjectMessage.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -1,97 +0,0 @@
-package org.jboss.soa.esb.message.payload;
-
-import java.io.Serializable;
-
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.payload.InvalidPayloadException;
-import org.jboss.soa.esb.message.payload.ObjectMessage;
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated 
- * by the @authors tag. All rights reserved. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author mark.little at jboss.com
- */
-
-/**
- * Similar to JMS, the Message payload only contains a serializable Object.
- */
-
-public class ObjectMessage
-{
-    public static final String ELEMENT_NAME = "org.jboss.soa.esb.message.payload.object";
-    
-    private static final long serialVersionUID = 0xdeadbeef;
-    
-    /**
-     * Add the Object element to the Body.
-     * 
-     * @param value the Object to add.
-     */
-    
-    public void setObject (Serializable value)
-    {
-	if (value == null)
-	    throw new IllegalArgumentException();
-	else
-	    _payload.add(ELEMENT_NAME, value);
-    }
-
-    /**
-     * Obtain the Object from the Body.
-     * 
-     * @return the Object.
-     */
-    
-    public Serializable getObject () throws InvalidPayloadException
-    {
-	try
-	{
-	    Object ret = _payload.get(ELEMENT_NAME);
-	    
-	    if (ret == null)
-		throw new InvalidPayloadException();
-	    
-	    return (Serializable) ret;
-	}
-	catch (ClassCastException ex)
-	{
-	    // not serializable
-	    
-	    throw new InvalidPayloadException(ex);
-	}
-    }
-    
-    public static final boolean isObjectMessage (Body payload)
-    {
-	try
-	{
-	    return (payload.get(ELEMENT_NAME) != null);
-	}
-	catch (Exception ex)
-	{
-	    return false;
-	}
-    }
-
-    ObjectMessage (Body payload)
-    {
-	_payload = payload;
-    }
-    
-    private Body _payload;
-}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/OperationBody.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/OperationBody.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/OperationBody.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,62 @@
+package org.jboss.soa.esb.message.body.content;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Enumeration;
+import java.util.Map;
+
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.body.content.OperationBody;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * This type of Body can be used when you want to convey a more format
+ * opcode/parameter approach to your Messages.
+ */
+
+// TODO: complete the implementation!
+
+public interface OperationBody extends Body
+{
+	/**
+	 * Add the type element to the Body.
+	 * 
+	 * @param value
+	 *            the String to add.
+	 */
+
+	public void setOperation (URI opcode, Map<String, Serializable> parameters);
+
+	/**
+	 * Obtain the Text from the Body.
+	 * 
+	 * @return the String.
+	 */
+
+	public Map<String, Serializable> getOperation (URI opcode) throws InvalidPayloadException;
+
+	public Enumeration<URI> operations () throws InvalidPayloadException;
+	
+	public boolean operationIsPresent (URI opcode) throws InvalidPayloadException;
+}
\ No newline at end of file

Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/Payload.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload/Payload.java	2007-08-03 12:53:42 UTC (rev 13995)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/Payload.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -1,157 +0,0 @@
-package org.jboss.soa.esb.message.payload;
-
-import java.io.IOException;
-
-import org.jboss.soa.esb.message.Message;
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated 
- * by the @authors tag. All rights reserved. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author mark.little at jboss.com
- */
-
-/**
- * Different message formats represent views on the underlying Message Body,
- * i.e., payload. They do not change how the content is represented on the wire,
- * only how it can be more easily interpreted within the application. These are
- * essentially helper classes.
- */
-
-public class Payload
-{
-
-    public static final Object getPayload (Message msg)
-    {
-	if ((msg == null) || (msg.getBody() == null))
-	    return null;
-	
-	if (CommandMessage.isCommandMessage(msg.getBody()))
-	    return getAsControlMessage(msg);
-	
-	if (MapMessage.isMapMessage(msg.getBody()))
-	    return getAsMapMessage(msg);
-	
-	if (ObjectMessage.isObjectMessage(msg.getBody()))
-	    return getAsObjectMessage(msg);
-	
-	if (TextMessage.isTextMessage(msg.getBody()))
-	    return getAsTextMessage(msg);
-	
-	if (BytesMessage.isBytesMessage(msg.getBody()))
-	{
-	    try
-	    {
-		return getAsBytesMessage(msg, true);
-	    }
-	    catch (Exception ex)
-	    {
-		ex.printStackTrace();
-	    }
-	}
-	
-	return null;
-    }
-    
-    /**
-     * View and manipulate the payload as a Control.
-     * 
-     * @param msg the message.
-     * @return the Control view.
-     */
-    
-    public static final CommandMessage getAsControlMessage (Message msg)
-    {
-	if ((msg == null) || (msg.getBody() == null))
-	    return null;
-	else
-	    return new CommandMessage(msg.getBody());
-    }
-
-    /**
-     * View and manipulate the payload as an Object map.
-     * 
-     * @param msg the message.
-     * @return the MapMessage view.
-     */
-    
-    public static final MapMessage getAsMapMessage (Message msg)
-    {
-	if ((msg == null) || (msg.getBody() == null))
-	    return null;
-	else
-	    return new MapMessage(msg.getBody());
-    }
-    
-    /**
-     * View and manipulate the payload as an Object.
-     * 
-     * @param msg the message.
-     * @return the ObjectMessage view.
-     */
-    
-    public static final ObjectMessage getAsObjectMessage (Message msg)
-    {
-	if ((msg == null) || (msg.getBody() == null))
-	    return null;
-	else
-	    return new ObjectMessage(msg.getBody());
-    }
-    
-    /**
-     * View and manipulate the payload as Text.
-     * 
-     * @param msg the message.
-     * @return the TextMessage view.
-     */
-    
-    public static final TextMessage getAsTextMessage (Message msg)
-    {
-	if ((msg == null) || (msg.getBody() == null))
-	    return null;
-	else
-	    return new TextMessage(msg.getBody());
-    }
-    
-    /**
-     * View and manipulate the payload as a structured byte stream. When reading
-     * the BytesMessage, the byte array must already have been set on the Body or
-     * the instance is placed into a write-only mode.
-     * 
-     * @param msg the message.
-     * @param boolean <i>true</i> if the instance will be read from, <i>false</i> otherwise.
-     * @return the BytesMessage view.
-     */
-    
-    public static final BytesMessage getAsBytesMessage (Message msg, boolean readMode) throws IOException
-    {
-	if ((msg == null) || (msg.getBody() == null))
-	    return null;
-	else
-	{
-	    BytesMessage payload = new BytesMessage(msg.getBody());
-	    
-	    if (readMode)
-		payload.readMode();
-	    else
-		payload.writeMode();
-	    
-	    return payload;
-	}
-    }
-
-}
\ No newline at end of file

Copied: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/Payload.java (from rev 14044, labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload/Payload.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/Payload.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/Payload.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,129 @@
+package org.jboss.soa.esb.message.body.content;
+
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Different message formats represent views on the underlying Message Body,
+ * i.e., payload. They do not change how the content is represented on the wire,
+ * only how it can be more easily interpreted within the application. These are
+ * essentially helper classes.
+ * 
+ * In order to use, first create your Message (via the factory) and then pass it
+ * to the appropriate method of this class. Use the returned Body type to then
+ * populate your Message before sending it. At the receiver, you can get the type by
+ * calling bodyType and then use the right method to get the Body type back for
+ * use. If you try to use it as the wrong type, you'll get an exception.
+ */
+
+public class Payload
+{
+	public static final String CONTENT_TYPE = "org.jboss.soa.esb.message.body.content";
+	
+	public static final String RAW_BODY = "raw";
+	public static final String BYTES_BODY = "bytes";
+	public static final String MAP_BODY = "map";
+	public static final String COMMAND_BODY = "command";
+	public static final String OBJECT_BODY = "object";
+	public static final String TEXT_BODY = "text";
+	
+	public static final String bodyType (Message msg)
+	{
+		if ((msg == null) || (msg.getBody() == null))
+			throw new IllegalArgumentException();
+		
+		Body body = msg.getBody();
+		
+		String type = (String) body.get(CONTENT_TYPE);
+		
+		if (type == null)
+			return RAW_BODY;
+		else
+			return type;
+	}
+	
+	public static final BytesBody createBytesBody (Message msg) throws InvalidPayloadException
+	{
+		if ((msg == null) || (msg.getBody() == null))
+			return null;
+		
+		checkType(msg, BYTES_BODY);
+		
+		return (BytesBody) MessageFactory.getInstance().createBodyType(msg, BYTES_BODY);
+	}
+
+	public static final MapBody createMapBody (Message msg) throws InvalidPayloadException
+	{
+		if ((msg == null) || (msg.getBody() == null))
+			return null;
+		
+		checkType(msg, MAP_BODY);
+		
+		return (MapBody) MessageFactory.getInstance().createBodyType(msg, MAP_BODY);
+	}
+	
+	public static final CommandBody createCommandBody (Message msg) throws InvalidPayloadException
+	{
+		if ((msg == null) || (msg.getBody() == null))
+			return null;
+		
+		checkType(msg, COMMAND_BODY);
+		
+		return (CommandBody) MessageFactory.getInstance().createBodyType(msg, COMMAND_BODY);
+	}
+	
+	public static final ObjectBody createObjectBody (Message msg) throws InvalidPayloadException
+	{
+		if ((msg == null) || (msg.getBody() == null))
+			return null;
+		
+		checkType(msg, OBJECT_BODY);
+		
+		return (ObjectBody) MessageFactory.getInstance().createBodyType(msg, OBJECT_BODY);
+	}
+	
+	public static final TextBody createTextBody (Message msg) throws InvalidPayloadException
+	{
+		if ((msg == null) || (msg.getBody() == null))
+			return null;
+		
+		checkType(msg, TEXT_BODY);
+		
+		return (TextBody) MessageFactory.getInstance().createBodyType(msg, TEXT_BODY);
+	}
+	
+	/*
+	 * If the message type is set and it does not conform the type expected,
+	 * then throw IllegalArgumentException.
+	 */
+	
+	private static final void checkType (Message msg, String required) throws InvalidPayloadException
+	{
+		String type = (String) msg.getBody().get(CONTENT_TYPE);
+		
+		if ((type != null) && (!type.equals(required)))
+			throw new InvalidPayloadException();
+	}
+}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/TextBody.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/TextBody.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/TextBody.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,48 @@
+package org.jboss.soa.esb.message.body.content;
+
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.body.content.InvalidPayloadException;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Similar to JMS, the Message payload only contains a String.
+ */
+
+public interface TextBody extends Body
+{   
+    /**
+     * Add the Text element to the Body.
+     * 
+     * @param value the String to add.
+     */
+    
+    public void setText (String value);
+
+    /**
+     * Obtain the Text from the Body.
+     * 
+     * @return the String.
+     */
+    
+    public String getText () throws InvalidPayloadException;
+}
\ No newline at end of file

Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/TextMessage.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/payload/TextMessage.java	2007-08-03 12:53:42 UTC (rev 13995)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/body/content/TextMessage.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -1,93 +0,0 @@
-package org.jboss.soa.esb.message.payload;
-
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.payload.InvalidPayloadException;
-import org.jboss.soa.esb.message.payload.TextMessage;
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated 
- * by the @authors tag. All rights reserved. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author mark.little at jboss.com
- */
-
-/**
- * Similar to JMS, the Message payload only contains a String.
- */
-
-public class TextMessage
-{
-    public static final String ELEMENT_NAME = "org.jboss.soa.esb.message.payload.text";
-    
-    private static final long serialVersionUID = 0xdeadbeef;
-    
-    /**
-     * Add the Text element to the Body.
-     * 
-     * @param value the String to add.
-     */
-    
-    public void setText (String value)
-    {
-	if (value == null)
-	    throw new IllegalArgumentException();
-	
-	_payload.add(ELEMENT_NAME, value);
-    }
-
-    /**
-     * Obtain the Text from the Body.
-     * 
-     * @return the String.
-     */
-    
-    public String getText () throws InvalidPayloadException
-    {
-	try
-	{
-	    Object ret = _payload.get(ELEMENT_NAME);
-	    
-	    if (ret == null)
-		throw new InvalidPayloadException();
-	    
-	    return (String) ret;
-	}
-	catch (ClassCastException ex)
-	{
-	    throw new InvalidPayloadException(ex);
-	}
-    }
-    
-    public static final boolean isTextMessage (Body payload)
-    {
-	try
-	{
-	    return (payload.get(ELEMENT_NAME) != null);
-	}
-	catch (Exception ex)
-	{
-	    return false;
-	}
-    }
-
-    TextMessage (Body payload)
-    {
-	_payload = payload;
-    }
-    
-    private Body _payload;
-}
\ No newline at end of file

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/format/MessageFactory.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/format/MessageFactory.java	2007-08-05 10:44:28 UTC (rev 14044)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/format/MessageFactory.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -68,6 +68,17 @@
 	
 	public abstract void reset ();
 	
+	/**
+	 * Given a Message, return the Body component as a specific type for
+	 * manipulation, e.g., TextMessage or BytesMessage.
+	 * 
+	 * @param m the Message
+	 * @param bodyType the type of Body to "cast" to.
+	 * @return the Body.
+	 */
+	
+	public abstract Object createBodyType (Message m, String bodyType);
+	
 	// TODO setters/getters for the plugin programmatically too.
 	
 	public static MessageFactory getInstance ()

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/format/MessagePlugin.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/format/MessagePlugin.java	2007-08-05 10:44:28 UTC (rev 14044)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/format/MessagePlugin.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -45,8 +45,10 @@
 	public Message getMessage ();
 	
 	/**
-	 * @return the unique identifier for this message plugin.
+	 * @return the unique format identifier for this message plugin.
 	 */
 	
 	public URI getType ();
+	
+	public Object createBodyType (Message msg, String type);
 }

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/format/MessageType.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/format/MessageType.java	2007-08-05 10:44:28 UTC (rev 14044)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/format/MessageType.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -26,15 +26,20 @@
  */
 
 /**
- * You get a message of a specific type when you need it. Obviously that type
+ * You get a message of a specific format when you need it. Obviously that format
  * may not be suitable for the service (hopefully you've got that contractual
  * information a priori, but maybe not) and in which case some
  * translation/transformation may be necessary.
  * 
+ * This should not be confused with the type of payload, which can also be chosen
+ * after creation.
+ * 
  * @author Mark Little
  * 
  */
 
+// bad name ;-) Should be MessageFormat or some such.
+
 public abstract class MessageType
 {
     public static final String DEFAULT_URI = "org.jboss.soa.esb.message.default.uri";

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/ContentManager.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/ContentManager.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/ContentManager.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,169 @@
+package org.jboss.soa.esb.message.helper.content;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Map;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.body.content.BytesBody;
+import org.jboss.soa.esb.message.body.content.CommandBody;
+import org.jboss.soa.esb.message.body.content.MapBody;
+import org.jboss.soa.esb.message.body.content.ObjectBody;
+import org.jboss.soa.esb.message.body.content.Payload;
+import org.jboss.soa.esb.message.body.content.TextBody;
+import org.jboss.soa.esb.message.format.MessageFactory;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * You get a message of a specific type when you need it and it
+ * is initialized with state.
+ * 
+ * @author Mark Little
+ *
+ */
+
+public class ContentManager
+{	
+	public Message createTextMessage (String initial)
+	{
+		if (initial == null)
+			throw new IllegalArgumentException();
+		
+		Message msg = MessageFactory.getInstance().getMessage(_type);
+		
+		try
+		{
+			TextBody payload = (TextBody) MessageFactory.getInstance().createBodyType(msg, Payload.TEXT_BODY);
+			
+			payload.setText(initial);
+			
+			return msg;
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+		
+		return null;
+	}
+	
+	public Message createObjectMessage (Serializable initial)
+	{
+		if (initial == null)
+			throw new IllegalArgumentException();
+		
+		Message msg = MessageFactory.getInstance().getMessage(_type);
+		
+		try
+		{
+			ObjectBody payload = (ObjectBody) MessageFactory.getInstance().createBodyType(msg, Payload.OBJECT_BODY);
+			
+			payload.setObject(initial);
+			
+			return msg;
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+		
+		return null;
+	}
+	
+	public Message createMapMessage (Map<String, Serializable> initial)
+	{
+		if (initial == null)
+			throw new IllegalArgumentException();
+		
+		Message msg = MessageFactory.getInstance().getMessage(_type);
+		
+		try
+		{
+			MapBody payload = (MapBody) MessageFactory.getInstance().createBodyType(msg, Payload.MAP_BODY);
+			
+			payload.setMap(initial);
+			
+			return msg;
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+		
+		return null;
+	}
+	
+	public Message createCommandMessage (String initial)
+	{
+		if (initial == null)
+			throw new IllegalArgumentException();
+		
+		Message msg = MessageFactory.getInstance().getMessage(_type);
+		
+		try
+		{
+			CommandBody payload = (CommandBody) MessageFactory.getInstance().createBodyType(msg, Payload.COMMAND_BODY);
+			
+			payload.setType(initial);
+			
+			return msg;
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+		
+		return null;
+	}
+	
+	public Message createBytesMessage (byte[] initial)
+	{
+		if (initial == null)
+			throw new IllegalArgumentException();
+		
+		Message msg = MessageFactory.getInstance().getMessage(_type);
+		
+		try
+		{
+			BytesBody payload = (BytesBody) MessageFactory.getInstance().createBodyType(msg, Payload.BYTES_BODY);
+			
+			payload.setByteArray(initial);
+			
+			return msg;
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+		
+		return null;
+	}
+
+	protected ContentManager (URI type)
+	{
+		_type = type;
+	}
+	
+	private URI _type;
+	
+}

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/SerializedMessageFactory.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/SerializedMessageFactory.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/SerializedMessageFactory.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,54 @@
+package org.jboss.soa.esb.message.helper.content;
+
+import org.jboss.soa.esb.message.format.MessageType;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * You get a message of a specific type when you need it and it
+ * is initialized with state.
+ * 
+ * @author Mark Little
+ *
+ */
+
+public class SerializedMessageFactory extends ContentManager
+{	
+	protected SerializedMessageFactory ()
+	{
+		super(MessageType.JAVA_SERIALIZED);
+	}
+	
+	public static final SerializedMessageFactory getInstance ()
+	{
+		synchronized (_lock)
+		{
+			if (_theInstance == null)
+				_theInstance = new SerializedMessageFactory();
+		}
+		
+		return _theInstance;
+	}
+	
+	private static SerializedMessageFactory _theInstance = null;
+	private static final Object _lock = new Object();
+}

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/XMLMessageFactory.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/XMLMessageFactory.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/helper/content/XMLMessageFactory.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,54 @@
+package org.jboss.soa.esb.message.helper.content;
+
+import org.jboss.soa.esb.message.format.MessageType;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * You get a message of a specific type when you need it and it
+ * is initialized with state.
+ * 
+ * @author Mark Little
+ *
+ */
+
+public class XMLMessageFactory extends ContentManager
+{	
+	protected XMLMessageFactory ()
+	{
+		super(MessageType.JBOSS_XML);
+	}
+	
+	public static final XMLMessageFactory getInstance ()
+	{
+		synchronized (_lock)
+		{
+			if (_theInstance == null)
+				_theInstance = new XMLMessageFactory();
+		}
+		
+		return _theInstance;
+	}
+	
+	private static XMLMessageFactory _theInstance = null;
+	private static final Object _lock = new Object();
+}

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/ExampleMessagePlugin.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/ExampleMessagePlugin.java	2007-08-05 10:44:28 UTC (rev 14044)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/format/tests/ExampleMessagePlugin.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -68,4 +68,9 @@
 			return null;
 		}
 	}
+	
+	public Object createBodyType (Message m, String type)
+	{
+		return m.getBody();
+	}
 }

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/helper/content/SerializedContentManagerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/helper/content/SerializedContentManagerUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/helper/content/SerializedContentManagerUnitTest.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.message.helper.content;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Hashtable;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.body.content.BytesBody;
+import org.jboss.soa.esb.message.body.content.CommandBody;
+import org.jboss.soa.esb.message.body.content.MapBody;
+import org.jboss.soa.esb.message.body.content.ObjectBody;
+import org.jboss.soa.esb.message.body.content.TextBody;
+
+/**
+ * Unit tests for the Payload class.
+ * 
+ * @author Mark Little
+ */
+
+public class SerializedContentManagerUnitTest extends TestCase
+{
+	public void testTextMessage () throws Exception
+	{
+		Message msg = _factory.createTextMessage("hello world");		
+		TextBody body = (TextBody) msg.getBody();
+		
+		assertEquals(body.getText(), "hello world");
+	}
+	
+	public void testObjectMessage () throws Exception
+	{
+		Message msg = _factory.createObjectMessage("hello world");
+		ObjectBody body = (ObjectBody) msg.getBody();
+		
+		assertEquals(body.getObject(), "hello world");		
+	}
+	
+	public void testMapMessage () throws Exception
+	{
+		Hashtable<String, Serializable> initial = new Hashtable<String, Serializable>();
+		
+		initial.put("foo", "bar");
+		
+		Message msg = _factory.createMapMessage(initial);
+		MapBody body = (MapBody) msg.getBody();
+		
+		assertEquals(body.getString("foo"), "bar");
+	}
+	
+	public void testCommandMessage () throws Exception
+	{
+		Message msg = _factory.createCommandMessage("foobar");
+		CommandBody body = (CommandBody) msg.getBody();
+		
+		assertEquals(body.getType(), "foobar");
+	}
+	
+	public void testBytesMessage () throws Exception
+	{
+		ByteArrayOutputStream stream = new ByteArrayOutputStream();
+		ObjectOutputStream output = new ObjectOutputStream(stream);
+		
+		output.writeInt(12345);
+		output.writeUTF("Hello World");
+		
+		output.flush();
+		output.close();
+		
+		ObjectInputStream input = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray()));
+		
+		assertEquals(input.readInt(), 12345);
+		assertEquals(input.readUTF(), "Hello World");
+		
+		Message msg = _factory.createBytesMessage(stream.toByteArray());
+		BytesBody body = (BytesBody) msg.getBody();
+		
+		body.readMode();
+		
+		assertEquals(body.readInt(), 12345);
+		assertEquals(body.readUTFString(), "Hello World");
+	}
+	
+	private static final SerializedMessageFactory _factory = new SerializedMessageFactory();
+}

Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/helper/content/XMLContentManagerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/helper/content/XMLContentManagerUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/helper/content/XMLContentManagerUnitTest.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.message.helper.content;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Hashtable;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.body.content.BytesBody;
+import org.jboss.soa.esb.message.body.content.CommandBody;
+import org.jboss.soa.esb.message.body.content.MapBody;
+import org.jboss.soa.esb.message.body.content.ObjectBody;
+import org.jboss.soa.esb.message.body.content.TextBody;
+
+/**
+ * Unit tests for the Payload class.
+ * 
+ * @author Mark Little
+ */
+
+public class XMLContentManagerUnitTest extends TestCase
+{
+	public void testTextMessage () throws Exception
+	{
+		Message msg = _factory.createTextMessage("hello world");		
+		TextBody body = (TextBody) msg.getBody();
+		
+		assertEquals(body.getText(), "hello world");
+	}
+	
+	public void testObjectMessage () throws Exception
+	{
+		Message msg = _factory.createObjectMessage("hello world");
+		ObjectBody body = (ObjectBody) msg.getBody();
+		
+		assertEquals(body.getObject(), "hello world");		
+	}
+	
+	public void testMapMessage () throws Exception
+	{
+		Hashtable<String, Serializable> initial = new Hashtable<String, Serializable>();
+		
+		initial.put("foo", "bar");
+		
+		Message msg = _factory.createMapMessage(initial);
+		MapBody body = (MapBody) msg.getBody();
+		
+		assertEquals(body.getString("foo"), "bar");
+	}
+	
+	public void testCommandMessage () throws Exception
+	{
+		Message msg = _factory.createCommandMessage("foobar");
+		CommandBody body = (CommandBody) msg.getBody();
+		
+		assertEquals(body.getType(), "foobar");
+	}
+	
+	public void testBytesMessage () throws Exception
+	{
+		ByteArrayOutputStream stream = new ByteArrayOutputStream();
+		ObjectOutputStream output = new ObjectOutputStream(stream);
+		
+		output.writeInt(12345);
+		output.writeUTF("Hello World");
+		
+		output.flush();
+		output.close();
+		
+		ObjectInputStream input = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray()));
+		
+		assertEquals(input.readInt(), 12345);
+		assertEquals(input.readUTF(), "Hello World");
+		
+		Message msg = _factory.createBytesMessage(stream.toByteArray());
+		BytesBody body = (BytesBody) msg.getBody();
+		
+		body.readMode();
+		
+		assertEquals(body.readInt(), 12345);
+		assertEquals(body.readUTFString(), "Hello World");
+	}
+	
+	private static final XMLMessageFactory _factory = new XMLMessageFactory();
+}

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/payload/PayloadUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/payload/PayloadUnitTest.java	2007-08-05 10:44:28 UTC (rev 14044)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/payload/PayloadUnitTest.java	2007-08-06 09:27:57 UTC (rev 14045)
@@ -22,14 +22,21 @@
 
 package org.jboss.soa.esb.message.payload;
 
-import java.io.Serializable;
-import java.util.Hashtable;
-import java.util.Map;
+import java.io.IOException;
+import java.util.Enumeration;
 
 import junit.framework.TestCase;
 
 import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.body.content.BytesBody;
+import org.jboss.soa.esb.message.body.content.CommandBody;
+import org.jboss.soa.esb.message.body.content.IncompatibleModeException;
+import org.jboss.soa.esb.message.body.content.MapBody;
+import org.jboss.soa.esb.message.body.content.ObjectBody;
+import org.jboss.soa.esb.message.body.content.Payload;
+import org.jboss.soa.esb.message.body.content.TextBody;
 import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
 
 /**
  * Unit tests for the Payload class.
@@ -39,141 +46,151 @@
 
 public class PayloadUnitTest extends TestCase
 {
-    public void testMapMessage () throws Exception
-    {
-	Message msg = MessageFactory.getInstance().getMessage();
+	public void testMapMessage() throws Exception
+	{
+		Message msg = MessageFactory.getInstance().getMessage();
 
-	assertEquals((msg != null), true);
-	
-	MapMessage mapMessage = Payload.getAsMapMessage(msg);
-	Hashtable<String, Serializable> map = new Hashtable<String, Serializable>();
-	
-	map.put("foo", "bar");
-	map.put("hello", "world");
-	
-	mapMessage.setMap(map);
-	
-	Map<String, Serializable> payload = mapMessage.getMap();
-	
-	assertNotNull(payload);
-	
-	assertEquals(payload.get("foo"), "bar");
-	assertEquals(payload.get("hello"), "world");
-    }
+		assertEquals((msg != null), true);
 
-    public void testTextMessage () throws Exception
-    {
-	Message msg = MessageFactory.getInstance().getMessage();
+		MapBody mapMessage = Payload.createMapBody(msg);
 
-	assertEquals((msg != null), true);
-	
-	TextMessage mapMessage = Payload.getAsTextMessage(msg);
-	
-	mapMessage.setText("hello world");
+		assertEquals(msg.getBody() instanceof MapBody, true);
+		
+		mapMessage.setString("foo", "bar");
+		mapMessage.setBoolean("hello", true);
 
-	assertEquals(mapMessage.getText(), "hello world");
-    }
-    
-    public void testObjectMessage () throws Exception
-    {
-	Message msg = MessageFactory.getInstance().getMessage();
+		Enumeration<String> names = mapMessage.getMapNames();
 
-	assertEquals((msg != null), true);
-	
-	ObjectMessage mapMessage = Payload.getAsObjectMessage(msg);
-	
-	mapMessage.setObject("hello world");
+		assertNotNull(names);
 
-	assertEquals(mapMessage.getObject(), "hello world");
-    }
-    
-    public void testBytesMessage () throws Exception
-    {
-	Message msg = MessageFactory.getInstance().getMessage();
+		assertEquals(mapMessage.getString("foo"), "bar");
+		assertEquals(mapMessage.getBoolean("hello"), true);
+	}
 
-	assertEquals((msg != null), true);
-	
-	BytesMessage mapMessage = Payload.getAsBytesMessage(msg, true);
-	
-	try
+	public void testTextMessage() throws Exception
 	{
-	    mapMessage.writeBoolean(true);
-	    
-	    fail();
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+
+		TextBody textMessage = Payload.createTextBody(msg);
+
+		textMessage.setText("hello world");
+
+		assertEquals(textMessage.getText(), "hello world");
 	}
-	catch (IncompatibleModeException ex)
+
+	public void testObjectMessage() throws Exception
 	{
+		Message msg = MessageFactory.getInstance().getMessage();
+
+		assertEquals((msg != null), true);
+
+		ObjectBody objectMessage = Payload.createObjectBody(msg);;
+
+		objectMessage.setObject("hello world");
+
+		assertEquals(objectMessage.getObject(), "hello world");
 	}
-	
-	mapMessage.writeMode();
-	
-	mapMessage.writeInt(12345);
-	mapMessage.writeUTFString("hello world");
-	mapMessage.writeShort((short) 10);
-	mapMessage.writeBoolean(true);
-	
-	mapMessage.readMode();
-	
-	assertEquals(mapMessage.readInt(), 12345);
-	assertEquals(mapMessage.readUTFString(), "hello world");
-	assertEquals(mapMessage.readShort(), (short) 10);
-	assertEquals(mapMessage.readBoolean(), true);
-    }
-    
-    public void testBytesMessageAsControl () throws Exception
-    {
-	Message msg = MessageFactory.getInstance().getMessage();
 
-	assertEquals((msg != null), true);
-	
-	BytesMessage mapMessage = Payload.getAsBytesMessage(msg, true);
-	
-	try
+	public void testBytesMessage() throws Exception
 	{
-	    mapMessage.writeBoolean(true);
-	    
-	    fail();
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+
+		BytesBody mapMessage = Payload.createBytesBody(msg);
+
+		try
+		{
+			mapMessage.readMode();
+			
+			fail();
+		}
+		catch (Exception ex)
+		{
+		}
+		
+		try
+		{
+			mapMessage.writeBoolean(true);
+
+			fail();
+		}
+		catch (IncompatibleModeException ex)
+		{
+		}
+
+		mapMessage.writeMode();
+
+		mapMessage.writeInt(12345);
+		mapMessage.writeUTFString("hello world");
+		mapMessage.writeShort((short) 10);
+		mapMessage.writeBoolean(true);
+
+		mapMessage.flush();
+		
+		mapMessage.readMode();
+
+		assertEquals(mapMessage.readInt(), 12345);
+		assertEquals(mapMessage.readUTFString(), "hello world");
+		assertEquals(mapMessage.readShort(), (short) 10);
+		assertEquals(mapMessage.readBoolean(), true);
 	}
-	catch (IncompatibleModeException ex)
+
+	public void testBytesMessageAsControl() throws Exception
 	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+
+		BytesBody mapMessage = Payload.createBytesBody(msg);
+
+		try
+		{
+			mapMessage.readMode();
+			
+			fail();
+		}
+		catch (IOException ex)
+		{
+		}
+		
+		try
+		{
+			mapMessage.writeBoolean(true);
+
+			fail();
+		}
+		catch (IncompatibleModeException ex)
+		{
+		}
+
+		mapMessage.writeMode();
+
+		mapMessage.writeInt(12345);
+		mapMessage.writeUTFString("hello world");
+		mapMessage.writeShort((short) 10);
+		mapMessage.writeBoolean(true);
+
+		mapMessage.flush();
+		
+		mapMessage.readMode();
+
+		assertEquals(mapMessage.readInt(), 12345);
+		assertEquals(mapMessage.readUTFString(), "hello world");
+		assertEquals(mapMessage.readShort(), (short) 10);
+		assertEquals(mapMessage.readBoolean(), true);
+
+		try
+		{
+			@SuppressWarnings("unused")
+			CommandBody payload = Payload.createCommandBody(msg);
+			
+			fail();
+		}
+		catch (Exception ex)
+		{
+		}
 	}
-	
-	mapMessage.writeMode();
-	
-	mapMessage.writeInt(12345);
-	mapMessage.writeUTFString("hello world");
-	mapMessage.writeShort((short) 10);
-	mapMessage.writeBoolean(true);
-	
-	mapMessage.readMode();
-	
-	assertEquals(mapMessage.readInt(), 12345);
-	assertEquals(mapMessage.readUTFString(), "hello world");
-	assertEquals(mapMessage.readShort(), (short) 10);
-	assertEquals(mapMessage.readBoolean(), true);
-	
-	assertTrue(BytesMessage.isBytesMessage(msg.getBody()));
-	assertFalse(CommandMessage.isCommandMessage(msg.getBody()));
-	
-	try
-	{
-	    @SuppressWarnings("unused")
-        BytesMessage payload = (BytesMessage) Payload.getPayload(msg);
-	}
-	catch (ClassCastException ex)
-	{
-	    fail();
-	}
-	
-	try
-	{
-        @SuppressWarnings("unused")
-	    CommandMessage payload = (CommandMessage) Payload.getPayload(msg);
-	    
-	    fail();
-	}
-	catch (ClassCastException ex)
-	{
-	}
-    }
 }




More information about the jboss-svn-commits mailing list