[jboss-svn-commits] JBL Code SVN: r9679 - in labs/jbossesb/workspace/rearch2/core: lib and 32 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Feb 21 12:03:54 EST 2007


Author: mark.little at jboss.com
Date: 2007-02-21 12:03:54 -0500 (Wed, 21 Feb 2007)
New Revision: 9679

Added:
   labs/jbossesb/workspace/rearch2/core/checkstyle.xml
   labs/jbossesb/workspace/rearch2/core/lib/commons-logging.jar
   labs/jbossesb/workspace/rearch2/core/lib/log4j.jar
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/PortReferenceHelper.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/assertion/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/assertion/AssertArgument.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/AttachmentImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/ContextImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/FaultImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/SerializedMessagePlugin.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/XMLMessagePlugin.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/XMLUtil.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalManager.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalPlugin.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/SerializedMarshalUnmarshalPlugin.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/thirdparty/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/thirdparty/Base64.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/BaseException.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/ConfigurationException.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/FatalError.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/MarshalException.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/ProtocolNotSupportedException.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/SendFailedException.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/UnmarshalException.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/Call.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/EPR.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/MalformedEPRException.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/PortReference.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/XMLUtil.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/EmailEpr.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/FTPEpr.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/FileEpr.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/HTTPEpr.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/JDBCEpr.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/JMSEpr.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/SFTPEpr.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/util/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/util/EPRManager.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/common/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/common/Environment.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/common/ModulePropertyManager.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/helpers/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/helpers/NamingContext.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Attachment.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Context.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Fault.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Header.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Message.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Properties.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/MessageFactory.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/MessagePlugin.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/MessageType.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/EmailUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/FTPUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/HTTPUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/JDBCUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/JMSUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/CallUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/EPRUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/util/
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/util/tests/
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/util/tests/EPRHelperUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/util/tests/EPRManagerUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/ExampleMessageImpl.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/ExampleMessagePlugin.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/MessageFactoryUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/BodyUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/ExampleObject.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/FaultUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/MessageUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java
Modified:
   labs/jbossesb/workspace/rearch2/core/pom.xml
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/App.java
Log:


Added: labs/jbossesb/workspace/rearch2/core/checkstyle.xml
===================================================================

Added: labs/jbossesb/workspace/rearch2/core/lib/commons-logging.jar
===================================================================
(Binary files differ)


Property changes on: labs/jbossesb/workspace/rearch2/core/lib/commons-logging.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossesb/workspace/rearch2/core/lib/log4j.jar
===================================================================
(Binary files differ)


Property changes on: labs/jbossesb/workspace/rearch2/core/lib/log4j.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: labs/jbossesb/workspace/rearch2/core/pom.xml
===================================================================
--- labs/jbossesb/workspace/rearch2/core/pom.xml	2007-02-21 15:08:45 UTC (rev 9678)
+++ labs/jbossesb/workspace/rearch2/core/pom.xml	2007-02-21 17:03:54 UTC (rev 9679)
@@ -21,6 +21,20 @@
       <scope>system</scope>
       <systemPath>${basedir}/lib/jbossts-common.jar</systemPath>
    </dependency>
+   <dependency>
+      <groupId>apache</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.2.3</version>
+      <scope>system</scope>
+      <systemPath>${basedir}/lib/commons-logging.jar</systemPath>
+   </dependency>
+   <dependency>
+      <groupId>apache</groupId>
+      <artifactId>log4j</artifactId>
+      <version>1.2.3</version>
+      <scope>system</scope>
+      <systemPath>${basedir}/lib/log4j.jar</systemPath>
+   </dependency>
   </dependencies>
   <build>
 	<plugins>

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,196 @@
+package org.jboss.internal.soa.esb.addressing.helpers;
+
+/*
+ * 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
+ */
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.XMLUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public abstract class CallHelper
+{
+
+	public static Element toXML(Call call, Document doc, Element header)
+			throws MarshalException
+	{
+		AssertArgument.isNotNull(call, "call");
+		AssertArgument.isNotNull(doc, "doc");
+		AssertArgument.isNotNull(header, "header");
+
+		header.setAttributeNS(XMLUtil.XMLNS_URI, XMLUtil.XMLNS_PREFIX
+				+ XMLUtil.WSA_PREFIX, XMLUtil.WSA_NAMESPACE_URI);
+		
+		if (call.getTo() != null)
+		{
+			final Element toElement = doc.createElementNS(
+					XMLUtil.WSA_NAMESPACE_URI, XMLUtil.TO_TAG);
+			toElement.setPrefix(XMLUtil.WSA_PREFIX);
+			EPRHelper.toXML(call.getTo(), doc, header, toElement, true);
+			header.appendChild(toElement);
+		}
+
+		if (call.getFrom() != null)
+		{
+			final Element fromElement = doc.createElementNS(
+					XMLUtil.WSA_NAMESPACE_URI, XMLUtil.FROM_TAG);
+			fromElement.setPrefix(XMLUtil.WSA_PREFIX);
+			EPRHelper.toXML(call.getFrom(), doc, header, fromElement, false);
+			header.appendChild(fromElement);
+		}
+
+		if (call.getReplyTo() != null)
+		{
+			final Element replyToElement = doc.createElementNS(
+					XMLUtil.WSA_NAMESPACE_URI, XMLUtil.REPLY_TO_TAG);
+			replyToElement.setPrefix(XMLUtil.WSA_PREFIX);
+			EPRHelper.toXML(call.getReplyTo(), doc, header, replyToElement,
+					false);
+			header.appendChild(replyToElement);
+		}
+
+		if (call.getRelatesTo() != null)
+		{
+			final Element relatesToElement = doc.createElementNS(
+					XMLUtil.WSA_NAMESPACE_URI, XMLUtil.RELATES_TO_TAG);
+			relatesToElement.setPrefix(XMLUtil.WSA_PREFIX);
+			relatesToElement.setNodeValue(call.getRelatesTo().toString());
+			header.appendChild(relatesToElement);
+		}
+
+		if (call.getFaultTo() != null)
+		{
+			final Element faultToElement = doc.createElementNS(
+					XMLUtil.WSA_NAMESPACE_URI, XMLUtil.FAULT_TO_TAG);
+			faultToElement.setPrefix(XMLUtil.WSA_PREFIX);
+			EPRHelper.toXML(call.getFaultTo(), doc, header, faultToElement,
+					false);
+			header.appendChild(faultToElement);
+		}
+
+		if (call.getAction() != null)
+		{
+			final Element actionElement = doc.createElementNS(
+					XMLUtil.WSA_NAMESPACE_URI, XMLUtil.ACTION_TAG);
+			actionElement.setPrefix(XMLUtil.WSA_PREFIX);
+			actionElement.setTextContent(call.getAction().toString());
+			header.appendChild(actionElement);
+		}
+
+		if (call.getMessageID() != null)
+		{
+			final Element messageIDElement = doc.createElementNS(
+					XMLUtil.WSA_NAMESPACE_URI, XMLUtil.MESSAGE_IDENTIFIER_TAG);
+			messageIDElement.setPrefix(XMLUtil.WSA_PREFIX);
+			messageIDElement.setTextContent(call.getMessageID().toString());
+			header.appendChild(messageIDElement);
+		}
+
+		return header;
+	}
+
+	public static Call fromXML(Element header) throws UnmarshalException
+	{
+		AssertArgument.isNotNull(header, "header");
+
+		Call call = new Call();
+		NodeList nl = header.getChildNodes();
+
+		for (int i = 0; i < nl.getLength(); i++)
+		{
+			Node n = nl.item(i);
+
+			if ((n.getPrefix() != null) && (n.getLocalName() != null))
+			{
+				if (n.getPrefix().equals(XMLUtil.WSA_PREFIX) && (n.getLocalName().equals(XMLUtil.TO_TAG)))
+				{
+					call.setTo(EPRHelper.fromXML((Element) header, true));
+				}
+				
+				if (n.getPrefix().equals(XMLUtil.WSA_PREFIX) && (n.getLocalName().equals(XMLUtil.FROM_TAG)))
+				{
+					call.setFrom(EPRHelper.fromXML((Element) n, false));
+				}
+	
+				if (n.getPrefix().equals(XMLUtil.WSA_PREFIX) && (n.getLocalName().equals(XMLUtil.REPLY_TO_TAG)))
+				{
+					call.setReplyTo(EPRHelper.fromXML((Element) n, false));
+				}
+	
+				if (n.getPrefix().equals(XMLUtil.WSA_PREFIX) && (n.getLocalName().equals(XMLUtil.RELATES_TO_TAG)))
+				{
+					try
+					{
+						call.setRelatesTo(new URI(n.getNodeValue()));
+					}
+					catch (URISyntaxException e)
+					{
+						throw new UnmarshalException("'" + XMLUtil.RELATES_TO_TAG
+								+ "' must be a valid URI", e);
+					}
+				}
+	
+				if (n.getPrefix().equals(XMLUtil.WSA_PREFIX) && (n.getLocalName().equals(XMLUtil.FAULT_TO_TAG)))
+				{
+					call.setFaultTo(EPRHelper.fromXML((Element) n, false));
+				}
+	
+				if (n.getPrefix().equals(XMLUtil.WSA_PREFIX) && (n.getLocalName().equals(XMLUtil.ACTION_TAG)))
+				{
+					try
+					{
+						call.setAction(new URI(n.getTextContent()));
+					}
+					catch (URISyntaxException e)
+					{
+						throw new UnmarshalException("'" + XMLUtil.ACTION_TAG
+								+ "' must be a valid URI", e);
+					}
+				}
+	
+				if (n.getPrefix().equals(XMLUtil.WSA_PREFIX) && (n.getLocalName().equals(XMLUtil.MESSAGE_IDENTIFIER_TAG)))
+				{
+					try
+					{
+						call.setMessageID(new URI(n.getTextContent()));
+					}
+					catch (URISyntaxException e)
+					{
+						throw new UnmarshalException("'"
+								+ XMLUtil.MESSAGE_IDENTIFIER_TAG
+								+ "' must be a valid URI", e);
+					}
+				}
+			}
+		}
+
+		return call;
+	}
+
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,408 @@
+package org.jboss.internal.soa.esb.addressing.helpers;
+
+/*
+ * 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
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.XMLUtil;
+import org.jboss.soa.esb.addressing.eprs.EmailEpr;
+import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
+import org.jboss.soa.esb.addressing.eprs.HTTPEpr;
+import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.addressing.eprs.SFTPEpr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
+public class EPRHelper
+{
+	public static final String EPR_TYPE = "type";
+
+	/**
+	 * Serialize the EPR to an XML representation.
+	 * 
+	 * @param epr
+	 * @param doc
+	 * @param header
+	 * @return
+	 */
+
+	public static final Element toXML(EPR epr, Document doc, Element header,
+			Element packElement) throws MarshalException
+	{
+		return toXML(epr, doc, header, packElement, false);
+	}
+
+	/**
+	 * Serialize the EPR to an XML representation. Specify whether this is a To
+	 * node in the Call.
+	 * 
+	 * @param epr
+	 * @param doc
+	 * @param header
+	 * @return
+	 */
+
+	public static final Element toXML(EPR epr, Document doc, Element header,
+			Element packElement, boolean to) throws MarshalException
+	{
+		AssertArgument.isNotNull(epr, "epr");
+
+		// TODO
+		// The EPR type really should be doing this itself.
+
+		setSpecificEPR(epr);
+		PortReferenceHelper.toXML(header, doc, packElement, epr.getAddr(), to);
+
+		return header;
+	}
+
+	/**
+	 * Deserialize the EPR from an XML representation.
+	 * 
+	 * @param header
+	 * @return
+	 */
+
+	public static final EPR fromXML(Element header) throws UnmarshalException
+	{
+		return fromXML(header, false);
+	}
+
+	/**
+	 * Deserialize the EPR from an XML representation. Specify whether this is a
+	 * To node in the Call.
+	 * 
+	 * @param header
+	 * @return
+	 */
+
+	public static final EPR fromXML(Element header, boolean to)
+			throws UnmarshalException
+	{
+		AssertArgument.isNotNull(header, "header");
+
+		if (to)
+		{
+			NodeList children = header.getChildNodes();
+
+			for (int i = 0; i < children.getLength(); i++)
+			{
+				Node n = children.item(i);
+
+				if (n instanceof Element)
+				{
+					Element el = (Element) n;
+					String prefix = el.getPrefix();
+					String tag = el.getLocalName();
+					
+					if ((prefix != null) && (prefix.equals(XMLUtil.WSA_PREFIX)))
+					{
+						if ((tag != null) && (tag.equals(XMLUtil.TO_TAG)))
+						{
+							return getSpecificEPR(new EPR(PortReferenceHelper
+									.fromXML(el, true)), header);
+						}
+					}
+				}
+			}
+		}
+
+		return getSpecificEPR(new EPR(PortReferenceHelper.fromXML(header, to)));
+	}
+
+	/**
+	 * Create a string version of the XML representation for this EPR. If the
+	 * EPR is a specific type (e.g., JMSEpr) then that type information will
+	 * also be encoded.
+	 * 
+	 * @param epr
+	 * @return
+	 * @throws MarshalException 
+	 */
+
+	public static final String toXMLString(EPR epr) throws MarshalException
+	{
+		return toXMLString(epr, false, XMLUtil.FROM_TAG);
+	}
+
+	/**
+	 * Create a string version of the XML representation for this EPR. If the
+	 * EPR is a specific type (e.g., JMSEpr) then that type information will
+	 * also be encoded. Specify whether this is a To node in the Call.
+	 * 
+	 * @param epr
+	 * @return
+	 * @throws MarshalException 
+	 */
+
+	public static final String toXMLString(EPR epr, boolean to, String tag) throws MarshalException
+	{
+		AssertArgument.isNotNull(epr, "epr");
+		AssertArgument.isNotNull(tag, "tag");
+
+		try
+		{
+			DocumentBuilderFactory factory = DocumentBuilderFactory
+					.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			DocumentBuilder builder = factory.newDocumentBuilder();
+			Document doc = builder.newDocument();
+			Element portReferenceElement = doc.createElementNS(
+					XMLUtil.WSA_NAMESPACE_URI, tag);
+			
+			setSpecificEPR(epr);
+
+			if (to)
+			{
+				Element header = doc.createElement("header");
+				doc.appendChild(header);
+				header.setAttributeNS(XMLUtil.XMLNS_URI, XMLUtil.XMLNS_PREFIX
+						+ XMLUtil.WSA_PREFIX, XMLUtil.WSA_NAMESPACE_URI);
+				toXML(epr, doc, header, portReferenceElement, to);
+				header.appendChild(portReferenceElement);
+			}
+			else
+			{
+				portReferenceElement.setAttributeNS(XMLUtil.XMLNS_URI, XMLUtil.XMLNS_PREFIX
+						+ XMLUtil.WSA_PREFIX, XMLUtil.WSA_NAMESPACE_URI);
+				
+				doc.appendChild(portReferenceElement);
+				toXML(epr, doc, portReferenceElement, portReferenceElement, to);
+			}
+
+			StringWriter sWriter = new StringWriter();
+			OutputFormat format = new OutputFormat();
+			format.setIndenting(true);
+
+			XMLSerializer xmlS = new XMLSerializer(sWriter, format);
+
+			xmlS.asDOMSerializer();
+			xmlS.serialize(doc);
+
+			return sWriter.toString();
+		}
+		catch (ParserConfigurationException ex)
+		{
+			throw new MarshalException("Failed to construct DOM Document Builder.", ex);
+		}
+		catch (IOException ex)
+		{
+			throw new MarshalException("Error during DOM to String serialisation.", ex);
+		}
+	}
+
+	/**
+	 * Get the EPR from the string representation. If the EPR was a specific
+	 * type (e.g., JMSEpr) then it will be returned as an instance of the
+	 * appropriate class.
+	 * 
+	 * @param xml
+	 * @return
+	 * @throws UnmarshalException 
+	 */
+
+	public static final EPR fromXMLString(String xml) throws UnmarshalException
+	{
+		return fromXMLString(xml, false);
+	}
+
+	/**
+	 * Get the EPR from the string representation. If the EPR was a specific
+	 * type (e.g., JMSEpr) then it will be returned as an instance of the
+	 * appropriate class. Specify whether this is a To node in the Call.
+	 * 
+	 * @param xml
+	 * @return
+	 * @throws UnmarshalException 
+	 */
+
+	public static final EPR fromXMLString(String xml, boolean to) throws UnmarshalException
+	{
+		AssertArgument.isNotNull(xml, "xml");
+
+		try
+		{
+			DocumentBuilderFactory factory = DocumentBuilderFactory
+					.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			DocumentBuilder builder = factory.newDocumentBuilder();
+			Document doc = builder.parse(new ByteArrayInputStream(xml
+					.getBytes()));
+			Element rootElement = (Element) doc.getDocumentElement();
+
+			return fromXML(rootElement, to);
+		}
+		catch (SAXException ex)
+		{
+			throw new UnmarshalException("Unable to parse EPR XML.", ex);
+		}
+		catch (IOException ex)
+		{
+			throw new UnmarshalException("Unable to read EPR XML stream.", ex);
+		}
+		catch (ParserConfigurationException ex)
+		{
+			throw new UnmarshalException("Failed to construct DOM Document Builder.", ex);
+		}
+	}
+
+	private final static void setSpecificEPR(EPR epr)
+	{
+		String eprType = null;
+
+		/*
+		 * Do not re-order.
+		 */
+
+		if (epr instanceof EmailEpr)
+			eprType = EmailEpr.type().toString();
+		else if (epr instanceof SFTPEpr)
+			eprType = SFTPEpr.type().toString();
+		else if (epr instanceof HTTPEpr)
+			eprType = HTTPEpr.type().toString();
+		else if (epr instanceof JDBCEpr)
+			eprType = JDBCEpr.type().toString();
+		else if (epr instanceof JMSEpr)
+			eprType = JMSEpr.type().toString();
+		else if (epr instanceof FTPEpr)
+			eprType = FTPEpr.type().toString();
+		else if (epr instanceof FileEpr)
+			eprType = FileEpr.type().toString();
+
+		if (eprType != null)
+		{
+			if (epr.getAddr().getExtensionValue(EPR_TYPE) == null) {
+				epr.getAddr().addExtension(EPR_TYPE, eprType);
+			}
+		}
+	}
+
+	private final static EPR getSpecificEPR(EPR epr)
+	{
+		String eprType = epr.getAddr().getExtensionValue(EPR_TYPE);
+
+		if (eprType != null)
+		{
+			/*
+			 * Do not re-order.
+			 */
+
+			if (eprType.equals(EmailEpr.type().toString()))
+				return new EmailEpr(epr);
+			else if (eprType.equals(SFTPEpr.type().toString()))
+				return new SFTPEpr(epr);
+			else if (eprType.equals(HTTPEpr.type().toString()))
+				return new HTTPEpr(epr);
+			else if (eprType.equals(JDBCEpr.type().toString()))
+				return new JDBCEpr(epr);
+			else if (eprType.equals(JMSEpr.type().toString()))
+				return new JMSEpr(epr);
+			else if (eprType.equals(FTPEpr.type().toString()))
+				return new FTPEpr(epr);
+			else if (eprType.equals(FileEpr.type().toString()))
+				return new FileEpr(epr);
+			else
+				return epr;
+		} else {
+			return epr;
+		}
+	}
+
+	/**
+	 * Because of WS-A rules, if this was a To node then all of the elements
+	 * within the EPR are now at top-level in the header and not easily
+	 * obtained. We need to ask each EPR type to reconstitute itself.
+	 * 
+	 * @param epr
+	 * @param header
+	 * @return
+	 */
+
+	private final static EPR getSpecificEPR(EPR epr, Element header)
+	{
+		NodeList children = header.getChildNodes();
+		String eprType = null;
+
+		for (int i = 0; i < children.getLength(); i++)
+		{
+			String prefix = children.item(i).getPrefix();
+			String tag = children.item(i).getLocalName();
+			
+			if ((prefix != null) && (prefix.equals(XMLUtil.JBOSSESB_PREFIX)))
+			{
+				if ((tag != null) && (tag.equals(EPR_TYPE)))
+				{
+					eprType = children.item(i).getTextContent();
+				}
+			}
+		}
+
+		if (eprType != null)
+		{
+			/*
+			 * Do not re-order.
+			 */
+
+			if (eprType.equals(EmailEpr.type().toString()))
+				return new EmailEpr(epr, header);
+			else if (eprType.equals(SFTPEpr.type().toString()))
+				return new SFTPEpr(epr, header);
+			else if (eprType.equals(HTTPEpr.type().toString()))
+				return new HTTPEpr(epr, header);
+			else if (eprType.equals(JDBCEpr.type().toString()))
+				return new JDBCEpr(epr, header);
+			else if (eprType.equals(JMSEpr.type().toString()))
+				return new JMSEpr(epr, header);
+			else if (eprType.equals(FTPEpr.type().toString()))
+				return new FTPEpr(epr, header);
+			else if (eprType.equals(FileEpr.type().toString()))
+				return new FileEpr(epr, header);
+			else
+				return epr;
+		} else {
+			return epr;
+		}
+	}
+
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/PortReferenceHelper.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/PortReferenceHelper.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/addressing/helpers/PortReferenceHelper.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,433 @@
+/*
+ * 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
+ */
+
+/*
+ * Copyright (c) 2002, 2003, Arjuna Technologies Limited.
+ *
+ * PortReferenceHelper.java
+ */
+
+package org.jboss.internal.soa.esb.addressing.helpers;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.jboss.soa.esb.addressing.XMLUtil;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/*
+ * This should pack the PortReference into an ERP.
+ * 
+ * It would be better if PortReference had a packToXML and unpackFromXML.
+ * 
+ * This needs rewriting after the interoperability workshop!
+ */
+
+public class PortReferenceHelper
+{
+	/**
+	 * WS-Addressing is broken in that the To field is a URI, even if the From
+	 * field was an EPR! You have to use the EPR bits separately. So, the
+	 * toField is used to indicate whether we are packing this address as a To
+	 * field (when we need to treat it differently) or as an EPR.
+	 */
+
+	/** ************************************************** */
+	public static void toXML(org.w3c.dom.Element header,
+			org.w3c.dom.Document document,
+			org.w3c.dom.Element portReferenceElement,
+			PortReference portReference, boolean toField)
+			throws MarshalException
+	{
+		try
+		{
+			if (!toField)
+			{
+				Element addressElement = document.createElementNS(
+						XMLUtil.WSA_NAMESPACE_URI, XMLUtil.ADDRESS_TAG);
+				addressElement.setPrefix(XMLUtil.WSA_PREFIX);
+				addressElement.appendChild(document
+						.createTextNode(portReference.getAddress()));
+				portReferenceElement.appendChild(addressElement);
+			}
+			else
+			{
+				portReferenceElement.appendChild(document
+						.createTextNode(portReference.getAddress()));
+			}
+
+			Iterator extensions = portReference.getExtensions();
+			Element referenceProperties = null;
+
+			while (extensions.hasNext())
+			{
+				PortReference.Extension extension = (PortReference.Extension) extensions
+						.next();
+
+				/*
+				 * WS-Addressing is broken in that the To field is a URI, even
+				 * if the From field was an EPR! You have to use the EPR bits
+				 * separately. Doh!
+				 */
+
+				if (!toField)
+				{
+					if (referenceProperties == null)
+					{
+						referenceProperties = document.createElementNS(
+								XMLUtil.WSA_NAMESPACE_URI,
+								XMLUtil.REFERENCE_PROPERTIES_TAG);
+						referenceProperties.setPrefix(XMLUtil.WSA_PREFIX);
+						portReferenceElement.appendChild(referenceProperties);
+					}
+				}
+				else
+					referenceProperties = header;
+
+				extensionToXML(referenceProperties, document, extension);
+			}
+		}
+		catch (Exception exception)
+		{
+			exception.printStackTrace();
+			throw new MarshalException("Marshal failure: " + exception);
+		}
+	}
+
+	/** **************************** */
+	public static PortReference fromXML(
+			org.w3c.dom.Element portReferenceElement, boolean toField)
+			throws UnmarshalException
+	{
+		PortReference portReference = new PortReference();
+
+		if (toField)
+		{
+			portReference.setAddress(portReferenceElement.getTextContent());
+		}
+		
+		org.w3c.dom.NodeList elements = portReferenceElement.getChildNodes();
+		
+		for (int i = 0; i < elements.getLength(); i++)
+		{
+			final Object extensionObject = elements.item(i);
+			
+			if (extensionObject instanceof Element)
+			{
+				int parentNodeType = PortReference.Extension.NEITHER;
+				Element extensionElement = (Element) extensionObject;
+				NodeList children = extensionElement.getChildNodes();
+				String parentName = extensionElement.getNodeName();
+				boolean haveChildren = false;
+
+				if (parentName.equals(XMLUtil.REFERENCE_PROPERTIES_TAG))
+					parentNodeType = PortReference.Extension.REFERENCE_PROPERTIES;
+				else
+				{
+					if (parentName.equals(XMLUtil.REFERENCE_PARAMETERS_TAG))
+						parentNodeType = PortReference.Extension.REFERENCE_PARAMETERS;
+					else
+					{
+						if (!toField
+								&& parentName.equals(XMLUtil.WSA_PREFIX + ":"
+										+ XMLUtil.ADDRESS_TAG))
+						{
+							portReference.setAddress(extensionElement
+									.getTextContent());
+						}
+					}
+				}
+
+				final int numChildren = children.getLength();
+				
+				for (int count = 0; count < numChildren; count++)
+				{
+					final Object childObject = children.item(count);
+
+					if (childObject instanceof Element)
+					{
+						Element childElement = (Element) childObject;
+
+						portReference
+								.addExtension(childrenFromXML(childElement));
+						haveChildren = true;
+					}
+				}
+
+				if (!haveChildren && !parentName.equals(XMLUtil.WSA_PREFIX + ":"+ XMLUtil.ADDRESS_TAG))
+				{
+					PortReference.Extension ext = new PortReference.Extension(
+							extensionElement.getNodeName(), null, null,
+							extensionElement.getNodeValue(), parentNodeType);
+
+					portReference.addExtension(ext);
+
+					final NamedNodeMap attrs = extensionElement.getAttributes();
+					final int numAttrs = attrs.getLength();
+					if (numAttrs > 0)
+					{
+						final HashMap<ArjunaName, String> p = new HashMap<ArjunaName, String>();
+						for (int count = 0; count < numAttrs; count++)
+						{
+							final Attr attr = (Attr) attrs.item(count);
+							if (!"http://www.w3.org/2000/xmlns/".equals(attr
+									.getNamespaceURI()))
+							{
+								final ArjunaName name = generateName(attr);
+								p.put(name, attr.getValue());
+							}
+						}
+
+						ext.addAttributes(p);
+					}
+				}
+			}
+		}
+
+		return portReference;
+	}
+
+	private final static PortReference.Extension childrenFromXML(
+			Element childRoot)
+	{
+		final NodeList children = childRoot.getChildNodes();
+		final int numChildNodes = children.getLength();
+
+		final PortReference.Extension extension;
+		if (numChildNodes > 0)
+		{
+			Object childObject = children.item(0);
+			if (childObject instanceof Element)
+			{
+				extension = new PortReference.Extension(
+						childRoot.getNodeName(), childRoot.getPrefix(),
+						childRoot.getNamespaceURI());
+				
+				for (int count = 1; count < numChildNodes; count++)
+				{
+					extension.addChild(childrenFromXML((Element) childObject));
+					childObject = children.item(count);
+				}
+			}
+			else
+			{
+				extension = new PortReference.Extension(
+						childRoot.getNodeName(), childRoot.getPrefix(),
+						childRoot.getNamespaceURI(), ((Node) childObject)
+								.getNodeValue());
+			}
+		}
+		else
+		{
+			extension = new PortReference.Extension(childRoot.getNodeName(),
+					childRoot.getPrefix(), childRoot.getNamespaceURI(),
+					childRoot.getNodeValue());
+		}
+
+		final NamedNodeMap attrs = childRoot.getAttributes();
+		final int numAttrs = attrs.getLength();
+		if (numAttrs > 0)
+		{
+			final HashMap<ArjunaName, String> p = new HashMap<ArjunaName, String>();
+			for (int count = 0; count < numAttrs; count++)
+			{
+				final Attr attr = (Attr) attrs.item(count);
+				if (!"http://www.w3.org/2000/xmlns/".equals(attr
+						.getNamespaceURI()))
+				{
+					final ArjunaName name = generateName(attr);
+					p.put(name, attr.getValue());
+				}
+			}
+
+			extension.addAttributes(p);
+		}
+		return extension;
+	}
+
+	private final static Element extensionToXML(Element packInto,
+			org.w3c.dom.Document document, PortReference.Extension toPack)
+			throws MarshalException
+	{
+		final String uri = toPack.getURI();
+		final Element element;
+		if (uri == null)
+		{
+			element = document.createElement(toPack.getTag());
+		}
+		else
+		{
+			final String prefix = toPack.getPrefix();
+			element = document.createElementNS(uri, toPack.getTag());
+			element.setPrefix(prefix);
+			element.setAttributeNS(XMLUtil.XMLNS_URI, XMLUtil.XMLNS_PREFIX
+					+ toPack.getPrefix(), uri);
+		}
+		packInto.appendChild(element);
+
+		if (toPack.getValue() != null)
+		{
+			final Text text = document.createTextNode(toPack.getValue());
+			element.appendChild(text);
+		}
+
+		LinkedList extensions = toPack.getChildren();
+
+		if (extensions != null)
+		{
+			for (int i = 0; i < extensions.size(); i++)
+			{
+				PortReference.Extension ext = (PortReference.Extension) extensions
+						.get(i);
+
+				extensionToXML(element, document, ext);
+			}
+		}
+
+		HashMap attrs = toPack.getAttributes();
+
+		if (attrs != null)
+		{
+			Iterator names = attrs.entrySet().iterator();
+
+			while (names.hasNext())
+			{
+				Map.Entry entry = (Map.Entry) names.next();
+				ArjunaName name = (ArjunaName) entry.getKey();
+				final String value = (String) entry.getValue();
+				final String attrURI = name.getURI();
+				if (attrURI != null)
+				{
+					element.setAttributeNS(attrURI, name.getQualifiedName(),
+							value);
+				}
+				else
+				{
+					element.setAttribute(name.getQualifiedName(), value);
+				}
+			}
+		}
+
+		return element;
+	}
+
+	/**
+	 * Generate a name based on the attribute.
+	 * 
+	 * @param attr
+	 *            The current attribute.
+	 * @return The name
+	 */
+	private static ArjunaName generateName(final Attr attr)
+	{
+		final String localName = attr.getNodeName();
+		final String uri = attr.getNamespaceURI();
+		final String prefix = attr.getPrefix();
+
+		return new ArjunaName(uri, prefix, localName);
+	}
+
+	private static class ArjunaName
+	{
+		/**
+		 * The uri.
+		 */
+		private final String uri;
+
+		/**
+		 * The prefix.
+		 */
+		private final String prefix;
+
+		/**
+		 * The local name.
+		 */
+		private final String localName;
+
+		/**
+		 * Construct the name.
+		 * 
+		 * @param uri
+		 *            The uri.
+		 * @param prefix
+		 *            The prefix.
+		 * @param localName
+		 *            The local name.
+		 */
+		public ArjunaName(final String uri, final String prefix,
+				final String localName)
+		{
+			this.uri = uri;
+			this.prefix = prefix;
+			this.localName = localName;
+		}
+
+		/**
+		 * Get the uri.
+		 * 
+		 * @return the uri.
+		 */
+		public String getURI()
+		{
+			return uri;
+		}
+
+		/**
+		 * Get the prefix.
+		 * 
+		 * @return the prefix.
+		 */
+		public String getPrefix()
+		{
+			return prefix;
+		}
+
+		/**
+		 * Get the local name.
+		 * 
+		 * @return the local name.
+		 */
+		public String getLocalName()
+		{
+			return localName;
+		}
+
+		/**
+		 * Get the qualified name.
+		 * 
+		 * @return the qualified name.
+		 */
+		public String getQualifiedName()
+		{
+			return (prefix == null ? localName : prefix + ":" + localName);
+		}
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/assertion/AssertArgument.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/assertion/AssertArgument.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/assertion/AssertArgument.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,70 @@
+/*
+ * 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
+ */
+
+package org.jboss.internal.soa.esb.assertion;
+
+/**
+ * Argument assertion utilities.
+ * <p/>
+ * <b>Copied from <a href="http://www.milyn.org">milyn.org</a></b>.
+ *  
+ * @author tfennelly
+ */
+public abstract class AssertArgument {
+
+	/**
+	 * Assert that the argument is not null.
+	 * @param arg Argument.
+	 * @param argName Argument name.
+	 * @throws IllegalArgumentException Argument is null.
+	 */
+	public static void isNotNull(Object arg, String argName) throws IllegalArgumentException {
+		if (arg == null) {
+			throw new IllegalArgumentException("null '" + argName
+					+ "' arg in method call.");
+		}
+	}
+
+	/**
+	 * Assert that the argument is not empty.
+	 * @param arg Argument.
+	 * @param argName Argument name.
+	 * @throws IllegalArgumentException Argument is not null, but is empty.
+	 */
+	public static void isNotEmpty(String arg, String argName) throws IllegalArgumentException {
+		if (arg != null && arg.trim().equals("")) {
+			throw new IllegalArgumentException("Not null, but empty '"
+					+ argName + "' arg in method call.");
+		}
+	}
+
+	/**
+	 * Assert that the argument is neither null nor empty.
+	 * @param arg Argument.
+	 * @param argName Argument name.
+	 * @throws IllegalArgumentException Argument is null or empty.
+	 */
+	public static void isNotNullAndNotEmpty(String arg, String argName) throws IllegalArgumentException {
+		if (arg == null || arg.trim().equals("")) {
+			throw new IllegalArgumentException("null or empty '" + argName
+					+ "' arg in method call.");
+		}
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,136 @@
+package org.jboss.internal.soa.esb.message.format;
+
+import java.net.URI;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
+
+import org.jboss.internal.soa.esb.message.format.serialized.SerializedMessagePlugin;
+import org.jboss.internal.soa.esb.message.format.xml.XMLMessagePlugin;
+import org.jboss.soa.esb.common.ModulePropertyManager;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessagePlugin;
+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
+ */
+
+/**
+ * Messages may contain attachments that do not appear in the main payload body.
+ * For example, binary document formats, zip files etc.
+ * 
+ * @author Mark Little
+ */
+
+public class MessageFactoryImpl extends MessageFactory
+{
+
+	public MessageFactoryImpl ()
+	{
+		reset();
+	}
+
+	public void reset ()
+	{
+		messageFormats.clear();
+		
+		/*
+		 * Go through the properties loaded from the property file. Anything
+		 * starting with MessagePlugin.MESSAGE_PLUGIN is assumed to be a plugin
+		 * that we load and add to the list.
+		 */
+		
+		Properties properties = ModulePropertyManager.getPropertyManager(ModulePropertyManager.CORE_MODULE).getProperties();
+		
+		if (properties != null)
+		{
+			Enumeration names = properties.propertyNames();
+
+			while (names.hasMoreElements())
+			{
+				String attrName = (String) names.nextElement();
+				
+				if (attrName.startsWith(MessagePlugin.MESSAGE_PLUGIN))
+				{
+					try
+					{
+						String pluginName = properties.getProperty(attrName);
+						Class c = Class.forName(pluginName);
+						MessagePlugin thePlugin = (MessagePlugin) c.newInstance();
+
+						messageFormats.put(thePlugin.getType(), thePlugin);
+					}
+					catch (ClassNotFoundException ex)
+					{
+						ex.printStackTrace();
+					}
+					catch (IllegalAccessException ex)
+					{
+						ex.printStackTrace();
+					}
+					catch (InstantiationException ex)
+					{
+						ex.printStackTrace();
+					}
+				}
+			}
+		}
+	         
+		/*
+		 * Now add the default(s).
+		 */
+		
+		messageFormats.put(MessageType.JBOSS_XML, new XMLMessagePlugin());
+		messageFormats.put(MessageType.JAVA_SERIALIZED, new SerializedMessagePlugin());
+	}
+	
+	public Message getMessage() // returns some default implementation.
+	{
+		return ((MessagePlugin) messageFormats.get(MessageType.DEFAULT_TYPE)).getMessage();
+	}
+
+	public Message getMessage(URI type) // returns a message of a specific type.
+	{
+		if (type == null)
+			throw new IllegalArgumentException();
+
+		MessagePlugin plugin = messageFormats.get(type);
+
+		if (plugin != null)
+			return plugin.getMessage();
+		else
+			return null;
+	}
+
+	public Message getMessage(Message msg, URI type) // convert a message
+	// from one form to
+	// another.
+	{
+		if ((msg == null) || (type == null))
+			throw new IllegalArgumentException();
+
+		return null;
+	}
+
+	private final Hashtable<URI, MessagePlugin> messageFormats = new Hashtable<URI, MessagePlugin>();
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/AttachmentImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/AttachmentImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/AttachmentImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,152 @@
+/*
+ * 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
+ */
+
+package org.jboss.internal.soa.esb.message.format.serialized;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.jboss.soa.esb.message.Attachment;
+
+/**
+ * Messages may contain attachments that do not appear in the main payload body.
+ * For example, binary document formats, zip files etc.
+ * 
+ * @author Mark Little
+ */
+
+public class AttachmentImpl implements Attachment, java.io.Serializable
+{
+	private static final long serialVersionUID = 0x0;
+
+	public Object get(String name)
+	{
+		return _table.get(name);
+	}
+
+	public Object put(String name, Object value) 
+	{
+		if (value instanceof Serializable)
+			return _table.put(name,(Serializable)value);
+		throw new IllegalArgumentException("value must be Serializable");
+	}
+
+	public Object remove(String name) 
+	{
+		return _table.remove(name);
+	}
+
+	public String[] getNames() 
+	{
+		return _table.keySet().toArray(new String[_table.size()]);
+	}
+
+	public Object itemAt(int index) throws IndexOutOfBoundsException 
+	{
+		return _list.get(index);
+	}
+
+	public Object removeItemAt(int index) throws IndexOutOfBoundsException 
+	{
+		return _list.remove(index);
+	}
+
+	public Object replaceItemAt(int index, Object value) throws IndexOutOfBoundsException 
+	{
+		if (value instanceof Serializable)
+			return _list.set(index,(Serializable)value);
+		throw new IllegalArgumentException("value must be Serializable");
+	}
+
+	public void addItem(Object value) 
+	{
+		if (value instanceof Serializable)
+			_list.add((Serializable)value);
+		else
+			throw new IllegalArgumentException("value must be Serializable");
+	}
+
+	public void addItemAt(int index, Object value) throws IndexOutOfBoundsException 
+	{
+		if (value instanceof Serializable)
+			_list.add(index,(Serializable)value);
+		else
+			throw new IllegalArgumentException("value must be Serializable");
+	}
+
+	public int getNamedCount() 
+	{
+		return _table.size();
+	}
+	public int getUnnamedCount() 
+	{
+		return _list.size();
+	}
+	public String toString() 
+	{ return new StringBuilder()
+		.append("Attachment - Named:").append(_table.toString())
+		.append(" Unnamed:").append(_list.toString())
+		.toString();
+	}
+	
+	@Override
+	public boolean equals(Object arg)
+	{
+		if (! (arg instanceof Attachment))
+			return false;
+		Attachment other = (Attachment)arg;
+
+		if (other.getNamedCount() != _table.size())
+			return false;
+		for(Map.Entry<String,Serializable>oCurr : _table.entrySet())
+		{	
+			Object val = other.get(oCurr.getKey());
+			if (null==oCurr.getValue())
+				if (null==val)
+					continue;
+				else
+					return false;
+			if (!oCurr.getValue().equals(val))
+				return false;
+		}
+
+		if (other.getUnnamedCount() != _list.size())
+			return false;
+		int index = 0;
+		for (Serializable oCurr : _list)
+		{
+			Object val = other.itemAt(index++);
+			if (null==oCurr)
+				if (null==val)
+					continue;
+				else
+					return false;
+			if (!oCurr.equals(val))
+				return false;
+		}
+		return true;		
+	}
+
+	ArrayList<Serializable> _list = new ArrayList<Serializable>();
+	Hashtable<String,Serializable> _table = new Hashtable<String,Serializable>();
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,139 @@
+package org.jboss.internal.soa.esb.message.format.serialized;
+
+import java.io.Serializable;
+import java.util.Hashtable;
+import java.util.Set;
+
+import org.jboss.soa.esb.message.Body;
+
+/*
+ * 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 implementation requires that all contents are serializable.
+ */
+
+public class BodyImpl implements Body, java.io.Serializable
+{
+	private static final long serialVersionUID = 0x0;
+	
+	public BodyImpl ()
+	{
+		_content = null;
+		_objects = new Hashtable<String, Serializable>();
+	}
+	
+	public void setContents (byte[] content)
+	{
+		_content = content;
+	}
+
+	public byte[] getContents ()
+	{
+		return _content;
+	}
+	
+	public void add (String name, Object value)
+	{
+		if ((name == null) || (value == null))
+			throw new IllegalArgumentException();
+		
+		if (value instanceof Serializable)
+		{
+			synchronized (_objects)
+			{
+				_objects.put(name, (Serializable) value);
+			}
+		}
+		else
+			throw new IllegalArgumentException("Object must be Serializable.");
+	}
+	
+	public Object get (String name)
+	{
+		synchronized (_objects)
+		{
+			return _objects.get(name);
+		}
+	}
+	
+	public String[] getNames ()
+	{
+		Set<String> keys = _objects.keySet();
+		
+		if (keys != null)
+		{
+			String[] toReturn = new String[keys.size()];
+		
+			return keys.toArray(toReturn);
+		}
+		else
+			return null;
+	}
+	
+	public Object remove (String name)
+	{
+		synchronized (_objects)
+		{
+			return _objects.remove(name);
+		}
+	}
+	
+	public void replace (Body b)
+	{
+		if (b == null)
+			throw new IllegalArgumentException();
+		
+		setContents(b.getContents());
+		
+		_objects = ((BodyImpl) b)._objects;
+	}
+	
+	public void merge (Body b)
+	{
+		if (b == null)
+			throw new IllegalArgumentException();
+		
+		byte[] toAdd = b.getContents();
+		
+		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);
+				
+				_content = buffer;
+			}
+		}
+	}
+	
+	private byte[] _content;
+	private Hashtable<String, Serializable> _objects;
+	
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/ContextImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/ContextImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/ContextImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,29 @@
+package org.jboss.internal.soa.esb.message.format.serialized;
+
+import org.jboss.soa.esb.message.Context;
+
+/*
+ * 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
+ */
+
+public class ContextImpl implements Context, java.io.Serializable
+{
+	private static final long serialVersionUID = 0x0;
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/FaultImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/FaultImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/FaultImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,55 @@
+package org.jboss.internal.soa.esb.message.format.serialized;
+
+import java.net.URI;
+
+import org.jboss.soa.esb.message.Fault;
+
+/*
+ * 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
+ */
+
+public class FaultImpl implements Fault, java.io.Serializable
+{
+	private static final long serialVersionUID = 0x0;
+	
+	public URI getCode ()
+	{
+		return _code;
+	}
+	
+	public void setCode (URI code)
+	{
+		_code = code;
+	}
+	
+	public String getReason ()
+	{
+		return _reason;
+	}
+	
+	public void setReason (String reason)
+	{
+		_reason = reason;
+	}
+	
+	private URI _code = null;
+	private String _reason = null;
+	
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,161 @@
+package org.jboss.internal.soa.esb.message.format.serialized;
+
+/*
+ * 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
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.io.StringWriter;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.jboss.internal.soa.esb.addressing.helpers.CallHelper;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.message.Header;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
+/**
+ * The message header. Contains such things as routing information.
+ */
+
+public class HeaderImpl implements Header, Serializable
+{
+	private static final long serialVersionUID = 0x0;
+	
+	public static final String HEADER_TAG = "Header";
+	
+	public HeaderImpl ()
+	{
+		_call = new Call();
+	}
+	
+	// TODO add other setters/getters for artibitrary attributes
+	
+	public Call getCall ()
+	{
+		return _call;
+	}
+	
+	public void setCall (Call call)
+	{
+		if (call == null)
+			throw new IllegalArgumentException();
+		
+		_call = call;
+	}
+
+	/*
+	 * Call and PortReference aren't Serializable so we have to do some
+	 * magic.
+	 */
+	
+	private void writeObject(java.io.ObjectOutputStream out) throws IOException
+	{
+		if (_call != null)
+		{
+			try
+			{
+				DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+				
+				factory.setNamespaceAware(true);
+
+				DocumentBuilder builder = factory.newDocumentBuilder();
+				Document doc = builder.newDocument();
+				Element header = doc.createElement(HEADER_TAG);	
+				
+				doc.appendChild(header);
+				
+				header = CallHelper.toXML(_call, doc, header);
+				
+				StringWriter sWriter = new StringWriter();
+				OutputFormat format = new OutputFormat();
+				format.setIndenting(true);
+				XMLSerializer xmlS = new XMLSerializer(sWriter, format);
+				xmlS.asDOMSerializer();
+				xmlS.serialize(doc);
+
+				out.writeObject(sWriter.toString());
+			}
+			catch (MarshalException ex)
+			{
+				ex.printStackTrace();
+				
+				throw new IOException(ex.toString());
+			}
+			catch (ParserConfigurationException ex)
+			{
+				ex.printStackTrace();
+				
+				throw new IOException(ex.toString());
+			}
+		}	
+	}
+	
+	private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
+	{
+		try
+		{
+			String header = (String) in.readObject();
+			InputStream inStream = new ByteArrayInputStream(header.getBytes());
+			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+
+			DocumentBuilder builder = factory.newDocumentBuilder();				
+			Document doc = builder.parse(inStream);
+	
+			Element headerElement = doc.getDocumentElement();
+			
+			_call = CallHelper.fromXML(headerElement);
+		}
+		catch (UnmarshalException ex)
+		{
+			ex.printStackTrace();
+			
+			throw new IOException(ex.toString());
+		}
+		catch (ParserConfigurationException ex)
+		{
+			ex.printStackTrace();
+			
+			throw new IOException(ex.toString());
+		}
+		catch (SAXException ex)
+		{
+			ex.printStackTrace();
+			
+			throw new IOException(ex.toString());
+		}
+	}
+	
+	private Call _call;
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,129 @@
+/*
+ * 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
+ */
+package org.jboss.internal.soa.esb.message.format.serialized;
+
+import java.io.Serializable;
+import java.net.URI;
+
+import org.jboss.soa.esb.message.Attachment;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Context;
+import org.jboss.soa.esb.message.Fault;
+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.format.MessageType;
+
+
+/**
+ * This is the basic internal core message abstraction. A message consists of the following
+ * components:
+ * 
+ * Header: the header information contains information such as the destination EPR, the
+ * sender EPR, where the reply goes etc, i.e., general message-level functional information.
+ * Context: additional information to contextualise the message; for example, transaction or
+ * security data, the identity of the ultimate receiver, or HTTP-cookie like information.
+ * Body: the actual payload of the message.
+ * Fault: any fault information associated with the message.
+ * Attachment: any attachments associated with the message.
+ * 
+ * Each message, once created, has a corresponding element for these 5 components. That element
+ * may be empty (<b>NOT NULL</b>). The object representing the element can then be used to act
+ * on the corresponding data item in the message.
+ * 
+ * @author Mark Little
+ *
+ */
+
+public class MessageImpl implements Message, Serializable
+{
+	private static final long serialVersionUID = 0x0;
+	
+	/**
+	 * @return get the header component of the message.
+	 */
+	
+	public Header getHeader ()
+	{
+		return _theHeader;
+	}
+	
+	/**
+	 * @return get the context component of the message.
+	 */
+	
+	public Context getContext ()
+	{
+		return _theContext;
+	}
+	
+	/**
+	 * @return get the body component of the message.
+	 */
+	
+	public Body getBody ()
+	{
+		return _theBody;
+	}
+	
+	/**
+	 * @return get any faults associated with the message. These should not
+	 * be application level faults, but comms level.
+	 */
+	
+	public Fault getFault ()
+	{
+		return _theFault;
+	}
+	
+	/**
+	 * @return get any message attachments.
+	 */
+	
+	public Attachment getAttachment ()
+	{
+		return _theAttachment;
+	}
+	
+	/**
+	 * @return the type of this message format.
+	 */
+	
+	public URI getType ()
+	{
+		return MessageType.JAVA_SERIALIZED;
+	}
+
+	/**
+	 * @return Map&lt;String,Object&gt; - any message properties.
+	 */
+	public Properties getProperties() 
+	{
+		return _properties;
+	}
+
+	private HeaderImpl _theHeader = new HeaderImpl();
+	private ContextImpl _theContext = new ContextImpl();
+	private BodyImpl _theBody = new BodyImpl();
+	private FaultImpl _theFault = new FaultImpl();
+	private AttachmentImpl _theAttachment = new AttachmentImpl();
+	private Properties _properties = new PropertiesImpl();
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,92 @@
+/*
+ * 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 schifest at heuristica.com.ar
+ */
+package org.jboss.internal.soa.esb.message.format.serialized;
+
+import java.io.Serializable;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.jboss.soa.esb.message.Properties;
+
+public class PropertiesImpl implements Properties, Serializable
+{
+	private static final long serialVersionUID = 0x0;
+
+	public Object getProperty(String name)
+	{
+		return _table.get(name);
+	}
+
+	public Object getProperty(String name, Object defaultVal)
+	{
+		Object oRet = getProperty(name);
+		return (null == oRet) ? defaultVal : oRet;
+	}
+
+	public Object setProperty(String name, Object value)
+	{
+		if (value instanceof Serializable)
+			return _table.put(name, (Serializable) value);
+		else
+			throw new IllegalArgumentException("Value must be serializable");
+	}
+
+	public Object remove(String name)
+	{
+		return _table.remove(name);
+	}
+	
+	public int size() {return _table.size(); } 
+
+	public String[] getNames()
+	{
+		return _table.keySet().toArray(new String[_table.size()]);
+	}
+
+	public String toString()
+	{
+		return _table.toString();
+	}
+
+	@Override
+	public boolean equals(Object arg)
+	{
+		if (! (arg instanceof Properties))
+			return false;
+		Properties other = (Properties)arg;
+		if (other.size() != _table.size())
+			return false;
+		for(Map.Entry<String,Serializable>oCurr : _table.entrySet())
+		{	
+			Object val = other.getProperty(oCurr.getKey());
+			if (null==oCurr.getValue())
+				if (null==val)
+					continue;
+				else
+					return false;
+			if (!oCurr.getValue().equals(val))
+				return false;
+		}
+		return true;
+	}
+
+	Hashtable<String, Serializable> _table = new Hashtable<String, Serializable>();
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/SerializedMessagePlugin.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/SerializedMessagePlugin.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/SerializedMessagePlugin.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,48 @@
+package org.jboss.internal.soa.esb.message.format.serialized;
+
+import java.net.URI;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessagePlugin;
+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
+ */
+
+/**
+ * Used to plug in new message formats dynamically.
+ *  
+ * @author Mark Little
+ *
+ */
+
+public class SerializedMessagePlugin implements MessagePlugin
+{
+	public Message getMessage ()
+	{
+		return new MessageImpl();
+	}
+	
+	public URI getType ()
+	{
+		return MessageType.JAVA_SERIALIZED;
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,272 @@
+/*
+ * 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
+ */
+
+package org.jboss.internal.soa.esb.message.format.xml;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.jboss.internal.soa.esb.thirdparty.Base64;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.message.Attachment;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Messages may contain attachments that do not appear in the main payload body.
+ * For example, binary document formats, zip files etc.
+ * 
+ * @author Mark Little
+ */
+
+public class AttachmentImpl implements Attachment, java.io.Serializable
+{
+	public static final String ATTACHMENT_TAG = "Attachment";
+	public static final String NAME_ATTR = "name";
+    public static final String NAMED_TAG = "Named";
+    public static final String UNNAMED_TAG = "UnNamed";
+
+	private static final long serialVersionUID = 0x0;
+
+	public Object get(String name)
+	{
+		return _table.get(name);
+	}
+
+	public Object put(String name, Object value)
+	{
+		if (value instanceof Serializable)
+			return _table.put(name, (Serializable) value);
+		throw new IllegalArgumentException("value must be Serializable");
+	}
+
+	public Object remove(String name)
+	{
+		return _table.remove(name);
+	}
+
+	public String[] getNames()
+	{
+		return _table.keySet().toArray(new String[_table.size()]);
+	}
+
+	public Object itemAt(int index) throws IndexOutOfBoundsException
+	{
+		return _list.get(index);
+	}
+
+	public Object removeItemAt(int index) throws IndexOutOfBoundsException
+	{
+		return _list.remove(index);
+	}
+
+	public Object replaceItemAt(int index, Object value)
+			throws IndexOutOfBoundsException
+	{
+		if (value instanceof Serializable)
+			return _list.set(index, (Serializable) value);
+		throw new IllegalArgumentException("value must be Serializable");
+	}
+
+	public void addItem(Object value)
+	{
+		if (value instanceof Serializable)
+			_list.add((Serializable) value);
+		else
+			throw new IllegalArgumentException("value must be Serializable");
+	}
+
+	public void addItemAt(int index, Object value)
+			throws IndexOutOfBoundsException
+	{
+		if (value instanceof Serializable)
+			_list.add(index, (Serializable) value);
+		else
+			throw new IllegalArgumentException("value must be Serializable");
+	}
+
+	public int getNamedCount()
+	{
+		return _table.size();
+	}
+
+	public int getUnnamedCount()
+	{
+		return _list.size();
+	}
+
+	public String toString()
+	{
+		return new StringBuilder().append("Attachment - Named:").append(
+				_table.toString()).append(" Unnamed:").append(_list.toString())
+				.toString();
+	}
+
+	/**
+	 * toXML(elem) - Will build a child element with appropriate values and
+	 * append it to arg0
+	 * 
+	 * @param elem
+	 *            Element - where to add 'this' as a child node
+	 * @return Element - 'this' as the added Element, or &lt;null&gt; if no
+	 *         properties in table and nothing was appended to arg0
+	 * @see XMLUtil.ATTACHMENT_TAG
+	 */
+	public Element toXML(Element elem) throws MarshalException
+	{
+		if (_table.size() < 1 && _list.size() < 1)
+			return null;
+
+		Document doc = elem.getOwnerDocument();
+		Element thisElement = doc.createElement(ATTACHMENT_TAG);
+
+		listToXml(doc, thisElement);
+		tableToXml(doc, thisElement);
+
+		elem.appendChild(thisElement);
+		return thisElement;
+	}
+
+	private void tableToXml(Document doc, Element elem)
+	{
+		for (Map.Entry<String, Serializable> oCurr : _table.entrySet())
+		{
+			Element named = doc.createElement(NAMED_TAG);
+			named.setAttribute(NAME_ATTR, oCurr.getKey());
+			named.appendChild(doc.createCDATASection(Base64.encodeObject(oCurr
+					.getValue())));
+			elem.appendChild(named);
+		}
+	}
+
+	private void listToXml(Document doc, Element elem)
+	{
+		for (Serializable oCurr : _list)
+		{
+			Element anonymous = doc.createElement(UNNAMED_TAG);
+			anonymous.appendChild(doc.createCDATASection(Base64
+					.encodeObject(oCurr)));
+			elem.appendChild(anonymous);
+		}
+	}
+
+	/**
+	 * fromXml(elem) - Populate properties found in appropriate child element
+	 * 
+	 * @see XMLUtil.ATTACHMENT_TAG
+	 * @param elem -
+	 *            Element where to look for child nodes
+	 */
+	public void fromXML(Element elem) throws UnmarshalException
+	{
+		_table.clear();
+		_list.clear();
+
+		NodeList NL = elem.getElementsByTagName(ATTACHMENT_TAG);
+		for (int i1 = 0; i1 < NL.getLength(); i1++)
+		{
+			Node oCurr = NL.item(i1);
+			if ((oCurr instanceof Element))
+			{
+				listFromXml((Element) oCurr);
+				tableFromXml((Element) oCurr);
+			}
+		}
+	}
+
+	private void listFromXml(Element elem)
+	{
+		NodeList anonymous = elem.getElementsByTagName(UNNAMED_TAG);
+		for (int i1 = 0; i1 < anonymous.getLength(); i1++)
+		{
+			Node oCurr = anonymous.item(i1);
+			if (oCurr instanceof Element)
+			{
+				CDATASection cdata = (CDATASection) oCurr.getFirstChild();
+				Object value = Base64.decodeToObject(cdata.getWholeText());
+				_list.add((Serializable) value);
+			}
+		}
+	}
+
+	private void tableFromXml(Element elem)
+	{
+		NodeList named = elem.getElementsByTagName(NAMED_TAG);
+		for (int i1 = 0; i1 < named.getLength(); i1++)
+		{
+			Node oCurr = named.item(i1);
+			if (oCurr instanceof Element)
+			{
+				CDATASection cdata = (CDATASection) oCurr.getFirstChild();
+				String name = ((Element) oCurr).getAttribute(NAME_ATTR);
+				Object value = Base64.decodeToObject(cdata.getWholeText());
+				_table.put(name, (Serializable) value);
+			}
+		}
+	}
+
+	@Override
+	public boolean equals(Object arg)
+	{
+		if (! (arg instanceof Attachment))
+			return false;
+		Attachment other = (Attachment)arg;
+
+		if (other.getNamedCount() != _table.size())
+			return false;
+		for(Map.Entry<String,Serializable>oCurr : _table.entrySet())
+		{	
+			Object val = other.get(oCurr.getKey());
+			if (null==oCurr.getValue())
+				if (null==val)
+					continue;
+				else
+					return false;
+			if (!oCurr.getValue().equals(val))
+				return false;
+		}
+
+		if (other.getUnnamedCount() != _list.size())
+			return false;
+		int index = 0;
+		for (Serializable oCurr : _list)
+		{
+			Object val = other.itemAt(index++);
+			if (null==oCurr)
+				if (null==val)
+					continue;
+				else
+					return false;
+			if (!oCurr.equals(val))
+				return false;
+		}
+		return true;		
+	}
+
+	ArrayList<Serializable> _list = new ArrayList<Serializable>();
+	Hashtable<String, Serializable> _table = new Hashtable<String, Serializable>();
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,285 @@
+package org.jboss.internal.soa.esb.message.format.xml;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Set;
+
+import org.jboss.internal.soa.esb.message.format.xml.marshal.MarshalUnmarshalManager;
+import org.jboss.internal.soa.esb.thirdparty.Base64;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.message.Body;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/*
+ * 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
+ */
+
+/*
+ * A Body implementation that serializes to XML.
+ */
+
+public class BodyImpl implements Body
+{
+	public static final String BODY_TAG = "Body";
+
+	public static final String BYTES_TAG = "Bytes";
+
+	public static final String CONTENT_TAG = "Content";
+
+	public static final String KEY_TAG = "Key";
+
+	public static final String VALUE_TAG = "Value";
+
+	public BodyImpl()
+	{
+		_content = null;
+		_objects = new Hashtable<String, Object>();
+	}
+
+	public void add(String name, Object value)
+	{
+		if ((name == null) || (value == null))
+			throw new IllegalArgumentException();
+
+		synchronized (_objects)
+		{
+			_objects.put(name, value);
+		}
+	}
+
+	public Object get(String name)
+	{
+		synchronized (_objects)
+		{
+			return _objects.get(name);
+		}
+	}
+
+	public String[] getNames()
+	{
+		Set<String> keys = _objects.keySet();
+
+		if (keys != null)
+		{
+			String[] toReturn = new String[keys.size()];
+
+			return keys.toArray(toReturn);
+		}
+		else
+			return null;
+	}
+
+	public Object remove(String name)
+	{
+		synchronized (_objects)
+		{
+			return _objects.remove(name);
+		}
+	}
+
+	public Element toXML(Element envelope) throws MarshalException
+	{
+		Document doc = envelope.getOwnerDocument();
+		Element bodyElement = doc.createElement(BODY_TAG);
+
+		envelope.appendChild(bodyElement);
+
+		if (_content != null)
+		{
+			Element byteElement = doc.createElement(BYTES_TAG);
+
+			byteElement.appendChild(doc.createCDATASection(Base64
+					.encodeBytes(_content)));
+
+			bodyElement.appendChild(byteElement);
+		}
+
+		/*
+		 * This would normally be handled by an external adapter.
+		 */
+
+		Enumeration<String> keys = _objects.keys();
+
+		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);
+
+			keyElement.appendChild(doc.createCDATASection(Base64
+					.encodeBytes(key.getBytes())));
+
+			objElement.appendChild(keyElement);
+			objElement.appendChild(valueElement);
+
+			if (MarshalUnmarshalManager.getInstance().marshal(valueElement,
+					value))
+			{
+				bodyElement.appendChild(objElement);
+			}
+			else
+				throw new MarshalException("Cannot pack object " + key);
+		}
+
+		return bodyElement;
+	}
+
+	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.
+			 */
+
+			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);
+
+					if (!(xxx instanceof Element))
+						continue;
+
+					Element node = (Element) xxx;
+
+					if (node.getNodeName().equals(BYTES_TAG))
+					{
+						CDATASection cdata = (CDATASection) node
+								.getFirstChild();
+
+						// 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();
+
+							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));
+
+								if (childList.item(k).getNodeName().equals(
+										KEY_TAG))
+								{
+									CDATASection cdata = (CDATASection) childList.item(k).getFirstChild();
+
+									key = new String(Base64.decode(cdata
+											.getWholeText()));
+								}
+							}
+
+							if (value == null)
+								throw new UnmarshalException(
+										"Cannot unpack object "
+												+ node.getNodeName());
+							else
+								_objects.put(key, value);
+						}
+					}
+				}
+			}
+		}
+	}
+
+	public void setContents(byte[] content)
+	{
+		_content = content;
+	}
+
+	public byte[] getContents()
+	{
+		return _content;
+	}
+
+	public void replace(Body b)
+	{
+		if (b == null)
+			throw new IllegalArgumentException();
+
+		setContents(b.getContents());
+
+		_objects = ((BodyImpl) b)._objects;
+	}
+
+	public void merge(Body b)
+	{
+		if (b == null)
+			throw new IllegalArgumentException();
+
+		byte[] toAdd = b.getContents();
+
+		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);
+
+				_content = buffer;
+			}
+		}
+
+		_objects.putAll(((BodyImpl) b)._objects);
+	}
+
+	private byte[] _content;
+
+	private Hashtable<String, Object> _objects;
+
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,47 @@
+package org.jboss.internal.soa.esb.message.format.xml;
+
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.message.Context;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/*
+ * 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
+ */
+
+public class ContextImpl implements Context
+{
+    public static final String CONTEXT_TAG = "Context";
+    
+	public Element toXML (Element envelope) throws MarshalException
+	{
+		Document doc = envelope.getOwnerDocument();
+		Element contextElement = doc.createElement(CONTEXT_TAG);
+		
+		envelope.appendChild(contextElement);
+		
+		return contextElement;
+	}
+	
+	public void fromXML (Element envelope) throws UnmarshalException
+	{
+	}
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,136 @@
+package org.jboss.internal.soa.esb.message.format.xml;
+
+import java.net.URI;
+
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.message.Fault;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/*
+ * 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
+ */
+
+public class FaultImpl implements Fault
+{
+	public static final String FAULT_TAG = "Fault";
+
+	public static final String CODE_TAG = "Code";
+
+	public static final String REASON_TAG = "Reason";
+
+	public URI getCode()
+	{
+		return _code;
+	}
+
+	public void setCode(URI code)
+	{
+		_code = code;
+	}
+
+	public String getReason()
+	{
+		return _reason;
+	}
+
+	public void setReason(String reason)
+	{
+		_reason = reason;
+	}
+
+	public Element toXML(Element envelope) throws MarshalException
+	{
+		Document doc = envelope.getOwnerDocument();
+		Element faultElement = doc.createElement(FAULT_TAG);
+
+		if (_code != null)
+		{
+			Element codeElement = doc.createElement(CODE_TAG);
+			Text content = doc.createTextNode(_code.toString());
+			
+			codeElement.appendChild(content);
+			
+			faultElement.appendChild(codeElement);
+		}
+
+		if (_reason != null)
+		{
+			Element reasonElement = doc.createElement(REASON_TAG);
+			Text content = doc.createTextNode(_reason);
+			
+			reasonElement.appendChild(content);
+
+			faultElement.appendChild(reasonElement);
+		}
+
+		if ((_code != null) || (_reason != null))
+		{
+			envelope.appendChild(faultElement);
+			
+			return faultElement;
+		}
+		else
+			return envelope;
+	}
+
+	public void fromXML (Element envelope) throws UnmarshalException
+	{
+		NodeList nl = envelope.getChildNodes();
+
+		_code = null;
+		_reason = null;
+		
+		for (int i = 0; i < nl.getLength(); i++)
+		{
+			if (nl.item(i).getNodeName().equals(FAULT_TAG))
+			{
+				NodeList children = nl.item(i).getChildNodes();
+
+				for (int j = 0; j < children.getLength(); j++)
+				{
+					Element child = (Element) children.item(j);
+
+					if (child.getNodeName().equals(CODE_TAG))
+					{
+						try
+						{
+							_code = new URI(child.getFirstChild().getNodeValue());
+						}
+						catch (Exception ex)
+						{
+							ex.printStackTrace();
+						}
+					}
+
+					if (child.getNodeName().equals(REASON_TAG))
+						_reason = child.getFirstChild().getNodeValue();
+				}
+			}
+		}
+	}
+
+	private URI _code = null;
+	private String _reason = null;
+
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,103 @@
+package org.jboss.internal.soa.esb.message.format.xml;
+
+/*
+ * 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
+ */
+
+import org.jboss.internal.soa.esb.addressing.helpers.CallHelper;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.message.Header;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * The message header. Contains such things as routing information.
+ */
+
+public class HeaderImpl implements Header
+{
+    public static final String HEADER_TAG = "Header";
+    
+	public HeaderImpl ()
+	{
+		_call = new Call();
+	}
+	
+	// TODO add other setters/getters for artibitrary attributes
+	
+	public Call getCall ()
+	{
+		return _call;
+	}
+	
+	public void setCall (Call call)
+	{
+		if (call == null)
+			throw new IllegalArgumentException();
+		
+		_call = call;
+	}
+	
+	public Element toXML (Element envelope) throws MarshalException
+	{
+		Document doc = envelope.getOwnerDocument();
+		
+		// TODO remove MAGIC strings!!
+		
+		Element headerElement = doc.createElement(HEADER_TAG);
+		
+		envelope.appendChild(headerElement);
+		
+		if (_call != null)
+			return CallHelper.toXML(_call, doc, headerElement);
+		else
+			return headerElement;
+	}
+	
+	public void fromXML (Element envelope) throws UnmarshalException
+	{
+		_call = new Call();
+		
+		NodeList nl = envelope.getChildNodes();
+		Element headerElement = null;
+		
+		for (int i = 0; i < nl.getLength(); i++)
+		{
+			Node n = nl.item(i);
+			
+			if (n.getNodeName().equals(HEADER_TAG))
+			{
+				headerElement = (Element) n;
+				break;
+			}
+		}
+		
+		// TODO error handling!!
+		
+		if (headerElement != null)
+			_call = CallHelper.fromXML(headerElement);
+	}
+	
+	private Call _call;
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,210 @@
+/*
+ * 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
+ */
+package org.jboss.internal.soa.esb.message.format.xml;
+
+import java.io.Serializable;
+import java.net.URI;
+
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.message.Attachment;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Context;
+import org.jboss.soa.esb.message.Fault;
+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.format.MessageType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+/**
+ * This is the basic internal core message abstraction. A message consists of the following
+ * components:
+ * 
+ * Header: the header information contains information such as the destination EPR, the
+ * sender EPR, where the reply goes etc, i.e., general message-level functional information.
+ * Context: additional information to contextualise the message; for example, transaction or
+ * security data, the identity of the ultimate receiver, or HTTP-cookie like information.
+ * Body: the actual payload of the message.
+ * Fault: any fault information associated with the message.
+ * Attachment: any attachments associated with the message.
+ * Properties: any properties associated with the message.
+ * 
+ * Each message, once created, has a corresponding element for these 5 components. That element
+ * may be empty (<b>NOT NULL</b>). The object representing the element can then be used to act
+ * on the corresponding data item in the message.
+ * 
+ * @author Mark Little
+ *
+ */
+
+public class MessageImpl implements Message, Serializable
+{
+    private static final long serialVersionUID = 0x0;
+    
+    public static final String ENVELOPE_TAG = "Envelope";
+    
+	/**
+	 * @return get the header component of the message.
+	 */
+	
+	public Header getHeader ()
+	{
+		return _theHeader;
+	}
+	
+	/**
+	 * @return get the context component of the message.
+	 */
+	
+	public Context getContext ()
+	{
+		return _theContext;
+	}
+	
+	/**
+	 * @return get the body component of the message.
+	 */
+	
+	public Body getBody ()
+	{
+		return _theBody;
+	}
+	
+	/**
+	 * @return get any faults associated with the message. These should not
+	 * be application level faults, but comms level.
+	 */
+	
+	public Fault getFault ()
+	{
+		return _theFault;
+	}
+	
+	/**
+	 * @return get any message attachments.
+	 */
+	
+	public Attachment getAttachment ()
+	{
+		return _theAttachment;
+	}
+	
+	/**
+	 * @return the type of this message format.
+	 */
+	
+	public URI getType ()
+	{
+		return MessageType.JBOSS_XML;
+	}
+	/**
+	 * getProperties()
+	 * @return org.jboss.soa.esb.message.Properties - any message properties.
+	 */
+	public Properties getProperties() 
+	{
+		return _theProperties;
+	}
+	
+	// to/from XML here, rather than on individual elements
+	
+	public Document toXML (Document doc) throws MarshalException
+	{
+		try
+		{		
+			// TODO remove magic strings!
+			
+			Element envelope = doc.createElement(ENVELOPE_TAG);
+
+			doc.appendChild(envelope);
+			
+			_theHeader.toXML(envelope);
+			_theContext.toXML(envelope);
+			_theBody.toXML(envelope);
+			_theFault.toXML(envelope);
+			_theAttachment.toXML(envelope);
+			_theProperties.toXML(envelope);
+			
+			return doc;
+		}
+		catch (MarshalException ex)
+		{
+			throw ex;
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			throw new MarshalException(ex);
+		}
+	}
+	
+	public void fromXML (Document doc) throws UnmarshalException
+	{
+		try
+		{
+			NodeList nl = doc.getChildNodes();
+			Element envelope = null;
+			
+			for (int i = 0; i < nl.getLength(); i++)
+			{
+				Node n = nl.item(i);
+				
+				if (n.getNodeName().equals(ENVELOPE_TAG))
+				{
+					envelope = (Element) n;
+					break;
+				}
+			}
+
+			_theHeader.fromXML(envelope);
+			_theContext.fromXML(envelope);
+			_theBody.fromXML(envelope);
+			_theFault.fromXML(envelope);
+			_theAttachment.fromXML(envelope);
+			_theProperties.fromXML(envelope);
+		}
+		catch (UnmarshalException ex)
+		{
+			throw ex;
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			throw new UnmarshalException(ex);
+		}
+	}
+	
+	// TODO add equality operator(s)
+	
+	private HeaderImpl _theHeader = new HeaderImpl();
+	private ContextImpl _theContext = new ContextImpl();
+	private BodyImpl _theBody = new BodyImpl();
+	private FaultImpl _theFault = new FaultImpl();
+	private AttachmentImpl _theAttachment = new AttachmentImpl();
+	private PropertiesImpl _theProperties = new PropertiesImpl();
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,218 @@
+/*
+ * 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 schifest at heuristica.com.ar
+ */
+package org.jboss.internal.soa.esb.message.format.xml;
+
+import java.io.Serializable;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.jboss.internal.soa.esb.thirdparty.Base64;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.message.Properties;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class PropertiesImpl implements Properties
+{
+	public static final String PROPERTIES_TAG = "Properties";
+
+	public static final String PROPERTY_TAG = "Property";
+
+	public static final String KEY_TAG = "Key";
+
+	public static final String VALUE_TAG = "Value";
+
+	public Object getProperty(String name)
+	{
+		return _table.get(name);
+	}
+
+	public Object getProperty(String name, Object defaultVal)
+	{
+		Object oRet = getProperty(name);
+		return (null == oRet) ? defaultVal : oRet;
+	}
+
+	public Object setProperty(String name, Object value)
+	{
+		if (value instanceof Serializable)
+			return _table.put(name, (Serializable) value);
+		else
+			throw new IllegalArgumentException("value must be XmlSerializable");
+	}
+
+	public Object remove(String name)
+	{
+		return _table.remove(name);
+	}
+
+	public int size()
+	{
+		return _table.size();
+	}
+
+	public String[] getNames()
+	{
+		return _table.keySet().toArray(new String[_table.size()]);
+	}
+
+	/**
+	 * toXML(elem) - Will build a child element with appropriate values and
+	 * append it to arg0
+	 * 
+	 * @param elem
+	 *            Element - where to add 'this' as a child node
+	 * @return Element - 'this' as the added Element, or &lt;null&gt; if no
+	 *         properties in table and nothing was appended to arg0
+	 */
+	public Element toXML(Element elem) throws MarshalException
+	{
+		if (_table.size() < 1)
+			return null;
+
+		Document doc = elem.getOwnerDocument();
+		Element thisElement = doc.createElement(PROPERTIES_TAG);
+
+		boolean bAdd = false;
+		for (Map.Entry<String, Serializable> oCurr : _table.entrySet())
+		{
+			Element oProp = doc.createElement(PROPERTY_TAG);
+			Element keyElement = doc.createElement(KEY_TAG);
+			Element valueElement = doc.createElement(VALUE_TAG);
+			
+			keyElement.appendChild(doc.createCDATASection(Base64.encodeBytes(oCurr.getKey().getBytes())));
+			oProp.appendChild(keyElement);
+		
+			valueElement.appendChild(doc.createCDATASection(Base64.encodeObject(oCurr.getValue())));
+			oProp.appendChild(valueElement);
+			
+			thisElement.appendChild(oProp);
+			bAdd = true;
+		}
+		if (bAdd)
+		{
+			elem.appendChild(thisElement);
+			return thisElement;
+		}
+		else
+			return null;
+	}
+
+	/**
+	 * fromXml(elem) - Populate properties found in appropriate child element
+	 * 
+	 * @see XMLUtil.PROPERTIES_TAG
+	 * @param elem -
+	 *            Element where to look for child nodes
+	 */
+	public void fromXML(Element elem) throws UnmarshalException
+	{
+		_table.clear();
+		
+		/*
+		 * There should be only one!
+		 */
+		
+		NodeList NL = elem.getElementsByTagName(PROPERTIES_TAG);
+
+		if (NL.getLength() > 1)
+			throw new UnmarshalException("More "+PROPERTIES_TAG+" than we expected!");
+		
+		if (NL.getLength() == 1)
+			NL = NL.item(0).getChildNodes();
+		
+		for (int i1 = 0; i1 < NL.getLength(); i1++)
+		{
+			Node oCurr = NL.item(i1);
+			
+			if (!(oCurr instanceof Element))
+				continue;
+
+			if (oCurr.getNodeName().equals(PROPERTY_TAG))
+			{
+				NodeList props = oCurr.getChildNodes();
+				String key = null;
+				Object value = null;
+				
+				for (int i2 = 0; i2 < props.getLength(); i2++)
+				{
+					Node oProp = props.item(i2);
+
+					if (oProp instanceof Element)
+					{
+						if (oProp.getNodeName().equals(VALUE_TAG))
+						{
+							CDATASection cdata = (CDATASection) oProp.getFirstChild();
+							value = Base64.decodeToObject(cdata.getWholeText());
+						}
+						else
+						{
+							if (oProp.getNodeName().equals(KEY_TAG))
+							{
+								CDATASection cdata = (CDATASection) oProp.getFirstChild();
+								key = new String(Base64.decode(cdata.getWholeText()));
+							}
+						}
+					}
+				}
+				
+				if ((key != null) && (value != null))
+					_table.put(key, (Serializable) value);
+				else
+					throw new UnmarshalException("Could not get tuple for "+oCurr.getNodeName());
+			}
+		}
+	}
+
+	public String toString()
+	{
+		return _table.toString();
+	}
+
+	@Override
+	public boolean equals(Object arg)
+	{
+		if (!(arg instanceof Properties))
+			return false;
+		Properties other = (Properties) arg;
+		if (other.size() != _table.size())
+			return false;
+		for (Map.Entry<String, Serializable> oCurr : _table.entrySet())
+		{
+			Object val = other.getProperty(oCurr.getKey());
+			if (null == oCurr.getValue())
+				if (null == val)
+					continue;
+				else
+					return false;
+			if (!oCurr.getValue().equals(val))
+				return false;
+		}
+		return true;
+	}
+
+	Hashtable<String, Serializable> _table = new Hashtable<String, Serializable>();
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/XMLMessagePlugin.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/XMLMessagePlugin.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/XMLMessagePlugin.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,48 @@
+package org.jboss.internal.soa.esb.message.format.xml;
+
+import java.net.URI;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessagePlugin;
+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
+ */
+
+/**
+ * Used to plug in new message formats dynamically.
+ *  
+ * @author Mark Little
+ *
+ */
+
+public class XMLMessagePlugin implements MessagePlugin
+{
+	public Message getMessage ()
+	{
+		return new MessageImpl();
+	}
+	
+	public URI getType ()
+	{
+		return MessageType.JBOSS_XML;
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/XMLUtil.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/XMLUtil.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/XMLUtil.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,34 @@
+/*
+ * 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
+ */
+
+/*
+ * Copyright (c) 2002, 2003, Arjuna Technologies Limited.
+ *
+ * XMLUtil.java
+ */
+
+package org.jboss.internal.soa.esb.message.format.xml;
+
+public class XMLUtil
+{
+    public static final String ESB_PREFIX = "jbesb";
+    public static final String ESB_NAMESPACE_URI = "http://www.jboss.org/ws/2006/09/esb";
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalManager.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalManager.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalManager.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,162 @@
+package org.jboss.internal.soa.esb.message.format.xml.marshal;
+
+import java.net.URI;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
+
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.common.ModulePropertyManager;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/*
+ * 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
+ */
+
+/**
+ * Used to plug in new Object marshal/unmarshal formats dynamically. When packing
+ * objects in XML, the system runs through the list of registered plug-ins until it
+ * finds one that can deal with the object type (or faults). When packing, the name (type)
+ * of the plug-in that packed the object is also attached to facilitate unpacking.
+ *  
+ * @author Mark Little
+ *
+ */
+
+public class MarshalUnmarshalManager
+{
+	public static MarshalUnmarshalManager getInstance ()
+	{
+		return _instance;
+	}
+	
+	private MarshalUnmarshalManager ()
+	{
+		/*
+		 * Go through the properties loaded from the property file. Anything
+		 * starting with MessagePlugin.MESSAGE_PLUGIN is assumed to be a plugin
+		 * that we load and add to the list.
+		 */
+		
+		Properties properties = ModulePropertyManager.getPropertyManager(ModulePropertyManager.CORE_MODULE).getProperties();
+		
+		if (properties != null)
+		{
+			Enumeration names = properties.propertyNames();
+
+			while (names.hasMoreElements())
+			{
+				String attrName = (String) names.nextElement();
+				
+				if (attrName.startsWith(MarshalUnmarshalPlugin.MARSHAL_UNMARSHAL_PLUGIN))
+				{
+					try
+					{
+						String pluginName = properties.getProperty(attrName);
+						Class c = Class.forName(pluginName);
+						MarshalUnmarshalPlugin thePlugin = (MarshalUnmarshalPlugin) c.newInstance();
+
+						_plugins.put(thePlugin.type(), thePlugin);
+					}
+					catch (ClassNotFoundException ex)
+					{
+						ex.printStackTrace();
+					}
+					catch (IllegalAccessException ex)
+					{
+						ex.printStackTrace();
+					}
+					catch (InstantiationException ex)
+					{
+						ex.printStackTrace();
+					}
+				}
+			}
+			
+			/*
+			 * Add in the default plugin.
+			 */
+			
+			SerializedMarshalUnmarshalPlugin defaultPlugin = new SerializedMarshalUnmarshalPlugin();
+			
+			_plugins.put(defaultPlugin.type(), defaultPlugin);
+		}
+	}
+	
+	/**
+	 * Pack the provided object into the document.
+	 * 
+	 * @param doc the XML document.
+	 * @param param the object to pack.
+	 * 
+	 * @return <code>true</code> if the object was packed, <code>false</code> otherwise.
+	 * @throws MarshalException thrown if there is a problem packing.
+	 */
+	
+	public boolean marshal (Element doc, Object param) throws MarshalException
+	{
+		if ((doc == null) || (param == null))
+			throw new IllegalArgumentException();
+		
+		Enumeration<URI> keys = _plugins.keys();
+		
+		while (keys.hasMoreElements())
+		{
+			if (_plugins.get(keys.nextElement()).marshal(doc, param))
+				return true;
+		}
+		
+		return false;
+	}
+	
+	/**
+	 * Unpack the object from the document.
+	 * 
+	 * @param doc the document.
+	 * 
+	 * @return the object, or <code>null</code> if this implementation cannot deal with the
+	 * format.
+	 * @throws UnmarshalException thrown if there is a problem unpacking.
+	 */
+	
+	public Object unmarshal (Element doc) throws UnmarshalException
+	{
+		if (doc == null)
+			throw new IllegalArgumentException();
+		
+		Enumeration<URI> keys = _plugins.keys();
+		
+		while (keys.hasMoreElements())
+		{
+			Object result = _plugins.get(keys.nextElement()).unmarshal(doc);
+			
+			if (result != null)
+				return result;
+		}
+		
+		return null;
+	}
+	
+	private Hashtable<URI,MarshalUnmarshalPlugin> _plugins = new Hashtable<URI,MarshalUnmarshalPlugin>();
+
+	private static final MarshalUnmarshalManager _instance = new MarshalUnmarshalManager();
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalPlugin.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalPlugin.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalPlugin.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,76 @@
+package org.jboss.internal.soa.esb.message.format.xml.marshal;
+
+import java.net.URI;
+
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.w3c.dom.Element;
+
+/*
+ * 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
+ */
+
+/**
+ * Used to plug in new Object marshal/unmarshal formats dynamically. When packing
+ * objects in XML, the system runs through the list of registered plug-ins until it
+ * finds one that can deal with the object type (or faults). When packing, the name (type)
+ * of the plug-in that packed the object is also attached to facilitate unpacking.
+ *  
+ * @author Mark Little
+ *
+ */
+
+public interface MarshalUnmarshalPlugin
+{
+	public static final String MARSHAL_UNMARSHAL_PLUGIN = "org.jboss.soa.esb.message.format.xml.plugin";
+	
+	public static final String tagName = "marshalunmarshal";
+	public static final String pluginType = "plugin-type";
+		
+	/**
+	 * Pack the provided object into the document.
+	 * 
+	 * @param doc the XML document.
+	 * @param param the object to pack.
+	 * 
+	 * @return <code>true</code> if the object was packed, <code>false</code> otherwise.
+	 * @throws MarshalException thrown if there is a problem packing.
+	 */
+	
+	public boolean marshal (Element doc, Object param) throws MarshalException;
+	
+	/**
+	 * Unpack the object from the document.
+	 * 
+	 * @param doc the document.
+	 * 
+	 * @return the object, or <code>null</code> if this implementation cannot deal with the
+	 * format.
+	 * @throws UnmarshalException thrown if there is a problem unpacking.
+	 */
+	
+	public Object unmarshal (Element doc) throws UnmarshalException;
+	
+	/**
+	 * @return the unique name for this plugin.
+	 */
+	
+	public URI type ();
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/SerializedMarshalUnmarshalPlugin.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/SerializedMarshalUnmarshalPlugin.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/marshal/SerializedMarshalUnmarshalPlugin.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,175 @@
+package org.jboss.internal.soa.esb.message.format.xml.marshal;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jboss.internal.soa.esb.thirdparty.Base64;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/*
+ * 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
+ */
+
+/**
+ * Used to plug in new Object marshal/unmarshal formats dynamically. When
+ * packing objects in XML, the system runs through the list of registered
+ * plug-ins until it finds one that can deal with the object type (or faults).
+ * When packing, the name (type) of the plug-in that packed the object is also
+ * attached to facilitate unpacking.
+ * 
+ * @author Mark Little
+ * 
+ */
+
+public class SerializedMarshalUnmarshalPlugin implements MarshalUnmarshalPlugin
+{
+
+	public SerializedMarshalUnmarshalPlugin()
+	{
+		try
+		{
+			_type = new URI("urn:xml/marshalunmarshal/plugin/serialization");
+		}
+		catch (URISyntaxException ex)
+		{
+			ex.printStackTrace();
+		}
+	}
+
+	/**
+	 * Pack the provided object into the document.
+	 * 
+	 * @param doc
+	 *            the XML document.
+	 * @param param
+	 *            the object to pack.
+	 * 
+	 * @return <code>true</code> if the object was packed, <code>false</code>
+	 *         otherwise.
+	 * @throws MarshalException
+	 *             thrown if there is a problem packing.
+	 */
+
+	public boolean marshal(Element doc, Object param) throws MarshalException
+	{
+		if (param instanceof Serializable)
+		{
+			// we can deal with this type!
+
+			try
+			{
+				Element nodeElement = doc.getOwnerDocument().createElement(
+						MarshalUnmarshalPlugin.tagName);
+
+				Element pluginType = doc.getOwnerDocument().createElement(
+						MarshalUnmarshalPlugin.pluginType);
+				pluginType.appendChild(doc.getOwnerDocument().createTextNode(
+						type().toString()));
+				nodeElement.appendChild(pluginType);
+
+				nodeElement.appendChild(doc.getOwnerDocument()
+						.createCDATASection(
+								Base64.encodeObject((Serializable) param)));
+
+				doc.appendChild(nodeElement);
+			}
+			catch (Exception ex)
+			{
+				ex.printStackTrace();
+
+				throw new MarshalException(ex);
+			}
+
+			return true;
+		}
+		else
+			return false;
+	}
+
+	/**
+	 * Unpack the object from the document.
+	 * 
+	 * @param doc
+	 *            the document.
+	 * 
+	 * @return the object, or <code>null</code> if this implementation cannot
+	 *         deal with the format.
+	 * @throws UnmarshalException
+	 *             thrown if there is a problem unpacking.
+	 */
+
+	public Object unmarshal(Element doc) throws UnmarshalException
+	{
+		try
+		{
+			NodeList nl = doc.getChildNodes();
+
+			for (int i = 0; i < nl.getLength(); i++)
+			{
+				if (nl.item(i).getNodeName().equals(MarshalUnmarshalPlugin.tagName))
+				{
+					NodeList childList = nl.item(i).getChildNodes();
+
+					for (int j = 0; j < childList.getLength(); j++)
+					{
+						Node el = childList.item(j);
+
+						if (el.getNodeName().equals(
+								MarshalUnmarshalPlugin.pluginType))
+						{
+							if (el.getTextContent().equals(type().toString()))
+							{
+								CDATASection cdata = (CDATASection) childList
+										.item(j + 1);
+
+								return Base64.decodeToObject(cdata
+										.getWholeText());
+							}
+						}
+					}
+				}
+			}
+
+			return null;
+		}
+		catch (Exception ex)
+		{
+			throw new UnmarshalException(ex);
+		}
+	}
+
+	/**
+	 * @return the unique name for this plugin.
+	 */
+
+	public URI type()
+	{
+		return _type;
+	}
+
+	private URI _type = null;
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/thirdparty/Base64.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/thirdparty/Base64.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/thirdparty/Base64.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,1451 @@
+package org.jboss.internal.soa.esb.thirdparty;
+
+/**
+ * Encodes and decodes to and from Base64 notation.
+ *
+ * <p>
+ * Change Log:
+ * </p>
+ * <ul>
+ *  <li>v2.1 - Cleaned up javadoc comments and unused variables and methods. Added
+ *   some convenience methods for reading and writing to and from files.</li>
+ *  <li>v2.0.2 - Now specifies UTF-8 encoding in places where the code fails on systems
+ *   with other encodings (like EBCDIC).</li>
+ *  <li>v2.0.1 - Fixed an error when decoding a single byte, that is, when the
+ *   encoded data was a single byte.</li>
+ *  <li>v2.0 - I got rid of methods that used booleans to set options. 
+ *   Now everything is more consolidated and cleaner. The code now detects
+ *   when data that's being decoded is gzip-compressed and will decompress it
+ *   automatically. Generally things are cleaner. You'll probably have to
+ *   change some method calls that you were making to support the new
+ *   options format (<tt>int</tt>s that you "OR" together).</li>
+ *  <li>v1.5.1 - Fixed bug when decompressing and decoding to a             
+ *   byte[] using <tt>decode( String s, boolean gzipCompressed )</tt>.      
+ *   Added the ability to "suspend" encoding in the Output Stream so        
+ *   you can turn on and off the encoding if you need to embed base64       
+ *   data in an otherwise "normal" stream (like an XML file).</li>  
+ *  <li>v1.5 - Output stream pases on flush() command but doesn't do anything itself.
+ *      This helps when using GZIP streams.
+ *      Added the ability to GZip-compress objects before encoding them.</li>
+ *  <li>v1.4 - Added helper methods to read/write files.</li>
+ *  <li>v1.3.6 - Fixed OutputStream.flush() so that 'position' is reset.</li>
+ *  <li>v1.3.5 - Added flag to turn on and off line breaks. Fixed bug in input stream
+ *      where last buffer being read, if not completely full, was not returned.</li>
+ *  <li>v1.3.4 - Fixed when "improperly padded stream" error was thrown at the wrong time.</li>
+ *  <li>v1.3.3 - Fixed I/O streams which were totally messed up.</li>
+ * </ul>
+ *
+ * <p>
+ * I am placing this code in the Public Domain. Do with it as you will.
+ * This software comes with no guarantees or warranties but with
+ * plenty of well-wishing instead!
+ * Please visit <a href="http://iharder.net/base64">http://iharder.net/base64</a>
+ * periodically to check for updates or to contribute improvements.
+ * </p>
+ *
+ * @author Robert Harder
+ * @author rob at iharder.net
+ * @version 2.1
+ */
+public class Base64
+{
+    
+/* ********  P U B L I C   F I E L D S  ******** */   
+    
+    
+    /** No options specified. Value is zero. */
+    public final static int NO_OPTIONS = 0;
+    
+    /** Specify encoding. */
+    public final static int ENCODE = 1;
+    
+    
+    /** Specify decoding. */
+    public final static int DECODE = 0;
+    
+    
+    /** Specify that data should be gzip-compressed. */
+    public final static int GZIP = 2;
+    
+    
+    /** Don't break lines when encoding (violates strict Base64 specification) */
+    public final static int DONT_BREAK_LINES = 8;
+    
+    
+/* ********  P R I V A T E   F I E L D S  ******** */  
+    
+    
+    /** Maximum line length (76) of Base64 output. */
+    private final static int MAX_LINE_LENGTH = 76;
+    
+    
+    /** The equals sign (=) as a byte. */
+    private final static byte EQUALS_SIGN = (byte)'=';
+    
+    
+    /** The new line character (\n) as a byte. */
+    private final static byte NEW_LINE = (byte)'\n';
+    
+    
+    /** Preferred encoding. */
+    private final static String PREFERRED_ENCODING = "UTF-8";
+    
+    
+    /** The 64 valid Base64 values. */
+    private final static byte[] ALPHABET;
+    private final static byte[] _NATIVE_ALPHABET = /* May be something funny like EBCDIC */
+    {
+        (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', (byte)'G',
+        (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', (byte)'N',
+        (byte)'O', (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', (byte)'U', 
+        (byte)'V', (byte)'W', (byte)'X', (byte)'Y', (byte)'Z',
+        (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g',
+        (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n',
+        (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u', 
+        (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z',
+        (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5', 
+        (byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'+', (byte)'/'
+    };
+    
+    /** Determine which ALPHABET to use. */
+    static
+    {
+        byte[] __bytes;
+        try
+        {
+            __bytes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".getBytes( PREFERRED_ENCODING );
+        }   // end try
+        catch (java.io.UnsupportedEncodingException use)
+        {
+            __bytes = _NATIVE_ALPHABET; // Fall back to native encoding
+        }   // end catch
+        ALPHABET = __bytes;
+    }   // end static
+    
+    
+    /** 
+     * Translates a Base64 value to either its 6-bit reconstruction value
+     * or a negative number indicating some other meaning.
+     **/
+    private final static byte[] DECODABET =
+    {   
+        -9,-9,-9,-9,-9,-9,-9,-9,-9,                 // Decimal  0 -  8
+        -5,-5,                                      // Whitespace: Tab and Linefeed
+        -9,-9,                                      // Decimal 11 - 12
+        -5,                                         // Whitespace: Carriage Return
+        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 14 - 26
+        -9,-9,-9,-9,-9,                             // Decimal 27 - 31
+        -5,                                         // Whitespace: Space
+        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,              // Decimal 33 - 42
+        62,                                         // Plus sign at decimal 43
+        -9,-9,-9,                                   // Decimal 44 - 46
+        63,                                         // Slash at decimal 47
+        52,53,54,55,56,57,58,59,60,61,              // Numbers zero through nine
+        -9,-9,-9,                                   // Decimal 58 - 60
+        -1,                                         // Equals sign at decimal 61
+        -9,-9,-9,                                      // Decimal 62 - 64
+        0,1,2,3,4,5,6,7,8,9,10,11,12,13,            // Letters 'A' through 'N'
+        14,15,16,17,18,19,20,21,22,23,24,25,        // Letters 'O' through 'Z'
+        -9,-9,-9,-9,-9,-9,                          // Decimal 91 - 96
+        26,27,28,29,30,31,32,33,34,35,36,37,38,     // Letters 'a' through 'm'
+        39,40,41,42,43,44,45,46,47,48,49,50,51,     // Letters 'n' through 'z'
+        -9,-9,-9,-9                                 // Decimal 123 - 126
+        /*,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 127 - 139
+        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 140 - 152
+        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 153 - 165
+        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 166 - 178
+        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 179 - 191
+        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 192 - 204
+        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 205 - 217
+        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 218 - 230
+        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 231 - 243
+        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9         // Decimal 244 - 255 */
+    };
+    
+    // I think I end up not using the BAD_ENCODING indicator.
+    //private final static byte BAD_ENCODING    = -9; // Indicates error in encoding
+    private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding
+    private final static byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding
+
+    
+    /** Defeats instantiation. */
+    private Base64(){}
+    
+    
+    
+/* ********  E N C O D I N G   M E T H O D S  ******** */    
+    
+    
+    /**
+     * Encodes up to the first three bytes of array <var>threeBytes</var>
+     * and returns a four-byte array in Base64 notation.
+     * The actual number of significant bytes in your array is
+     * given by <var>numSigBytes</var>.
+     * The array <var>threeBytes</var> needs only be as big as
+     * <var>numSigBytes</var>.
+     * Code can reuse a byte array by passing a four-byte array as <var>b4</var>.
+     *
+     * @param b4 A reusable byte array to reduce array instantiation
+     * @param threeBytes the array to convert
+     * @param numSigBytes the number of significant bytes in your array
+     * @return four byte array in Base64 notation.
+     * @since 1.5.1
+     */
+    private static byte[] encode3to4( byte[] b4, byte[] threeBytes, int numSigBytes )
+    {
+        encode3to4( threeBytes, 0, numSigBytes, b4, 0 );
+        return b4;
+    }   // end encode3to4
+
+    
+    /**
+     * Encodes up to three bytes of the array <var>source</var>
+     * and writes the resulting four Base64 bytes to <var>destination</var>.
+     * The source and destination arrays can be manipulated
+     * anywhere along their length by specifying 
+     * <var>srcOffset</var> and <var>destOffset</var>.
+     * This method does not check to make sure your arrays
+     * are large enough to accomodate <var>srcOffset</var> + 3 for
+     * the <var>source</var> array or <var>destOffset</var> + 4 for
+     * the <var>destination</var> array.
+     * The actual number of significant bytes in your array is
+     * given by <var>numSigBytes</var>.
+     *
+     * @param source the array to convert
+     * @param srcOffset the index where conversion begins
+     * @param numSigBytes the number of significant bytes in your array
+     * @param destination the array to hold the conversion
+     * @param destOffset the index where output will be put
+     * @return the <var>destination</var> array
+     * @since 1.3
+     */
+    private static byte[] encode3to4( 
+     byte[] source, int srcOffset, int numSigBytes,
+     byte[] destination, int destOffset )
+    {
+        //           1         2         3  
+        // 01234567890123456789012345678901 Bit position
+        // --------000000001111111122222222 Array position from threeBytes
+        // --------|    ||    ||    ||    | Six bit groups to index ALPHABET
+        //          >>18  >>12  >> 6  >> 0  Right shift necessary
+        //                0x3f  0x3f  0x3f  Additional AND
+        
+        // Create buffer with zero-padding if there are only one or two
+        // significant bytes passed in the array.
+        // We have to shift left 24 in order to flush out the 1's that appear
+        // when Java treats a value as negative that is cast from a byte to an int.
+        int inBuff =   ( numSigBytes > 0 ? ((source[ srcOffset     ] << 24) >>>  8) : 0 )
+                     | ( numSigBytes > 1 ? ((source[ srcOffset + 1 ] << 24) >>> 16) : 0 )
+                     | ( numSigBytes > 2 ? ((source[ srcOffset + 2 ] << 24) >>> 24) : 0 );
+
+        switch( numSigBytes )
+        {
+            case 3:
+                destination[ destOffset     ] = ALPHABET[ (inBuff >>> 18)        ];
+                destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ];
+                destination[ destOffset + 2 ] = ALPHABET[ (inBuff >>>  6) & 0x3f ];
+                destination[ destOffset + 3 ] = ALPHABET[ (inBuff       ) & 0x3f ];
+                return destination;
+                
+            case 2:
+                destination[ destOffset     ] = ALPHABET[ (inBuff >>> 18)        ];
+                destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ];
+                destination[ destOffset + 2 ] = ALPHABET[ (inBuff >>>  6) & 0x3f ];
+                destination[ destOffset + 3 ] = EQUALS_SIGN;
+                return destination;
+                
+            case 1:
+                destination[ destOffset     ] = ALPHABET[ (inBuff >>> 18)        ];
+                destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ];
+                destination[ destOffset + 2 ] = EQUALS_SIGN;
+                destination[ destOffset + 3 ] = EQUALS_SIGN;
+                return destination;
+                
+            default:
+                return destination;
+        }   // end switch
+    }   // end encode3to4
+    
+    
+    
+    /**
+     * Serializes an object and returns the Base64-encoded
+     * version of that serialized object. If the object
+     * cannot be serialized or there is another error,
+     * the method will return <tt>null</tt>.
+     * The object is not GZip-compressed before being encoded.
+     *
+     * @param serializableObject The object to encode
+     * @return The Base64-encoded object
+     * @since 1.4
+     */
+    public static String encodeObject( java.io.Serializable serializableObject )
+    {
+        return encodeObject( serializableObject, NO_OPTIONS );
+    }   // end encodeObject
+    
+
+
+    /**
+     * Serializes an object and returns the Base64-encoded
+     * version of that serialized object. If the object
+     * cannot be serialized or there is another error,
+     * the method will return <tt>null</tt>.
+     * <p>
+     * Valid options:<pre>
+     *   GZIP: gzip-compresses object before encoding it.
+     *   DONT_BREAK_LINES: don't break lines at 76 characters
+     *     <i>Note: Technically, this makes your encoding non-compliant.</i>
+     * </pre>
+     * <p>
+     * Example: <code>encodeObject( myObj, Base64.GZIP )</code> or
+     * <p>
+     * Example: <code>encodeObject( myObj, Base64.GZIP | Base64.DONT_BREAK_LINES )</code>
+     *
+     * @param serializableObject The object to encode
+     * @param options Specified options
+     * @return The Base64-encoded object
+     * @see Base64#GZIP
+     * @see Base64#DONT_BREAK_LINES
+     * @since 2.0
+     */
+    public static String encodeObject( java.io.Serializable serializableObject, int options )
+    {
+        // Streams
+        java.io.ByteArrayOutputStream  baos  = null; 
+        java.io.OutputStream           b64os = null; 
+        java.io.ObjectOutputStream     oos   = null; 
+        java.util.zip.GZIPOutputStream gzos  = null;
+        
+        // Isolate options
+        int gzip           = (options & GZIP);
+        int dontBreakLines = (options & DONT_BREAK_LINES);
+        
+        try
+        {
+            // ObjectOutputStream -> (GZIP) -> Base64 -> ByteArrayOutputStream
+            baos  = new java.io.ByteArrayOutputStream();
+            b64os = new Base64.OutputStream( baos, ENCODE | dontBreakLines );
+    
+            // GZip?
+            if( gzip == GZIP )
+            {
+                gzos = new java.util.zip.GZIPOutputStream( b64os );
+                oos  = new java.io.ObjectOutputStream( gzos );
+            }   // end if: gzip
+            else
+                oos   = new java.io.ObjectOutputStream( b64os );
+            
+            oos.writeObject( serializableObject );
+        }   // end try
+        catch( java.io.IOException e )
+        {
+            e.printStackTrace();
+            return null;
+        }   // end catch
+        finally
+        {
+            try{ oos.close();   } catch( Exception e ){}
+            try{ gzos.close();  } catch( Exception e ){}
+            try{ b64os.close(); } catch( Exception e ){}
+            try{ baos.close();  } catch( Exception e ){}
+        }   // end finally
+        
+        // Return value according to relevant encoding.
+        try 
+        {
+            return new String( baos.toByteArray(), PREFERRED_ENCODING );
+        }   // end try
+        catch (java.io.UnsupportedEncodingException uue)
+        {
+            return new String( baos.toByteArray() );
+        }   // end catch
+        
+    }   // end encode
+    
+    
+
+    /**
+     * Encodes a byte array into Base64 notation.
+     * Does not GZip-compress data.
+     *
+     * @param source The data to convert
+     * @since 1.4
+     */
+    public static String encodeBytes( byte[] source )
+    {
+        return encodeBytes( source, 0, source.length, NO_OPTIONS );
+    }   // end encodeBytes
+    
+
+
+    /**
+     * Encodes a byte array into Base64 notation.
+     * <p>
+     * Valid options:<pre>
+     *   GZIP: gzip-compresses object before encoding it.
+     *   DONT_BREAK_LINES: don't break lines at 76 characters
+     *     <i>Note: Technically, this makes your encoding non-compliant.</i>
+     * </pre>
+     * <p>
+     * Example: <code>encodeBytes( myData, Base64.GZIP )</code> or
+     * <p>
+     * Example: <code>encodeBytes( myData, Base64.GZIP | Base64.DONT_BREAK_LINES )</code>
+     *
+     *
+     * @param source The data to convert
+     * @param options Specified options
+     * @see Base64#GZIP
+     * @see Base64#DONT_BREAK_LINES
+     * @since 2.0
+     */
+    public static String encodeBytes( byte[] source, int options )
+    {   
+        return encodeBytes( source, 0, source.length, options );
+    }   // end encodeBytes
+    
+    
+    /**
+     * Encodes a byte array into Base64 notation.
+     * Does not GZip-compress data.
+     *
+     * @param source The data to convert
+     * @param off Offset in array where conversion should begin
+     * @param len Length of data to convert
+     * @since 1.4
+     */
+    public static String encodeBytes( byte[] source, int off, int len )
+    {
+        return encodeBytes( source, off, len, NO_OPTIONS );
+    }   // end encodeBytes
+    
+    
+
+    /**
+     * Encodes a byte array into Base64 notation.
+     * <p>
+     * Valid options:<pre>
+     *   GZIP: gzip-compresses object before encoding it.
+     *   DONT_BREAK_LINES: don't break lines at 76 characters
+     *     <i>Note: Technically, this makes your encoding non-compliant.</i>
+     * </pre>
+     * <p>
+     * Example: <code>encodeBytes( myData, Base64.GZIP )</code> or
+     * <p>
+     * Example: <code>encodeBytes( myData, Base64.GZIP | Base64.DONT_BREAK_LINES )</code>
+     *
+     *
+     * @param source The data to convert
+     * @param off Offset in array where conversion should begin
+     * @param len Length of data to convert
+     * @param options Specified options
+     * @see Base64#GZIP
+     * @see Base64#DONT_BREAK_LINES
+     * @since 2.0
+     */
+    public static String encodeBytes( byte[] source, int off, int len, int options )
+    {
+        // Isolate options
+        int dontBreakLines = ( options & DONT_BREAK_LINES );
+        int gzip           = ( options & GZIP   );
+        
+        // Compress?
+        if( gzip == GZIP )
+        {
+            java.io.ByteArrayOutputStream  baos  = null;
+            java.util.zip.GZIPOutputStream gzos  = null;
+            Base64.OutputStream            b64os = null;
+            
+    
+            try
+            {
+                // GZip -> Base64 -> ByteArray
+                baos = new java.io.ByteArrayOutputStream();
+                b64os = new Base64.OutputStream( baos, ENCODE | dontBreakLines );
+                gzos  = new java.util.zip.GZIPOutputStream( b64os ); 
+            
+                gzos.write( source, off, len );
+                gzos.close();
+            }   // end try
+            catch( java.io.IOException e )
+            {
+                e.printStackTrace();
+                return null;
+            }   // end catch
+            finally
+            {
+                try{ gzos.close();  } catch( Exception e ){}
+                try{ b64os.close(); } catch( Exception e ){}
+                try{ baos.close();  } catch( Exception e ){}
+            }   // end finally
+
+            // Return value according to relevant encoding.
+            try
+            {
+                return new String( baos.toByteArray(), PREFERRED_ENCODING );
+            }   // end try
+            catch (java.io.UnsupportedEncodingException uue)
+            {
+                return new String( baos.toByteArray() );
+            }   // end catch
+        }   // end if: compress
+        
+        // Else, don't compress. Better not to use streams at all then.
+        else
+        {
+            // Convert option to boolean in way that code likes it.
+            boolean breakLines = dontBreakLines == 0;
+            
+            int    len43   = len * 4 / 3;
+            byte[] outBuff = new byte[   ( len43 )                      // Main 4:3
+                                       + ( (len % 3) > 0 ? 4 : 0 )      // Account for padding
+                                       + (breakLines ? ( len43 / MAX_LINE_LENGTH ) : 0) ]; // New lines      
+            int d = 0;
+            int e = 0;
+            int len2 = len - 2;
+            int lineLength = 0;
+            for( ; d < len2; d+=3, e+=4 )
+            {
+                encode3to4( source, d+off, 3, outBuff, e );
+
+                lineLength += 4;
+                if( breakLines && lineLength == MAX_LINE_LENGTH )
+                {   
+                    outBuff[e+4] = NEW_LINE;
+                    e++;
+                    lineLength = 0;
+                }   // end if: end of line
+            }   // en dfor: each piece of array
+
+            if( d < len )
+            {
+                encode3to4( source, d+off, len - d, outBuff, e );
+                e += 4;
+            }   // end if: some padding needed
+
+            
+            // Return value according to relevant encoding.
+            try
+            {
+                return new String( outBuff, 0, e, PREFERRED_ENCODING );
+            }   // end try
+            catch (java.io.UnsupportedEncodingException uue)
+            {
+                return new String( outBuff, 0, e );
+            }   // end catch
+            
+        }   // end else: don't compress
+        
+    }   // end encodeBytes
+    
+
+    
+    
+    
+/* ********  D E C O D I N G   M E T H O D S  ******** */
+    
+    
+    /**
+     * Decodes four bytes from array <var>source</var>
+     * and writes the resulting bytes (up to three of them)
+     * to <var>destination</var>.
+     * The source and destination arrays can be manipulated
+     * anywhere along their length by specifying 
+     * <var>srcOffset</var> and <var>destOffset</var>.
+     * This method does not check to make sure your arrays
+     * are large enough to accomodate <var>srcOffset</var> + 4 for
+     * the <var>source</var> array or <var>destOffset</var> + 3 for
+     * the <var>destination</var> array.
+     * This method returns the actual number of bytes that 
+     * were converted from the Base64 encoding.
+     * 
+     *
+     * @param source the array to convert
+     * @param srcOffset the index where conversion begins
+     * @param destination the array to hold the conversion
+     * @param destOffset the index where output will be put
+     * @return the number of decoded bytes converted
+     * @since 1.3
+     */
+    private static int decode4to3( byte[] source, int srcOffset, byte[] destination, int destOffset )
+    {
+        // Example: Dk==
+        if( source[ srcOffset + 2] == EQUALS_SIGN )
+        {
+            // Two ways to do the same thing. Don't know which way I like best.
+            //int outBuff =   ( ( DECODABET[ source[ srcOffset    ] ] << 24 ) >>>  6 )
+            //              | ( ( DECODABET[ source[ srcOffset + 1] ] << 24 ) >>> 12 );
+            int outBuff =   ( ( DECODABET[ source[ srcOffset    ] ] & 0xFF ) << 18 )
+                          | ( ( DECODABET[ source[ srcOffset + 1] ] & 0xFF ) << 12 );
+            
+            destination[ destOffset ] = (byte)( outBuff >>> 16 );
+            return 1;
+        }
+        
+        // Example: DkL=
+        else if( source[ srcOffset + 3 ] == EQUALS_SIGN )
+        {
+            // Two ways to do the same thing. Don't know which way I like best.
+            //int outBuff =   ( ( DECODABET[ source[ srcOffset     ] ] << 24 ) >>>  6 )
+            //              | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 )
+            //              | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 );
+            int outBuff =   ( ( DECODABET[ source[ srcOffset     ] ] & 0xFF ) << 18 )
+                          | ( ( DECODABET[ source[ srcOffset + 1 ] ] & 0xFF ) << 12 )
+                          | ( ( DECODABET[ source[ srcOffset + 2 ] ] & 0xFF ) <<  6 );
+            
+            destination[ destOffset     ] = (byte)( outBuff >>> 16 );
+            destination[ destOffset + 1 ] = (byte)( outBuff >>>  8 );
+            return 2;
+        }
+        
+        // Example: DkLE
+        else
+        {
+            try{
+            // Two ways to do the same thing. Don't know which way I like best.
+            //int outBuff =   ( ( DECODABET[ source[ srcOffset     ] ] << 24 ) >>>  6 )
+            //              | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 )
+            //              | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 )
+            //              | ( ( DECODABET[ source[ srcOffset + 3 ] ] << 24 ) >>> 24 );
+            int outBuff =   ( ( DECODABET[ source[ srcOffset     ] ] & 0xFF ) << 18 )
+                          | ( ( DECODABET[ source[ srcOffset + 1 ] ] & 0xFF ) << 12 )
+                          | ( ( DECODABET[ source[ srcOffset + 2 ] ] & 0xFF ) <<  6)
+                          | ( ( DECODABET[ source[ srcOffset + 3 ] ] & 0xFF )      );
+
+            
+            destination[ destOffset     ] = (byte)( outBuff >> 16 );
+            destination[ destOffset + 1 ] = (byte)( outBuff >>  8 );
+            destination[ destOffset + 2 ] = (byte)( outBuff       );
+
+            return 3;
+            }catch( Exception e){
+                System.out.println(""+source[srcOffset]+ ": " + ( DECODABET[ source[ srcOffset     ] ]  ) );
+                System.out.println(""+source[srcOffset+1]+  ": " + ( DECODABET[ source[ srcOffset + 1 ] ]  ) );
+                System.out.println(""+source[srcOffset+2]+  ": " + ( DECODABET[ source[ srcOffset + 2 ] ]  ) );
+                System.out.println(""+source[srcOffset+3]+  ": " + ( DECODABET[ source[ srcOffset + 3 ] ]  ) );
+                return -1;
+            }   //e nd catch
+        }
+    }   // end decodeToBytes
+    
+    
+    
+    
+    /**
+     * Very low-level access to decoding ASCII characters in
+     * the form of a byte array. Does not support automatically
+     * gunzipping or any other "fancy" features.
+     *
+     * @param source The Base64 encoded data
+     * @param off    The offset of where to begin decoding
+     * @param len    The length of characters to decode
+     * @return decoded data
+     * @since 1.3
+     */
+    public static byte[] decode( byte[] source, int off, int len )
+    {
+        int    len34   = len * 3 / 4;
+        byte[] outBuff = new byte[ len34 ]; // Upper limit on size of output
+        int    outBuffPosn = 0;
+        
+        byte[] b4        = new byte[4];
+        int    b4Posn    = 0;
+        int    i         = 0;
+        byte   sbiCrop   = 0;
+        byte   sbiDecode = 0;
+        for( i = off; i < off+len; i++ )
+        {
+            sbiCrop = (byte)(source[i] & 0x7f); // Only the low seven bits
+            sbiDecode = DECODABET[ sbiCrop ];
+            
+            if( sbiDecode >= WHITE_SPACE_ENC ) // White space, Equals sign or better
+            {
+                if( sbiDecode >= EQUALS_SIGN_ENC )
+                {
+                    b4[ b4Posn++ ] = sbiCrop;
+                    if( b4Posn > 3 )
+                    {
+                        outBuffPosn += decode4to3( b4, 0, outBuff, outBuffPosn );
+                        b4Posn = 0;
+                        
+                        // If that was the equals sign, break out of 'for' loop
+                        if( sbiCrop == EQUALS_SIGN )
+                            break;
+                    }   // end if: quartet built
+                    
+                }   // end if: equals sign or better
+                
+            }   // end if: white space, equals sign or better
+            else
+            {
+                System.err.println( "Bad Base64 input character at " + i + ": " + source[i] + "(decimal)" );
+                return null;
+            }   // end else: 
+        }   // each input character
+                                   
+        byte[] out = new byte[ outBuffPosn ];
+        System.arraycopy( outBuff, 0, out, 0, outBuffPosn ); 
+        return out;
+    }   // end decode
+    
+    
+    
+    
+    /**
+     * Decodes data from Base64 notation, automatically
+     * detecting gzip-compressed data and decompressing it.
+     *
+     * @param s the string to decode
+     * @return the decoded data
+     * @since 1.4
+     */
+    public static byte[] decode( String s )
+    {   
+        byte[] bytes;
+        try
+        {
+            bytes = s.getBytes( PREFERRED_ENCODING );
+        }   // end try
+        catch( java.io.UnsupportedEncodingException uee )
+        {
+            bytes = s.getBytes();
+        }   // end catch
+		//</change>
+        
+        // Decode
+        bytes = decode( bytes, 0, bytes.length );
+        
+        
+        // Check to see if it's gzip-compressed
+        // GZIP Magic Two-Byte Number: 0x8b1f (35615)
+        if( bytes != null && bytes.length >= 4 )
+        {
+            
+            int head = ((int)bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);       
+            if( java.util.zip.GZIPInputStream.GZIP_MAGIC == head ) 
+            {
+                java.io.ByteArrayInputStream  bais = null;
+                java.util.zip.GZIPInputStream gzis = null;
+                java.io.ByteArrayOutputStream baos = null;
+                byte[] buffer = new byte[2048];
+                int    length = 0;
+
+                try
+                {
+                    baos = new java.io.ByteArrayOutputStream();
+                    bais = new java.io.ByteArrayInputStream( bytes );
+                    gzis = new java.util.zip.GZIPInputStream( bais );
+
+                    while( ( length = gzis.read( buffer ) ) >= 0 )
+                    {
+                        baos.write(buffer,0,length);
+                    }   // end while: reading input
+
+                    // No error? Get new bytes.
+                    bytes = baos.toByteArray();
+
+                }   // end try
+                catch( java.io.IOException e )
+                {
+                    // Just return originally-decoded bytes
+                }   // end catch
+                finally
+                {
+                    try{ baos.close(); } catch( Exception e ){}
+                    try{ gzis.close(); } catch( Exception e ){}
+                    try{ bais.close(); } catch( Exception e ){}
+                }   // end finally
+
+            }   // end if: gzipped
+        }   // end if: bytes.length >= 2
+        
+        return bytes;
+    }   // end decode
+
+
+    
+
+    /**
+     * Attempts to decode Base64 data and deserialize a Java
+     * Object within. Returns <tt>null</tt> if there was an error.
+     *
+     * @param encodedObject The Base64 data to decode
+     * @return The decoded and deserialized object
+     * @since 1.5
+     */
+    public static Object decodeToObject( String encodedObject )
+    {
+        // Decode and gunzip if necessary
+        byte[] objBytes = decode( encodedObject );
+        
+        java.io.ByteArrayInputStream  bais = null;
+        java.io.ObjectInputStream     ois  = null;
+        Object obj = null;
+        
+        try
+        {
+            bais = new java.io.ByteArrayInputStream( objBytes );
+            ois  = new java.io.ObjectInputStream( bais );
+        
+            obj = ois.readObject();
+        }   // end try
+        catch( java.io.IOException e )
+        {
+            e.printStackTrace();
+            obj = null;
+        }   // end catch
+        catch( java.lang.ClassNotFoundException e )
+        {
+            e.printStackTrace();
+            obj = null;
+        }   // end catch
+        finally
+        {
+            try{ bais.close(); } catch( Exception e ){}
+            try{ ois.close();  } catch( Exception e ){}
+        }   // end finally
+        
+        return obj;
+    }   // end decodeObject
+    
+    
+    
+    /**
+     * Convenience method for encoding data to a file.
+     *
+     * @param dataToEncode byte array of data to encode in base64 form
+     * @param filename Filename for saving encoded data
+     * @return <tt>true</tt> if successful, <tt>false</tt> otherwise
+     *
+     * @since 2.1
+     */
+    public static boolean encodeToFile( byte[] dataToEncode, String filename )
+    {
+        boolean success = false;
+        Base64.OutputStream bos = null;
+        try
+        {
+            bos = new Base64.OutputStream( 
+                      new java.io.FileOutputStream( filename ), Base64.ENCODE );
+            bos.write( dataToEncode );
+            success = true;
+        }   // end try
+        catch( java.io.IOException e )
+        {
+            
+            success = false;
+        }   // end catch: IOException
+        finally
+        {
+            try{ bos.close(); } catch( Exception e ){}
+        }   // end finally
+        
+        return success;
+    }   // end encodeToFile
+    
+    
+    /**
+     * Convenience method for decoding data to a file.
+     *
+     * @param dataToDecode Base64-encoded data as a string
+     * @param filename Filename for saving decoded data
+     * @return <tt>true</tt> if successful, <tt>false</tt> otherwise
+     *
+     * @since 2.1
+     */
+    public static boolean decodeToFile( String dataToDecode, String filename )
+    {
+        boolean success = false;
+        Base64.OutputStream bos = null;
+        try
+        {
+                bos = new Base64.OutputStream( 
+                          new java.io.FileOutputStream( filename ), Base64.DECODE );
+                bos.write( dataToDecode.getBytes( PREFERRED_ENCODING ) );
+                success = true;
+        }   // end try
+        catch( java.io.IOException e )
+        {
+            success = false;
+        }   // end catch: IOException
+        finally
+        {
+                try{ bos.close(); } catch( Exception e ){}
+        }   // end finally
+        
+        return success;
+    }   // end decodeToFile
+    
+    
+    
+    
+    /**
+     * Convenience method for reading a base64-encoded
+     * file and decoding it.
+     *
+     * @param filename Filename for reading encoded data
+     * @return decoded byte array or null if unsuccessful
+     *
+     * @since 2.1
+     */
+    public static byte[] decodeFromFile( String filename )
+    {
+        byte[] decodedData = null;
+        Base64.InputStream bis = null;
+        try
+        {
+            // Set up some useful variables
+            java.io.File file = new java.io.File( filename );
+            byte[] buffer = null;
+            int length   = 0;
+            int numBytes = 0;
+            
+            // Check for size of file
+            if( file.length() > Integer.MAX_VALUE )
+            {
+                System.err.println( "File is too big for this convenience method (" + file.length() + " bytes)." );
+                return null;
+            }   // end if: file too big for int index
+            buffer = new byte[ (int)file.length() ];
+            
+            // Open a stream
+            bis = new Base64.InputStream( 
+                      new java.io.BufferedInputStream( 
+                      new java.io.FileInputStream( file ) ), Base64.DECODE );
+            
+            // Read until done
+            while( ( numBytes = bis.read( buffer, length, 4096 ) ) >= 0 )
+                length += numBytes;
+            
+            // Save in a variable to return
+            decodedData = new byte[ length ];
+            System.arraycopy( buffer, 0, decodedData, 0, length );
+            
+        }   // end try
+        catch( java.io.IOException e )
+        {
+            System.err.println( "Error decoding from file " + filename );
+        }   // end catch: IOException
+        finally
+        {
+            try{ bis.close(); } catch( Exception e) {}
+        }   // end finally
+        
+        return decodedData;
+    }   // end decodeFromFile
+    
+    
+    
+    /**
+     * Convenience method for reading a binary file
+     * and base64-encoding it.
+     *
+     * @param filename Filename for reading binary data
+     * @return base64-encoded string or null if unsuccessful
+     *
+     * @since 2.1
+     */
+    public static String encodeFromFile( String filename )
+    {
+        String encodedData = null;
+        Base64.InputStream bis = null;
+        try
+        {
+            // Set up some useful variables
+            java.io.File file = new java.io.File( filename );
+            byte[] buffer = new byte[ (int)(file.length() * 1.4) ];
+            int length   = 0;
+            int numBytes = 0;
+            
+            // Open a stream
+            bis = new Base64.InputStream( 
+                      new java.io.BufferedInputStream( 
+                      new java.io.FileInputStream( file ) ), Base64.ENCODE );
+            
+            // Read until done
+            while( ( numBytes = bis.read( buffer, length, 4096 ) ) >= 0 )
+                length += numBytes;
+            
+            // Save in a variable to return
+            encodedData = new String( buffer, 0, length, Base64.PREFERRED_ENCODING );
+                
+        }   // end try
+        catch( java.io.IOException e )
+        {
+            System.err.println( "Error encoding from file " + filename );
+        }   // end catch: IOException
+        finally
+        {
+            try{ bis.close(); } catch( Exception e) {}
+        }   // end finally
+        
+        return encodedData;
+        }   // end encodeFromFile
+    
+    
+    
+    
+    /* ********  I N N E R   C L A S S   I N P U T S T R E A M  ******** */
+    
+    
+    
+    /**
+     * A {@link Base64.InputStream} will read data from another
+     * <tt>java.io.InputStream</tt>, given in the constructor,
+     * and encode/decode to/from Base64 notation on the fly.
+     *
+     * @see Base64
+     * @since 1.3
+     */
+    public static class InputStream extends java.io.FilterInputStream
+    {
+        private boolean encode;         // Encoding or decoding
+        private int     position;       // Current position in the buffer
+        private byte[]  buffer;         // Small buffer holding converted data
+        private int     bufferLength;   // Length of buffer (3 or 4)
+        private int     numSigBytes;    // Number of meaningful bytes in the buffer
+        private int     lineLength;
+        private boolean breakLines;     // Break lines at less than 80 characters
+        
+        
+        /**
+         * Constructs a {@link Base64.InputStream} in DECODE mode.
+         *
+         * @param in the <tt>java.io.InputStream</tt> from which to read data.
+         * @since 1.3
+         */
+        public InputStream( java.io.InputStream in )
+        {   
+            this( in, DECODE );
+        }   // end constructor
+        
+        
+        /**
+         * Constructs a {@link Base64.InputStream} in
+         * either ENCODE or DECODE mode.
+         * <p>
+         * Valid options:<pre>
+         *   ENCODE or DECODE: Encode or Decode as data is read.
+         *   DONT_BREAK_LINES: don't break lines at 76 characters
+         *     (only meaningful when encoding)
+         *     <i>Note: Technically, this makes your encoding non-compliant.</i>
+         * </pre>
+         * <p>
+         * Example: <code>new Base64.InputStream( in, Base64.DECODE )</code>
+         *
+         *
+         * @param in the <tt>java.io.InputStream</tt> from which to read data.
+         * @param options Specified options
+         * @see Base64#ENCODE
+         * @see Base64#DECODE
+         * @see Base64#DONT_BREAK_LINES
+         * @since 2.0
+         */
+        public InputStream( java.io.InputStream in, int options )
+        {   
+            super( in );
+            this.breakLines   = (options & DONT_BREAK_LINES) != DONT_BREAK_LINES;
+            this.encode       = (options & ENCODE) == ENCODE;
+            this.bufferLength = encode ? 4 : 3;
+            this.buffer   = new byte[ bufferLength ];
+            this.position = -1;
+            this.lineLength = 0;
+        }   // end constructor
+        
+        /**
+         * Reads enough of the input stream to convert
+         * to/from Base64 and returns the next byte.
+         *
+         * @return next byte
+         * @since 1.3
+         */
+        public int read() throws java.io.IOException 
+        { 
+            // Do we need to get data?
+            if( position < 0 )
+            {
+                if( encode )
+                {
+                    byte[] b3 = new byte[3];
+                    int numBinaryBytes = 0;
+                    for( int i = 0; i < 3; i++ )
+                    {
+                        try
+                        { 
+                            int b = in.read();
+                            
+                            // If end of stream, b is -1.
+                            if( b >= 0 )
+                            {
+                                b3[i] = (byte)b;
+                                numBinaryBytes++;
+                            }   // end if: not end of stream
+                            
+                        }   // end try: read
+                        catch( java.io.IOException e )
+                        {   
+                            // Only a problem if we got no data at all.
+                            if( i == 0 )
+                                throw e;
+                            
+                        }   // end catch
+                    }   // end for: each needed input byte
+                    
+                    if( numBinaryBytes > 0 )
+                    {
+                        encode3to4( b3, 0, numBinaryBytes, buffer, 0 );
+                        position = 0;
+                        numSigBytes = 4;
+                    }   // end if: got data
+                    else
+                    {
+                        return -1;
+                    }   // end else
+                }   // end if: encoding
+                
+                // Else decoding
+                else
+                {
+                    byte[] b4 = new byte[4];
+                    int i = 0;
+                    for( i = 0; i < 4; i++ )
+                    {
+                        // Read four "meaningful" bytes:
+                        int b = 0;
+                        do{ b = in.read(); }
+                        while( b >= 0 && DECODABET[ b & 0x7f ] <= WHITE_SPACE_ENC );
+                        
+                        if( b < 0 )
+                            break; // Reads a -1 if end of stream
+                        
+                        b4[i] = (byte)b;
+                    }   // end for: each needed input byte
+                    
+                    if( i == 4 )
+                    {
+                        numSigBytes = decode4to3( b4, 0, buffer, 0 );
+                        position = 0;
+                    }   // end if: got four characters
+                    else if( i == 0 ){
+                        return -1;
+                    }   // end else if: also padded correctly
+                    else
+                    {
+                        // Must have broken out from above.
+                        throw new java.io.IOException( "Improperly padded Base64 input." );
+                    }   // end 
+                    
+                }   // end else: decode
+            }   // end else: get data
+            
+            // Got data?
+            if( position >= 0 )
+            {
+                // End of relevant data?
+                if( /*!encode &&*/ position >= numSigBytes )
+                    return -1;
+                
+                if( encode && breakLines && lineLength >= MAX_LINE_LENGTH )
+                {
+                    lineLength = 0;
+                    return '\n';
+                }   // end if
+                else
+                {
+                    lineLength++;   // This isn't important when decoding
+                                    // but throwing an extra "if" seems
+                                    // just as wasteful.
+                    
+                    int b = buffer[ position++ ];
+
+                    if( position >= bufferLength )
+                        position = -1;
+
+                    return b & 0xFF; // This is how you "cast" a byte that's
+                                     // intended to be unsigned.
+                }   // end else
+            }   // end if: position >= 0
+            
+            // Else error
+            else
+            {   
+                // When JDK1.4 is more accepted, use an assertion here.
+                throw new java.io.IOException( "Error in Base64 code reading stream." );
+            }   // end else
+        }   // end read
+        
+        
+        /**
+         * Calls {@link #read()} repeatedly until the end of stream
+         * is reached or <var>len</var> bytes are read.
+         * Returns number of bytes read into array or -1 if
+         * end of stream is encountered.
+         *
+         * @param dest array to hold values
+         * @param off offset for array
+         * @param len max number of bytes to read into array
+         * @return bytes read into array or -1 if end of stream is encountered.
+         * @since 1.3
+         */
+        public int read( byte[] dest, int off, int len ) throws java.io.IOException
+        {
+            int i;
+            int b;
+            for( i = 0; i < len; i++ )
+            {
+                b = read();
+                
+                //if( b < 0 && i == 0 )
+                //    return -1;
+                
+                if( b >= 0 )
+                    dest[off + i] = (byte)b;
+                else if( i == 0 )
+                    return -1;
+                else
+                    break; // Out of 'for' loop
+            }   // end for: each byte read
+            return i;
+        }   // end read
+        
+    }   // end inner class InputStream
+    
+    
+    
+    
+    
+    
+    /* ********  I N N E R   C L A S S   O U T P U T S T R E A M  ******** */
+    
+    
+    
+    /**
+     * A {@link Base64.OutputStream} will write data to another
+     * <tt>java.io.OutputStream</tt>, given in the constructor,
+     * and encode/decode to/from Base64 notation on the fly.
+     *
+     * @see Base64
+     * @since 1.3
+     */
+    public static class OutputStream extends java.io.FilterOutputStream
+    {
+        private boolean encode;
+        private int     position;
+        private byte[]  buffer;
+        private int     bufferLength;
+        private int     lineLength;
+        private boolean breakLines;
+        private byte[]  b4; // Scratch used in a few places
+        private boolean suspendEncoding;
+        
+        /**
+         * Constructs a {@link Base64.OutputStream} in ENCODE mode.
+         *
+         * @param out the <tt>java.io.OutputStream</tt> to which data will be written.
+         * @since 1.3
+         */
+        public OutputStream( java.io.OutputStream out )
+        {   
+            this( out, ENCODE );
+        }   // end constructor
+        
+        
+        /**
+         * Constructs a {@link Base64.OutputStream} in
+         * either ENCODE or DECODE mode.
+         * <p>
+         * Valid options:<pre>
+         *   ENCODE or DECODE: Encode or Decode as data is read.
+         *   DONT_BREAK_LINES: don't break lines at 76 characters
+         *     (only meaningful when encoding)
+         *     <i>Note: Technically, this makes your encoding non-compliant.</i>
+         * </pre>
+         * <p>
+         * Example: <code>new Base64.OutputStream( out, Base64.ENCODE )</code>
+         *
+         * @param out the <tt>java.io.OutputStream</tt> to which data will be written.
+         * @param options Specified options.
+         * @see Base64#ENCODE
+         * @see Base64#DECODE
+         * @see Base64#DONT_BREAK_LINES
+         * @since 1.3
+         */
+        public OutputStream( java.io.OutputStream out, int options )
+        {   
+            super( out );
+            this.breakLines   = (options & DONT_BREAK_LINES) != DONT_BREAK_LINES;
+            this.encode       = (options & ENCODE) == ENCODE;
+            this.bufferLength = encode ? 3 : 4;
+            this.buffer       = new byte[ bufferLength ];
+            this.position     = 0;
+            this.lineLength   = 0;
+            this.suspendEncoding = false;
+            this.b4           = new byte[4];
+        }   // end constructor
+        
+        
+        /**
+         * Writes the byte to the output stream after
+         * converting to/from Base64 notation.
+         * When encoding, bytes are buffered three
+         * at a time before the output stream actually
+         * gets a write() call.
+         * When decoding, bytes are buffered four
+         * at a time.
+         *
+         * @param theByte the byte to write
+         * @since 1.3
+         */
+        public void write(int theByte) throws java.io.IOException
+        {
+            // Encoding suspended?
+            if( suspendEncoding )
+            {
+                super.out.write( theByte );
+                return;
+            }   // end if: supsended
+            
+            // Encode?
+            if( encode )
+            {
+                buffer[ position++ ] = (byte)theByte;
+                if( position >= bufferLength )  // Enough to encode.
+                {
+                    out.write( encode3to4( b4, buffer, bufferLength ) );
+
+                    lineLength += 4;
+                    if( breakLines && lineLength >= MAX_LINE_LENGTH )
+                    {
+                        out.write( NEW_LINE );
+                        lineLength = 0;
+                    }   // end if: end of line
+
+                    position = 0;
+                }   // end if: enough to output
+            }   // end if: encoding
+
+            // Else, Decoding
+            else
+            {
+                // Meaningful Base64 character?
+                if( DECODABET[ theByte & 0x7f ] > WHITE_SPACE_ENC )
+                {
+                    buffer[ position++ ] = (byte)theByte;
+                    if( position >= bufferLength )  // Enough to output.
+                    {
+                        int len = Base64.decode4to3( buffer, 0, b4, 0 );
+                        out.write( b4, 0, len );
+                        //out.write( Base64.decode4to3( buffer ) );
+                        position = 0;
+                    }   // end if: enough to output
+                }   // end if: meaningful base64 character
+                else if( DECODABET[ theByte & 0x7f ] != WHITE_SPACE_ENC )
+                {
+                    throw new java.io.IOException( "Invalid character in Base64 data." );
+                }   // end else: not white space either
+            }   // end else: decoding
+        }   // end write
+        
+        
+        
+        /**
+         * Calls {@link #write(int)} repeatedly until <var>len</var> 
+         * bytes are written.
+         *
+         * @param theBytes array from which to read bytes
+         * @param off offset for array
+         * @param len max number of bytes to read into array
+         * @since 1.3
+         */
+        public void write( byte[] theBytes, int off, int len ) throws java.io.IOException
+        {
+            // Encoding suspended?
+            if( suspendEncoding )
+            {
+                super.out.write( theBytes, off, len );
+                return;
+            }   // end if: supsended
+            
+            for( int i = 0; i < len; i++ )
+            {
+                write( theBytes[ off + i ] );
+            }   // end for: each byte written
+            
+        }   // end write
+        
+        
+        
+        /**
+         * Method added by PHIL. [Thanks, PHIL. -Rob]
+         * This pads the buffer without closing the stream.
+         */
+        public void flushBase64() throws java.io.IOException 
+        {
+            if( position > 0 )
+            {
+                if( encode )
+                {
+                    out.write( encode3to4( b4, buffer, position ) );
+                    position = 0;
+                }   // end if: encoding
+                else
+                {
+                    throw new java.io.IOException( "Base64 input not properly padded." );
+                }   // end else: decoding
+            }   // end if: buffer partially full
+
+        }   // end flush
+
+        
+        /** 
+         * Flushes and closes (I think, in the superclass) the stream. 
+         *
+         * @since 1.3
+         */
+        public void close() throws java.io.IOException
+        {
+            // 1. Ensure that pending characters are written
+            flushBase64();
+
+            // 2. Actually close the stream
+            // Base class both flushes and closes.
+            super.close();
+            
+            buffer = null;
+            out    = null;
+        }   // end close
+        
+        
+        
+        /**
+         * Suspends encoding of the stream.
+         * May be helpful if you need to embed a piece of
+         * base640-encoded data in a stream.
+         *
+         * @since 1.5.1
+         */
+        public void suspendEncoding() throws java.io.IOException 
+        {
+            flushBase64();
+            this.suspendEncoding = true;
+        }   // end suspendEncoding
+        
+        
+        /**
+         * Resumes encoding of the stream.
+         * May be helpful if you need to embed a piece of
+         * base640-encoded data in a stream.
+         *
+         * @since 1.5.1
+         */
+        public void resumeEncoding()
+        {
+            this.suspendEncoding = false;
+        }   // end resumeEncoding
+        
+        
+        
+    }   // end inner class OutputStream
+    
+    
+}   // end class Base64

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/App.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/App.java	2007-02-21 15:08:45 UTC (rev 9678)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/App.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -13,13 +13,5 @@
     public static void main( String[] args )
     {
         System.out.println( "Hello World!" );
-        
-        //ModulePropertyManager.getPropertyManager("foo");
-        
-        try {
-			throw new LoadPropertiesException();
-		} catch (LoadPropertiesException e) {
-			e.printStackTrace();
-		}
     }
 }

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/BaseException.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/BaseException.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/BaseException.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,42 @@
+package org.jboss.soa.esb;
+
+/**
+ * Base ESB Exception.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class BaseException extends Exception {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Public Default Constructor.
+	 */
+	public BaseException() {
+		super();
+	}
+
+	/**
+	 * Public Constructor.
+	 * @param message Exception message.
+	 */
+	public BaseException(String message) {
+		super(message);
+	}
+
+	/**
+	 * Public Constructor.
+	 * @param message Exception message.
+	 * @param cause Exception cause.
+	 */
+	public BaseException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	/**
+	 * Public Constructor.
+	 * @param cause Exception cause.
+	 */
+	public BaseException(Throwable cause) {
+		super(cause);
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/ConfigurationException.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/ConfigurationException.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/ConfigurationException.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,58 @@
+/*
+ * 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;
+
+/**
+ * Configuration Exception.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @since Version 4.0
+ */
+public class ConfigurationException extends BaseException {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+     * Construct an exception instance. 
+     * @param message Exception message.
+     */
+    public ConfigurationException(String message) {
+        super(message);
+    }
+
+    /**
+     * Construct an exception instance. 
+     * @param message Exception message.
+     * @param cause Exception cause.
+     */
+    public ConfigurationException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * Construct an exception instance. 
+     * @param cause Exception cause.
+     */
+    public ConfigurationException(Throwable cause) {
+        super(cause);
+    }
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/FatalError.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/FatalError.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/FatalError.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,73 @@
+/*
+ * 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;
+
+/**
+ * Thrown if the ESB enters a state from which it would be unsafe
+ * to continue to execute. If caught, the handler must be sure it
+ * can deal with any underlying cause if the ESB is not to terminate.
+ * 
+ * @author Mark Little
+ * @since Version 4.0.1
+ */
+
+public class FatalError extends Error
+{
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Construct an exception instance.
+	 * 
+	 * @param message
+	 *            Exception message.
+	 */
+	public FatalError (String message)
+	{
+		super(message);
+	}
+
+	/**
+	 * Construct an exception instance.
+	 * 
+	 * @param message
+	 *            Exception message.
+	 * @param cause
+	 *            Exception cause.
+	 */
+	public FatalError(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
+
+	/**
+	 * Construct an exception instance.
+	 * 
+	 * @param cause
+	 *            Exception cause.
+	 */
+	public FatalError(Throwable cause)
+	{
+		super(cause);
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/MarshalException.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/MarshalException.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/MarshalException.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,53 @@
+package org.jboss.soa.esb;
+
+/*
+ * 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 marshalling a message fails. This could be because
+ * conversion to XML encounters problems.
+ */
+
+public class MarshalException extends Exception
+{
+	private static final long serialVersionUID = 0xE;
+	
+	public MarshalException()
+	{
+		super();
+	}
+
+	public MarshalException(String s)
+	{
+		super(s);
+	}
+
+	public MarshalException (Exception ex)
+	{
+		super(ex);
+	}
+
+	public MarshalException (String message, Exception ex)
+	{
+		super(message, ex);
+	}
+	
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/ProtocolNotSupportedException.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/ProtocolNotSupportedException.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/ProtocolNotSupportedException.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,39 @@
+package org.jboss.soa.esb;
+
+/*
+ * 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
+ */
+
+
+public class ProtocolNotSupportedException extends Exception
+{
+	public static final long serialVersionUID = 0xE;
+	
+	public ProtocolNotSupportedException()
+	{
+		super();
+	}
+
+	public ProtocolNotSupportedException(String s)
+	{
+		super(s);
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/SendFailedException.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/SendFailedException.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/SendFailedException.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,43 @@
+package org.jboss.soa.esb;
+
+/*
+ * 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
+ */
+
+
+public class SendFailedException extends Exception
+{
+	public static final long serialVersionUID = 0xE;
+	
+	public SendFailedException()
+	{
+		super();
+	}
+
+	public SendFailedException(String s)
+	{
+		super(s);
+	}
+
+	public SendFailedException(Throwable ex)
+	{
+		super(ex);
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/UnmarshalException.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/UnmarshalException.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/UnmarshalException.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,52 @@
+package org.jboss.soa.esb;
+
+/*
+ * 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. This could be because
+ * conversion from XML encounters problems.
+ */
+
+public class UnmarshalException extends Exception
+{
+	private static final long serialVersionUID = 0xE;
+	
+	public UnmarshalException()
+	{
+		super();
+	}
+
+	public UnmarshalException(String s)
+	{
+		super(s);
+	}
+
+	public UnmarshalException (Exception ex)
+	{
+		super(ex);
+	}
+
+	public UnmarshalException (String message, Exception ex)
+	{
+		super(ex);
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/Call.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/Call.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/Call.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,276 @@
+package org.jboss.soa.esb.addressing;
+
+/*
+ * 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
+ */
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * Represents an interaction pattern for a specific message exchange. When sending a message
+ * the sender application can specify where errors are to be returned, where responses are
+ * to go, along with other interaction information.
+ * 
+ * A call represents an exchange pattern for this message. It is built up as the message
+ * flows through the ESB and identifies where the message should go, along with any
+ * routing information for faults, replies etc.
+ *
+ * 
+ * To: the destination. MANDATORY.
+ * From: the sender. OPTIONAL. If not defined, then the sender MAY be inferred from the transport.
+ * ReplyTo: the destination for any response. OPTIONAL.
+ * FaultTo: the destination for any error message. OPTIONAL.
+ * RelatesTo: used to indicate that this message is related to another. OPTIONAL.
+ * Action: used by the sender to indicate the semantics of the message. Must be unique. MANDATORY.
+ * MessageID: used to uniquely identify this message. OPTIONAL.
+ * 
+ * @author marklittle
+ *
+ */
+
+// TODO maybe this should simply go into the Header interface?
+
+public class Call
+{
+	/**
+	 * Create a new (empty) call.
+	 */
+	
+	public Call ()
+	{
+	}
+	
+	/**
+	 * Create a new call, whose To field is set to the supplied EPR.
+	 * 
+	 * @param epr the To field.
+	 */
+	
+	public Call (EPR epr)
+	{
+		_to = epr;
+	}
+	
+	/**
+	 * Set the To field. Must not be null.
+	 * 
+	 * @param epr the To field value.
+	 */
+	
+	public void setTo (EPR epr)
+	{
+		if (epr == null)
+			throw new IllegalArgumentException();
+		
+		_to = epr;
+	}
+	
+	/**
+	 * @return the To field.
+	 */
+	
+	public EPR getTo ()
+	{
+		return _to;
+	}
+	
+	/**
+	 * Set the From field. May be null.
+	 * 
+	 * @param from the value of the field.
+	 */
+	
+	public void setFrom (EPR from)
+	{
+		_from = from;
+	}
+	
+	/**
+	 * @return the From field.
+	 * @throws URISyntaxException thrown if the address is invalid.
+	 */
+	
+	public EPR getFrom ()
+	{
+		return _from;
+	}
+	
+	/**
+	 * Set the ReplyTo field. May be null.
+	 * 
+	 * @param replyTo the value of the field.
+	 */
+	
+	public void setReplyTo (EPR replyTo)
+	{
+		_replyTo = replyTo;
+	}
+	
+	/**
+	 * @return the ReplyTo field.
+	 * @throws URISyntaxException thrown if the address is invalid.
+	 */
+	
+	public EPR getReplyTo ()
+	{
+		return _replyTo;
+	}
+	
+	/**
+	 * Set the FaultTo field. May be null.
+	 * 
+	 * @param uri the value of the field.
+	 */
+	
+	public void setFaultTo (EPR uri)
+	{
+		_faultTo = uri;
+	}
+	
+	/**
+	 * @return the FaultTo field.
+	 */
+	
+	public EPR getFaultTo ()
+	{
+		return _faultTo;
+	}
+	
+	/**
+	 * Set the RelatesTo field.
+	 * 
+	 * @param uri the value to set.
+	 */
+	
+	public void setRelatesTo (URI uri)
+	{
+		_relatesTo = uri;
+	}
+	
+	/**
+	 * @return the RelatesTo field.
+	 */
+	
+	public URI getRelatesTo ()
+	{
+		return _relatesTo;
+	}
+	
+	/**
+	 * Set the Action field.
+	 * @param uri the value to set.
+	 */
+	
+	public void setAction (URI uri)
+	{
+		_action = uri;
+	}
+
+	/**
+	 * @return the Action field.
+	 */
+	public URI getAction ()
+	{
+		return _action;
+	}
+	
+	/**
+	 * Set the MessageId for this instance.
+	 * 
+	 * @param uri the value to use.
+	 */
+	
+	public void setMessageID (URI uri)
+	{
+		_messageID = uri;
+	}
+	
+	/**
+	 * @return the MessageID field.
+	 */
+	
+	public URI getMessageID ()
+	{
+		return _messageID;
+	}
+	
+	public final boolean empty ()
+	{
+		if ((_to == null) && (_from == null) && (_replyTo == null))
+		{
+			if ((_relatesTo == null) && (_faultTo == null) && (_action == null) && (_messageID == null))
+				return true;
+		}
+		
+		return false;
+	}
+	
+	/**
+	 * Copy the instance specified.
+	 * 
+	 * @param from the instance to copy.
+	 */
+	
+	public void copy (Call from)
+	{
+		Call fromImpl = (Call) from;
+		
+		_to = fromImpl._to;
+		_from = fromImpl._from;
+		_replyTo = fromImpl._replyTo;
+		_relatesTo = fromImpl._relatesTo;
+		_faultTo = fromImpl._faultTo;
+		_action = fromImpl._action;
+		_messageID = fromImpl._messageID;
+	}
+	
+//	public void setMetaData (MetaData md);
+//	public MetaData getMetaData ();
+//	public void addReferenceParameter (...);
+	
+	public String toString ()
+	{
+		return "To: "+_to+" From: "+_from+" ReplyTo: "+_replyTo+" FaultTo: "+_faultTo+" Action: "+_action+" MessagdID: "+_messageID;
+	}
+	
+	/**
+	 * This instance is valid if all mandatory elements are set.
+	 * 
+	 * @return <code>true</code> if all mandatory elements are set, <code>false</code> otherwise.
+	 */
+	
+	public boolean valid ()
+	{
+		if ((_to != null) && (_action != null))
+			return true;
+		else
+			return false;
+	}
+	
+	private EPR _to = null;
+	private EPR _from = null;
+	private EPR _faultTo = null;
+	private EPR _replyTo = null;
+	private URI _relatesTo = null;
+	private URI _action = null;
+	private URI _messageID = null;
+	
+} 
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/EPR.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/EPR.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/EPR.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,133 @@
+package org.jboss.soa.esb.addressing;
+
+/*
+ * 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 class represents the endpoint reference for services.
+ */
+
+import java.net.URI;
+
+/**
+ * The Endpoint Reference class. All services (and clients) can be represented by
+ * an EPR, which is effectively an address. If using SOA principles then the ultimate
+ * recipient of the message should be addressed in a loosely-coupled manner: the service
+ * should multiplex/demultiplex work across "objects" based on the message content and
+ * the EPR should not address a specific "object".
+ * 
+ * @author marklittle
+ *
+ */
+public class EPR
+{
+	/**
+	 * Create a new Endpoint Reference with a null address.
+	 */
+	
+	public EPR ()
+	{
+		_addr = new PortReference();
+	}
+	
+	/**
+	 * Create a new Endpoint Reference with the specified address.
+	 * 
+	 * @param addr the specified address.
+	 */
+	
+	public EPR (PortReference addr)
+	{
+		_addr = addr;
+	}
+
+	/**
+	 * Create a new Endpoint Reference with the specified address.
+	 * 
+	 * @param uri the specified address.
+	 */
+	
+	public EPR (URI uri)
+	{
+		_addr = new PortReference(uri.toString());
+	}
+	
+	/**
+	 * Override the address of this EPR.
+	 * 
+	 * @param uri the new address.
+	 */
+	
+	public void setAddr (PortReference uri)
+	{
+		_addr = uri;
+	}
+	
+	/**
+	 * Get the EPR address.
+	 * 
+	 * @return the address.
+	 */
+	
+	public PortReference getAddr ()
+	{
+		return _addr;
+	}
+
+	/**
+	 * Copy the contents of the specified EPR into this instance.
+	 * 
+	 * @param from the instance to copy.
+	 */
+	
+	public void copy (EPR from)
+	{
+		EPR fromImpl = (EPR) from;
+		
+		_addr = fromImpl._addr;
+	}
+	
+//	public void setMetaData (MetaData md);
+//	public MetaData getMetaData ();
+//	public void addReferenceParameter (...);
+	
+	public String toString ()
+	{
+		return "EPR: "+_addr;
+	}
+
+	public boolean equals (Object obj)
+	{
+		if (obj == this)
+			return true;
+		else
+		{
+			if (obj instanceof EPR)
+				return ((EPR) obj)._addr.equals(_addr);
+		}
+		
+		return false;
+	}
+	
+	private PortReference _addr;
+
+} 
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/MalformedEPRException.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/MalformedEPRException.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/MalformedEPRException.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,51 @@
+package org.jboss.soa.esb.addressing;
+
+/*
+ * 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 the EPR is not well formed, e.g., contains incorrect information.
+ */
+
+public class MalformedEPRException extends Exception
+{
+	public static final long serialVersionUID = 0xE;
+	
+	public MalformedEPRException()
+	{
+		super();
+	}
+
+	public MalformedEPRException(String s)
+	{
+		super(s);
+	}
+	
+	public MalformedEPRException(String s, Throwable ex)
+	{
+		super(s, ex);
+	}
+
+	public MalformedEPRException(Throwable ex)
+	{
+		super(ex);
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/PortReference.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/PortReference.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/PortReference.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,396 @@
+/*
+ * 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
+ */
+
+/*
+ * Copyright (c) 2002, 2003, Arjuna Technologies Limited.
+ *
+ * PortReference.java
+ */
+
+package org.jboss.soa.esb.addressing;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * An implementation of a WS-Addressing EPR. It needs completely rewriting after
+ * the interoperability workshop as it is not extensible. It's morphed with the changing WS-C/WS-T and
+ * WS-Addr specifications and their quirks; now that WS-Addr is finalized the
+ * old quirks no longer need to be supported so it's best to rewrite this from
+ * scratch.
+ * 
+ * An instance of a PortReference represents a single element in WS-A.
+ */
+
+public class PortReference
+{
+	public PortReference()
+	{
+	}
+
+	public PortReference(String address)
+	{
+		setAddress(address);
+	}
+
+	public void setAddress(String address)
+	{
+		_address = address;
+	}
+
+	public String getAddress()
+	{
+		return _address;
+	}
+
+	public void addExtension(PortReference.Extension extension)
+	{
+		_extensions.add(extension);
+	}
+
+	// all extensions are added as the Arjuna namespace.
+
+	public void addExtension(String value)
+	{
+		addExtension(XMLUtil.INSTANCE_IDENTIFIER_TAG, XMLUtil.JBOSSESB_PREFIX,
+				XMLUtil.JBOSSESB_NAMESPACE_URI, value,
+				Extension.REFERENCE_PROPERTIES);
+	}
+
+	public void addExtension(String tag, String value)
+	{
+		addExtension(tag, XMLUtil.JBOSSESB_PREFIX,
+				XMLUtil.JBOSSESB_NAMESPACE_URI, value,
+				Extension.REFERENCE_PROPERTIES);
+	}
+
+	/**
+	 * Define the tag, prefix and namespace URI for the extension value. The
+	 * parent is a refProperty.
+	 */
+
+	public void addExtension(String tag, String prefix, String uri, String value)
+	{
+		_extensions.add(new Extension(tag, prefix, uri, value,
+				Extension.REFERENCE_PROPERTIES));
+	}
+
+	/**
+	 * Define the tag, prefix and namespace URI for the extension value. The
+	 * parent field defines whether the attribute has a refParam, refProp or
+	 * neither as its parent.
+	 */
+
+	public void addExtension(String tag, String prefix, String uri,
+			String value, int parent)
+	{
+		_extensions.add(new Extension(tag, prefix, uri, value, parent));
+	}
+
+	// placeholders only
+
+	public void addPortType(String qName)
+	{
+	}
+
+	public void addServiceName(String portName, String qName)
+	{
+	}
+
+	public void addPolicy()
+	{
+	}
+
+	public String getExtensionValue(String tag)
+	{
+		String extensionValue = null;
+		Iterator iterator = _extensions.iterator();
+
+		while (iterator.hasNext() && (extensionValue == null))
+		{
+			Extension extension = (Extension) iterator.next();
+
+			if (tag.equals(extension.getTag()))
+				extensionValue = extension.getValue();
+		}
+
+		return extensionValue;
+	}
+
+	public Iterator getExtensions()
+	{
+		return _extensions.iterator();
+	}
+
+	public void clearExtensions()
+	{
+		_extensions.clear();
+	}
+
+	public String toString()
+	{
+		return "PortReference < " + _address + " >";
+	}
+
+	public String extendedToString()
+	{
+		String addr = "<" + XMLUtil.WSA_PREFIX + ":Address " + _address + "/>";
+
+		Iterator extensions = getExtensions();
+
+		while (extensions.hasNext())
+		{
+			Extension ext = (Extension) extensions.next();
+
+			addr += ", <" + XMLUtil.WSA_PREFIX + ":"
+					+ XMLUtil.REFERENCE_PROPERTIES_TAG + " " + ext.getPrefix()
+					+ ":" + ext.getTag() + " : " + ext.getValue() + "/>";
+		}
+
+		return "PortReference : " + addr;
+	}
+
+	/**
+	 * Is this object equal to the specified parameter?
+	 * 
+	 * @param rhs
+	 *            The rhs object.
+	 * @return true if the specified object is equal, false otherwise.
+	 */
+	public boolean equals(final Object rhs)
+	{
+		if ((rhs != null) && (rhs.getClass() == getClass()))
+		{
+			// This should really only include reference property extensions
+			final PortReference rhsPortReference = (PortReference) rhs;
+			return (equalsObject(_address, rhsPortReference._address)
+					&& equalsObject(_extensions, rhsPortReference._extensions)
+					&& equalsObject(_portType, rhsPortReference._portType)
+					&& equalsObject(_serviceName, rhsPortReference._serviceName) && equalsObject(
+					_policies, rhsPortReference._policies));
+		}
+		return false;
+	}
+
+	/**
+	 * Return the hash code for this object.
+	 * 
+	 * @return the hash code value.
+	 */
+	public int hashCode()
+	{
+		// Not checked for spread.
+		return (objectHashCode(_address, 0x1)
+				^ objectHashCode(_extensions, 0x2)
+				^ objectHashCode(_portType, 0x4)
+				^ objectHashCode(_serviceName, 0x8) ^ objectHashCode(_policies,
+				0x10));
+	}
+
+	public static class Extension
+	{
+		public static final int REFERENCE_PROPERTIES = 0;
+		public static final int REFERENCE_PARAMETERS = 1;
+		public static final int NEITHER = 2;
+
+		public Extension(String tag, String prefix, String uri)
+		{
+			this(tag, prefix, uri, null, REFERENCE_PROPERTIES);
+		}
+
+		public Extension(String tag, String prefix, String uri, String value)
+		{
+			this(tag, prefix, uri, value, REFERENCE_PROPERTIES);
+		}
+
+		public Extension(String tag, String prefix, String uri, String value,
+				int parent)
+		{
+			_tag = tag;
+			_prefix = prefix;
+			_uri = uri;
+			_value = value;
+			_parent = parent;
+			
+			/*
+			 * If XML was loaded via DOM1 then prefix and namespace won't work!
+			 */
+			
+			if (_uri == null)
+				_uri = XMLUtil.JBOSSESB_NAMESPACE_URI;
+			
+			if (_prefix == null)
+				_prefix = XMLUtil.JBOSSESB_PREFIX;
+			
+			if (_tag.contains(":"))
+			{
+				int colon = _tag.indexOf(':');
+				
+				_tag = _tag.substring(colon+1);
+			}
+		}
+
+		public int getParent()
+		{
+			return _parent;
+		}
+
+		public String getTag()
+		{
+			return _tag;
+		}
+
+		public String getPrefix()
+		{
+			return _prefix;
+		}
+
+		public String getURI()
+		{
+			return _uri;
+		}
+
+		public String getValue()
+		{
+			return _value;
+		}
+
+		public LinkedList getChildren()
+		{
+			return _extensions;
+		}
+
+		public HashMap getAttributes()
+		{
+			return _attributes;
+		}
+
+		public void addAttributes(HashMap props)
+		{
+			_attributes = props;
+		}
+
+		public void addChild(Extension child)
+		{
+			if (_extensions == null)
+				_extensions = new LinkedList<Extension>();
+
+			_extensions.add(child);
+		}
+
+		public String toString()
+		{
+			return new String("< " + _tag + ", " + _prefix + ", " + _uri + ", "
+					+ _value + " >");
+		}
+
+		/**
+		 * Is this object equal to the specified parameter (ignoring prefix)?
+		 * 
+		 * @param rhs
+		 *            The rhs object.
+		 * @return true if the specified object is equal, false otherwise.
+		 */
+		public boolean equals(final Object rhs)
+		{
+			if ((rhs != null) && (rhs.getClass() == getClass()))
+			{
+				final Extension rhsExtension = (Extension) rhs;
+				return (equalsObject(_tag, rhsExtension._tag)
+						&& equalsObject(_uri, rhsExtension._uri)
+						&& equalsObject(_value, rhsExtension._value)
+						&& equalsObject(_extensions, rhsExtension._extensions) && (_parent == rhsExtension._parent));
+			}
+			return false;
+		}
+
+		/**
+		 * Return the hash code for this object.
+		 * 
+		 * @return the hash code value.
+		 */
+		public int hashCode()
+		{
+			// Not checked for spread.
+			return (_parent ^ objectHashCode(_tag, 0x4)
+					^ objectHashCode(_uri, 0x8) ^ objectHashCode(_value, 0x10) ^ objectHashCode(
+					_extensions, 0x20));
+		}
+
+		private String _tag = null;
+
+		private String _prefix = null;
+
+		private String _uri = null;
+
+		private String _value = null;
+
+		private int _parent = NEITHER;
+
+		private LinkedList<Extension> _extensions = null;
+
+		private HashMap _attributes = null;
+
+	}
+
+	/**
+	 * Get the hash code from the object or use the default if null.
+	 * 
+	 * @param obj
+	 *            The object.
+	 * @param defaultHashCode
+	 *            The default hash code.
+	 * @return The hash code.
+	 */
+	static int objectHashCode(final Object obj, final int defaultHashCode)
+	{
+		return (obj == null ? defaultHashCode : obj.hashCode());
+	}
+
+	/**
+	 * Are the two objects equal?
+	 * 
+	 * @param lhs
+	 *            The lhs object.
+	 * @param rhs
+	 *            The rhs object.
+	 * @return true if equal or both null, false otherwise.
+	 */
+	static boolean equalsObject(final Object lhs, final Object rhs)
+	{
+		if (lhs == null)
+		{
+			return (rhs == null);
+		} else
+		{
+			return lhs.equals(rhs);
+		}
+	}
+
+	private String _address = null;
+	private LinkedList<Extension> _extensions = new LinkedList<Extension>();
+	private Extension _portType = null;
+	private Extension _serviceName = null;
+	private List _policies = null;
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/XMLUtil.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/XMLUtil.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/XMLUtil.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,62 @@
+/*
+ * 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
+ */
+
+/*
+ * Copyright (c) 2002, 2003, Arjuna Technologies Limited.
+ *
+ * XMLUtil.java
+ */
+
+package org.jboss.soa.esb.addressing;
+
+public class XMLUtil
+{
+    // WS-Addr
+
+    public static final String WSA_PREFIX = "wsa";
+    public static final String WSA_NAMESPACE_URI = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
+
+    public static final String ENDPOINT_REFERENCE_TAG   = "EndpointReference";
+    public static final String MESSAGE_IDENTIFIER_TAG   = "MessageID";
+    public static final String REFERENCE_PROPERTIES_TAG = "ReferenceProperties";
+    public static final String REFERENCE_PARAMETERS_TAG = "ReferenceParameters";
+    public static final String REPLY_TO_TAG             = "ReplyTo";
+    public static final String FROM_TAG            		= "From";
+
+    public static final String TO_TAG                   = "To";
+    public static final String ADDRESS_TAG              = "Address";
+    public static final String ACTION_TAG               = "Action";
+    public static final String RELATES_TO_TAG           = "RelatesTo";
+    public static final String FAULT_TO_TAG             = "FaultTo";
+    
+    // JBossESB
+
+    public static final String JBOSSESB_PREFIX        = "jbossesb";
+    public static final String JBOSSESB_NAMESPACE_URI = "http://schemas.jboss.com/ws/2007/01/jbossesb";
+
+    public static final String INSTANCE_IDENTIFIER_TAG = "InstanceIdentifier";
+
+    public static final String UNKNOWNERROR_ERROR_CODE = "UnknownError";
+    
+    // XML Namespace
+    public static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/" ;
+    public static final String XMLNS_PREFIX = "xmlns:" ;
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/EmailEpr.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/EmailEpr.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/EmailEpr.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,225 @@
+package org.jboss.soa.esb.addressing.eprs;
+
+/*
+ * 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 class represents the endpoint reference for services.
+ */
+
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.jboss.soa.esb.addressing.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * A helper class for using email style EPRs. Simply create and use instances of
+ * this type.
+ * 
+ * @author marklittle
+ *
+ */
+public class EmailEpr extends EPR
+{  
+	public static final String DEFAULT_PORT = "25";
+	public static final String DEFAULT_USERNAME = "";
+	public static final String DEFAULT_PASSWORD = "";
+	
+	public static final String SMTP_PROTOCOL = "smtp";
+	public static final String POP_PROTOCOL = "pop";
+	
+	public static final String USERNAME_TAG = "username";
+	public static final String PASSWORD_TAG = "password";
+	
+	private static final String PROTOCOL_SEPARATOR = "://";
+	private static final String PORT_SEPARATOR = ":";
+	
+	public EmailEpr (EPR epr)
+	{
+		copy(epr);
+	}
+	
+	public EmailEpr (EPR epr, Element header)
+	{
+		copy(epr);
+		
+		NodeList nl = header.getChildNodes();
+
+		for (int i = 0; i < nl.getLength(); i++)
+		{
+			try
+			{
+				String prefix = nl.item(i).getPrefix();
+				String tag = nl.item(i).getLocalName();
+				
+				if ((prefix != null) && (prefix.equals(XMLUtil.JBOSSESB_PREFIX)))
+				{
+					if ((tag != null) && (tag.equals(USERNAME_TAG)))
+					{
+						getAddr().addExtension(USERNAME_TAG, nl.item(i).getTextContent());
+					}
+					else
+					{
+						if ((tag != null) && (tag.equals(PASSWORD_TAG)))
+							getAddr().addExtension(PASSWORD_TAG, nl.item(i).getTextContent());
+					}
+				}
+			}
+			catch (Exception ex)
+			{
+				ex.printStackTrace();
+			}
+		}
+	}
+	
+	/**
+	 * Create a new email EPR. The port number will be assumed to be 25,
+	 * and there are no values for username and password.
+	 * 
+	 * @param protocol the protocol to use.
+	 * @param host the host name.
+	 */
+	
+	public EmailEpr (String protocol, String host)
+	{
+		this(protocol, host, DEFAULT_PORT, DEFAULT_USERNAME, DEFAULT_PASSWORD);
+	}
+	
+	/**
+	 * Create a new email EPR.
+	 * 
+	 * @param protocol the protocol to use.
+	 * @param host the host name.
+	 * @param port the port to use.
+	 * @param username the username for sending/receiving.
+	 * @param password the password for sending/receiving.
+	 */
+	
+	public EmailEpr (String protocol, String host, String port, String username, String password)
+	{
+		// how many of these do we really need? modify accordingly.
+		
+		if ((protocol == null) || (host == null) || (port == null))
+			throw new IllegalArgumentException();
+		
+		if ((protocol.equals(SMTP_PROTOCOL) || (protocol.equals(POP_PROTOCOL))))
+		{
+			PortReference addr = new PortReference(protocol+PROTOCOL_SEPARATOR+host+PORT_SEPARATOR+port);
+			
+			if (username != null)
+				addr.addExtension(USERNAME_TAG, username);
+			
+			if (password != null)
+				addr.addExtension(PASSWORD_TAG, password);
+			
+			setAddr(addr);
+		}
+		else
+			throw new IllegalArgumentException("Invalid email protocol!");
+	}
+	
+	/**
+	 * @return the email protocol used.
+	 * @throws URISyntaxException thrown if the address is malformed.
+	 */
+	
+	public final String getProtocol () throws URISyntaxException
+	{
+		URI addr = new URI(getAddr().getAddress());
+		
+		return addr.getScheme();
+	}
+	
+	/**
+	 * @return the email host used.
+	 * @throws URISyntaxException thrown if the address is malformed.
+	 */
+	
+	public final String getHost () throws URISyntaxException
+	{	
+		URI addr = new URI(getAddr().getAddress());
+		
+		return addr.getHost();
+	}
+	
+	/**
+	 * @return the email port used, or -1 if not specified.
+	 * @throws URISyntaxException thrown if the address is malformed.
+	 */
+
+	public final int getPort () throws URISyntaxException
+	{
+		URI addr = new URI(getAddr().getAddress());
+		
+		return addr.getPort();
+	}
+	
+	/*
+	 * There are deliberately no setters for the values once the EPR is created.
+	 */
+	
+	/**
+	 * @return the password for this EPR, or <code>null</code> if none is set.
+	 * @throws URISyntaxException thrown if the address is malformed.
+	 */
+	
+	public final String getPassword () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(PASSWORD_TAG);
+	}
+	
+	/**
+	 * @return the username for this EPR, or <code>null</code> if none is set.
+	 * @throws URISyntaxException thrown if the address is malformed.
+	 */
+	
+	public final String getUserName () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(USERNAME_TAG);
+	}
+
+	public static final URI type ()
+	{
+	    return _type;
+	}
+	
+	private static URI _type;
+
+	static
+	{
+	    try
+		{
+		    _type = new URI("urn:jboss/esb/epr/type/email");
+		}
+		catch (Exception ex)
+		{
+		    ex.printStackTrace();
+		    
+		    throw new ExceptionInInitializerError(ex.toString());
+		}
+	}
+} 
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/FTPEpr.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/FTPEpr.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/FTPEpr.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,248 @@
+package org.jboss.soa.esb.addressing.eprs;
+
+/*
+ * 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 class represents the endpoint reference for services.
+ */
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.jboss.soa.esb.addressing.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * A helper class for using FTP style EPRs. Simply create instances of this
+ * class instead of the base EPR. Since URLs can use FTP, we try to leverage
+ * that as much as possible.
+ * 
+ * @author marklittle
+ *
+ */
+public class FTPEpr extends FileEpr
+{
+	public static final String USERNAME_TAG = "username";
+	public static final String PASSWORD_TAG = "password";
+	public static final String PASSIVE_TAG = "passive";
+	
+	public FTPEpr (EPR epr)
+	{
+		super(epr);
+		
+		copy(epr);
+	}
+	
+	public FTPEpr (EPR epr, Element header)
+	{
+		super(epr, header);
+		
+		copy(epr);
+		
+		NodeList nl = header.getChildNodes();
+
+		for (int i = 0; i < nl.getLength(); i++)
+		{
+			try
+			{
+				String prefix = nl.item(i).getPrefix();
+				String tag = nl.item(i).getLocalName();
+				
+				if ((prefix != null) && (prefix.equals(XMLUtil.JBOSSESB_PREFIX)))
+				{
+					if (tag != null)
+					{
+						if (tag.equals(USERNAME_TAG))
+							getAddr().addExtension(USERNAME_TAG, nl.item(i).getTextContent());
+						else
+						{
+							if (tag.equals(PASSWORD_TAG))
+								getAddr().addExtension(PASSWORD_TAG, nl.item(i).getTextContent());
+							else
+							{
+								if (tag.equals(PASSIVE_TAG))
+									getAddr().addExtension(PASSIVE_TAG, nl.item(i).getTextContent());
+							}
+						}
+					}
+				}
+			}
+			catch (Exception ex)
+			{
+				ex.printStackTrace();
+			}
+		}
+	}
+			
+	public FTPEpr (URL url) throws URISyntaxException
+	{
+		super(new URI(url.toString()));
+	}
+	
+	public FTPEpr (String url) throws URISyntaxException
+	{
+		super(new URI(url));
+	}
+
+	/**
+	 * Set the URL for this endpoint.
+	 * 
+	 * @param url the address.
+	 */
+	
+	public final void setURL (URL url)
+	{
+		super.setAddr(new PortReference(url.toString()));
+	}
+	
+	/**
+	 * Get the URL address.
+	 * 
+	 * @return the address.
+	 * @throws URISyntaxException thrown if the address is invalid.
+	 */
+	
+	public final URL getURL () throws MalformedURLException, URISyntaxException
+	{
+		return new URL(super.getAddr().getAddress());
+	}
+
+	/**
+	 * Set the username for this FTP EPR. In case it cannot be put in the URL.
+	 * 
+	 * @param username the user's name.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setUserName (String username) throws URISyntaxException
+	{
+		if (username == null)
+			throw new IllegalArgumentException();
+		
+		if (userSet)
+			throw new IllegalStateException("Username already set.");
+		
+		getAddr().addExtension(USERNAME_TAG, username);
+		userSet = true;
+	}
+	
+	/**
+	 * @return the user's name associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getUserName () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(USERNAME_TAG);
+	}
+	
+	/**
+	 * Set the password for this FTP EPR.
+	 * 
+	 * @param password the user's name.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setPassword (String password) throws URISyntaxException
+	{
+		if (password == null)
+			throw new IllegalArgumentException();
+		
+		if (passwordSet)
+			throw new IllegalStateException("Cannot change password");
+		
+		getAddr().addExtension(PASSWORD_TAG, password);
+		passwordSet = true;
+	}
+	
+	/**
+	 * @return the password associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getPassword () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(PASSWORD_TAG);
+	}
+	
+	/**
+	 * Passive FTP?
+	 * 
+	 * @param passive the value.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setPassive (boolean passive) throws URISyntaxException
+	{
+		if (passiveSet)
+			throw new IllegalStateException("Cannot change passive");
+		
+		if (passive)
+			getAddr().addExtension(PASSIVE_TAG, "true");
+		else
+			getAddr().addExtension(PASSIVE_TAG, "false");
+		
+		passiveSet = true;
+	}
+	
+	/**
+	 * @return the passive value associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final boolean getPassive () throws URISyntaxException
+	{
+		return "true".equals(getAddr().getExtensionValue(PASSIVE_TAG));
+	}
+	
+	
+	public static URI type ()
+	{
+	    return _type;
+	}
+
+	private boolean passwordSet = false;
+	private boolean userSet = false;
+	private boolean passiveSet = false;
+	
+	private static URI _type;
+	
+	static
+	{
+	    try
+		{
+		    _type = new URI("urn:jboss/esb/epr/type/ftp");
+		}
+		catch (Exception ex)
+		{
+		    ex.printStackTrace();
+		    
+		    throw new ExceptionInInitializerError(ex.toString());
+		}
+	}
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/FileEpr.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/FileEpr.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/FileEpr.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,430 @@
+package org.jboss.soa.esb.addressing.eprs;
+
+/*
+ * 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 class represents the endpoint reference for services.
+ */
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.jboss.soa.esb.addressing.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * A helper class for using file based  EPRs. Simply create instances of this
+ * class instead of the base EPR. Since URLs can use file:// as the protocol, we try to leverage
+ * that as much as possible.
+ * 
+ * @author marklittle
+ *
+ */
+public class FileEpr extends EPR
+{
+	public static final String INPUT_SUFFIX_TAG = "inputSuffix";
+	public static final String WORK_SUFFIX_TAG 	= "workSuffix";
+	public static final String POST_DIR_TAG 	= "postDir";
+	public static final String POST_SUFFIX_TAG 	= "postSuffix";
+	public static final String POST_DEL_TAG 	= "postDelete";
+	public static final String ERROR_DIR_TAG 	= "errorDir";
+	public static final String ERROR_SUFFIX_TAG	= "errorSuffix";
+	public static final String ERROR_DEL_TAG 	= "errorDelete";
+	public static final String URL_TAG = "URL";
+	
+	public FileEpr (EPR epr)
+	{
+		copy(epr);
+	}
+	
+	public FileEpr (EPR epr, Element header)
+	{
+		copy(epr);
+		
+		NodeList nl = header.getChildNodes();
+
+		for (int i = 0; i < nl.getLength(); i++)
+		{
+			String nodeName = nl.item(i).getNodeName();
+
+			try
+			{
+				String prefix = nl.item(i).getPrefix();
+				String tag = nl.item(i).getLocalName();
+				
+				if ((prefix != null) && (prefix.equals(XMLUtil.JBOSSESB_PREFIX)))
+				{
+					if (tag != null)
+					{
+						if (tag.equals(INPUT_SUFFIX_TAG))
+							getAddr().addExtension(INPUT_SUFFIX_TAG, nl.item(i).getTextContent());
+						else
+						{
+							if (tag.equals(POST_DIR_TAG))
+								getAddr().addExtension(POST_DIR_TAG, nl.item(i).getTextContent());
+							else
+							{
+								if (tag.equals(POST_SUFFIX_TAG))
+									getAddr().addExtension(POST_SUFFIX_TAG, nl.item(i).getTextContent());
+								else
+								{
+									if (tag.equals(POST_DEL_TAG))
+										getAddr().addExtension(POST_DEL_TAG, nl.item(i).getTextContent());
+									else
+									{
+										if (tag.equals(ERROR_DIR_TAG))
+										{
+											getAddr().addExtension(ERROR_DIR_TAG, nl.item(i).getTextContent());
+										}
+										else
+										{
+											if (tag.equals((ERROR_SUFFIX_TAG)))
+												getAddr().addExtension(ERROR_SUFFIX_TAG, nl.item(i).getTextContent());
+											else
+											{
+												if (tag.equals((ERROR_DEL_TAG)))
+													getAddr().addExtension(ERROR_DEL_TAG, nl.item(i).getTextContent());
+											}
+										}
+									}
+								}
+							}
+						}	
+					}
+				}
+			}
+			catch (Exception ex)
+			{
+				ex.printStackTrace();
+			}
+		}
+	}
+
+	public FileEpr (URL url) throws URISyntaxException
+	{
+		super(new URI(url.toString()));
+	}
+	
+	public FileEpr (String url) throws URISyntaxException
+	{
+		super(new URI(url));
+	}
+
+	/**
+	 * Set the URL for this endpoint.
+	 * 
+	 * @param url the address.
+	 */
+	
+	public void setURL (URL url)
+	{
+		super.setAddr(new PortReference(url.toString()));
+	}
+	
+	/**
+	 * Get the URL address.
+	 * 
+	 * @return the address.
+	 * @throws URISyntaxException thrown if the address is invalid.
+	 */
+	
+	public URL getURL () throws MalformedURLException, URISyntaxException
+	{
+		return new URL(super.getAddr().getAddress());
+	}
+
+	/**
+	 * Set the file input suffix.
+	 * 
+	 * @param suffix the input suffix to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setInputSuffix (String suffix) throws URISyntaxException
+	{
+		if (suffix == null)
+			throw new IllegalArgumentException();
+		
+		if (inputSet)
+			throw new IllegalStateException("Input suffix already set.");
+		
+		getAddr().addExtension(INPUT_SUFFIX_TAG, suffix);
+		inputSet = true;
+	}
+	
+	/**
+	 * @return the input suffix associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getInputSuffix () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(INPUT_SUFFIX_TAG);
+	}
+	
+	/**
+	 * Set the work suffix for this EPR.
+	 * 
+	 * @param suffix the suffix to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setWorkSuffix (String suffix) throws URISyntaxException
+	{
+		if (suffix == null)
+			throw new IllegalArgumentException();
+		
+		if (workSet)
+			throw new IllegalStateException("Cannot change work suffix");
+		
+		getAddr().addExtension(WORK_SUFFIX_TAG, suffix);
+		workSet = true;
+	}
+	
+	/**
+	 * @return the work suffix associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getWorkSuffix () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(WORK_SUFFIX_TAG);
+	}
+	
+	/**
+	 * Set the post directory for this EPR.
+	 * 
+	 * @param dir the directory to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setPostDirectory (String dir) throws URISyntaxException
+	{
+		if (dir == null)
+			throw new IllegalArgumentException();
+		
+		if (postDirSet)
+			throw new IllegalStateException("Cannot change post directory");
+		
+		getAddr().addExtension(POST_DIR_TAG, dir);
+		postDirSet = true;
+	}
+	
+	/**
+	 * @return the post directory associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getPostDirectory () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(POST_DIR_TAG);
+	}
+	
+	/**
+	 * Set the post suffix for this EPR.
+	 * 
+	 * @param suffix the suffix to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setPostSuffix (String suffix) throws URISyntaxException
+	{
+		if (suffix == null)
+			throw new IllegalArgumentException();
+		
+		if (postSuffixSet)
+			throw new IllegalStateException("Cannot change post suffix");
+		
+		getAddr().addExtension(POST_SUFFIX_TAG, suffix);
+		postSuffixSet = true;
+	}
+	
+	/**
+	 * @return the post suffix associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getPostSuffix () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(POST_SUFFIX_TAG);
+	}
+	
+	/**
+	 * Set the post delete for this EPR.
+	 * 
+	 * @param del the deleted value to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setPostDelete (boolean del) throws URISyntaxException
+	{		
+		if (postDelSet)
+			throw new IllegalStateException("Cannot change post delete");
+		
+		if (del)
+			getAddr().addExtension(POST_DEL_TAG, "true");
+		else
+			getAddr().addExtension(POST_DEL_TAG, "false");
+		
+		postDelSet = true;
+	}
+	
+	/**
+	 * @return the delete vazlue associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final boolean getPostDelete () throws URISyntaxException
+	{
+		return ("true".equals(getAddr().getExtensionValue(POST_DEL_TAG)));
+	}
+		
+	/**
+	 * Set the error directory for this EPR.
+	 * 
+	 * @param dir the directory to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setErrorDirectory (String dir) throws URISyntaxException
+	{
+		if (dir == null)
+			throw new IllegalArgumentException();
+		
+		if (errorDirSet)
+			throw new IllegalStateException("Cannot change error directory");
+		
+		getAddr().addExtension(ERROR_DIR_TAG, dir);
+		errorDirSet = true;
+	}
+	
+	/**
+	 * @return the error directory associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getErrorDirectory () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(ERROR_DIR_TAG);
+	}
+	
+	/**
+	 * Set the error suffix for this EPR.
+	 * 
+	 * @param suffix the suffix to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setErrorSuffix (String suffix) throws URISyntaxException
+	{
+		if (suffix == null)
+			throw new IllegalArgumentException();
+		
+		if (errorSuffixSet)
+			throw new IllegalStateException("Cannot change error suffix");
+		
+		getAddr().addExtension(ERROR_SUFFIX_TAG, suffix);
+		errorSuffixSet = true;
+	}
+	
+	/**
+	 * @return the error suffix associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getErrorSuffix () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(ERROR_SUFFIX_TAG);
+	}
+	
+	/**
+	 * Set the error delete for this EPR. (invalid Message files will be deleted)
+	 * 
+	 * @param del the deleted value to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setErrorDelete (boolean del) throws URISyntaxException
+	{		
+		if (errorDelSet)
+			throw new IllegalStateException("Cannot change error delete");
+		
+		if (del)
+			getAddr().addExtension(ERROR_DEL_TAG, "true");
+		else
+			getAddr().addExtension(ERROR_DEL_TAG, "false");
+		
+		errorDelSet = true;
+	}
+	
+	/**
+	 * Attention - Default 
+	 * @return the error delete value associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final boolean getErrorDelete () throws URISyntaxException
+	{
+		return (! "false".equals(getAddr().getExtensionValue(ERROR_DEL_TAG)));
+	}
+		
+	public static URI type ()
+	{
+	    return _type;
+	}
+	
+	protected FileEpr (URI uri)
+	{
+		super(uri);
+	}
+
+	private boolean inputSet = false;
+	private boolean workSet = false;
+	private boolean postDirSet = false;
+	private boolean postSuffixSet = false;
+	private boolean postDelSet = false;
+	private boolean errorDirSet = false;
+	private boolean errorSuffixSet = false;
+	private boolean errorDelSet = false;
+	
+	private static URI _type;
+	
+	static
+	{
+	    try
+		{
+		    _type = new URI("urn:jboss/esb/epr/type/file");
+		}
+		catch (Exception ex)
+		{
+		    ex.printStackTrace();
+		    
+		    throw new ExceptionInInitializerError(ex.toString());
+		}
+	}
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/HTTPEpr.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/HTTPEpr.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/HTTPEpr.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,111 @@
+package org.jboss.soa.esb.addressing.eprs;
+
+/*
+ * 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 class represents the endpoint reference for services.
+ */
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.w3c.dom.Element;
+
+/**
+ * A helper class for using HTTP style EPRs. Simply create instances of this
+ * class instead of the base EPR.
+ * 
+ * @author marklittle
+ *
+ */
+public class HTTPEpr extends EPR
+{
+
+	public HTTPEpr (EPR epr)
+	{
+		copy(epr);
+	}
+	
+	public HTTPEpr (EPR epr, Element header)
+	{
+		copy(epr);
+	}
+	
+	public HTTPEpr (URL url) throws URISyntaxException
+	{
+		super(new URI(url.toString()));
+	}
+	
+	public HTTPEpr (String url) throws URISyntaxException
+	{
+		super(new URI(url));
+	}
+	
+	/**
+	 * Set the URL for this endpoint.
+	 * 
+	 * @param url the address.
+	 */
+	
+	public final void setURL (URL url)
+	{
+		super.setAddr(new PortReference(url.toString()));
+	}
+	
+	/**
+	 * Get the URL address.
+	 * 
+	 * @return the address.
+	 * @throws URISyntaxException thrown if the address is invalid.
+	 */
+	
+	public final URL getURL () throws MalformedURLException, URISyntaxException
+	{
+		return new URL(super.getAddr().getAddress());
+	}
+	
+	public static final URI type ()
+	{
+	    return _type;
+	}
+
+	private static URI _type;
+	
+	static
+	{
+	    try
+		{
+		    _type = new URI("urn:jboss/esb/epr/type/http");
+		}
+		catch (Exception ex)
+		{
+		    ex.printStackTrace();
+		    
+		    throw new ExceptionInInitializerError(ex.toString());
+		}
+	}
+} 
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/JDBCEpr.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/JDBCEpr.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/JDBCEpr.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,500 @@
+package org.jboss.soa.esb.addressing.eprs;
+
+/*
+ * 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 class represents the endpoint reference for services.
+ */
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.jboss.soa.esb.addressing.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * A helper class for using database style EPRs. Simply create instances of this
+ * class instead of the base EPR.
+ * 
+ * @author marklittle
+ *
+ */
+
+public class JDBCEpr extends EPR
+{
+	public static final String JDBC_PROTOCOL = "jdbc";
+	
+	public static final String USERNAME_TAG = "username";
+	public static final String PASSWORD_TAG = "password";
+	public static final String SQL_TAG = "sql";
+	public static final String DRIVER_TAG = "driver";
+	public static final String URL_TAG = "URL";
+
+	public static final String TABLE_NAME_TAG 			= "tablename";
+	public static final String MESSAGE_ID_COLUMN_TAG 	= "message_id_column";
+	public static final String STATUS_COLUMN_TAG 		= "status_column";
+	public static final String DATA_COLUMN_TAG 			= "message_column";
+	public static final String TIMESTAMP_COLUMN_TAG 	= "insert_timestamp_column";
+	public static final String POST_DEL_TAG				= "postDelete";
+	public static final String ERROR_DEL_TAG			= "errorDelete";
+	
+	public JDBCEpr (EPR epr)
+	{
+		copy(epr);
+	}
+	
+	public JDBCEpr (EPR epr, Element header)
+	{
+		copy(epr);
+		
+		NodeList nl = header.getChildNodes();
+
+		for (int i = 0; i < nl.getLength(); i++)
+		{
+			try
+			{
+				String prefix = nl.item(i).getPrefix();
+				String tag = nl.item(i).getLocalName();
+				
+				if ((prefix != null) && (prefix.equals(XMLUtil.JBOSSESB_PREFIX)))
+				{
+					if (tag != null)
+					{
+						if (tag.equals(USERNAME_TAG))
+							getAddr().addExtension(USERNAME_TAG, nl.item(i).getTextContent());
+						else
+						{
+							if (tag.equals(PASSWORD_TAG))
+								getAddr().addExtension(PASSWORD_TAG, nl.item(i).getTextContent());
+							else
+							{
+								if (tag.equals(SQL_TAG))
+									getAddr().addExtension(SQL_TAG, nl.item(i).getTextContent());
+								else
+								{
+									if (tag.equals(DRIVER_TAG))
+										getAddr().addExtension(DRIVER_TAG, nl.item(i).getTextContent());
+									else
+									{
+										if (tag.equals(URL_TAG))
+											getAddr().addExtension(URL_TAG, nl.item(i).getTextContent());
+										else
+										{
+											if (tag.equals(TABLE_NAME_TAG))
+												getAddr().addExtension(TABLE_NAME_TAG, nl.item(i).getTextContent());
+											else
+											{
+												if (tag.equals(MESSAGE_ID_COLUMN_TAG))
+													getAddr().addExtension(MESSAGE_ID_COLUMN_TAG, nl.item(i).getTextContent());
+												else
+												{
+													if (tag.equals(STATUS_COLUMN_TAG))
+														getAddr().addExtension(STATUS_COLUMN_TAG, nl.item(i).getTextContent());
+													else
+													{
+														if (tag.equals(DATA_COLUMN_TAG))
+															getAddr().addExtension(DATA_COLUMN_TAG, nl.item(i).getTextContent());
+														else
+														{
+															if (tag.equals(TIMESTAMP_COLUMN_TAG))
+																getAddr().addExtension(TIMESTAMP_COLUMN_TAG, nl.item(i).getTextContent());
+															else
+															{
+																if (tag.equals(POST_DEL_TAG))
+																	getAddr().addExtension(POST_DEL_TAG, nl.item(i).getTextContent());
+																else
+																{
+																	if (tag.equals(ERROR_DEL_TAG))
+																		getAddr().addExtension(ERROR_DEL_TAG, nl.item(i).getTextContent());
+																}
+															}
+														}
+													}
+												}
+											}
+										}
+									}
+								}
+							}
+						}
+					}
+				}
+			}
+			catch (Exception ex)
+			{
+				ex.printStackTrace();
+			}
+		}
+	}			
+	
+	public JDBCEpr (String url, String sql) throws URISyntaxException
+	{
+		super(new URI(url));
+		
+		setSQL(sql);
+	}
+
+	public JDBCEpr (String url) throws URISyntaxException
+	{
+		this(url,true,true);
+	}
+
+	public JDBCEpr (String url, boolean postDelete, boolean errorDelete) throws URISyntaxException
+	{
+		super(new URI(url));
+		if (postDelete)
+			getAddr().addExtension(POST_DEL_TAG,Boolean.toString(postDelete));
+		if (errorDelete)
+			getAddr().addExtension(ERROR_DEL_TAG,Boolean.toString(errorDelete));
+	}
+
+	/**
+	 * Set the URL for this endpoint.
+	 * 
+	 * @param url the address.
+	 */
+	
+	public final void setURL (String url)
+	{
+		super.setAddr(new PortReference(url));
+	}
+	
+	/**
+	 * Get the URL address.
+	 * 
+	 * @return the address.
+	 * @throws URISyntaxException thrown if the address is invalid.
+	 */
+	
+	public final String getURL () throws URISyntaxException
+	{
+		return getAddr().getAddress();
+	}
+
+	/**
+	 * Set the username for this FTP EPR.
+	 * 
+	 * @param username the user's name.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setUserName (String username) throws URISyntaxException
+	{
+		if (username == null)
+			throw new IllegalArgumentException();
+		
+		if (userSet)
+			throw new IllegalStateException("Username already set.");
+		
+		getAddr().addExtension(USERNAME_TAG, username);
+		userSet = true;
+	}
+	
+	/**
+	 * @return the user's name associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getUserName () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(USERNAME_TAG);
+	}
+	
+	/**
+	 * Set the password for this FTP EPR.
+	 * 
+	 * @param password the user's name.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setPassword (String password) throws URISyntaxException
+	{
+		if (password == null)
+			throw new IllegalArgumentException();
+		
+		if (passwordSet)
+			throw new IllegalStateException("Password already set.");
+		
+		getAddr().addExtension(PASSWORD_TAG, password);
+		passwordSet = true;
+	}
+	
+	/**
+	 * @return the password associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getPassword () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(PASSWORD_TAG);
+	}
+	
+	/**
+	 * Set the SQL command that is used by this EPR.
+	 * 
+	 * @param sql the statement.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setSQL (String sql) throws URISyntaxException
+	{
+		if (sql == null)
+			throw new IllegalArgumentException();
+		
+		if (sqlSet)
+			throw new IllegalStateException("SQL already set.");
+		
+		getAddr().addExtension(SQL_TAG, sql);
+		sqlSet = true;
+	}
+	
+	/**
+	 * @return the SQL statement for this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getSQL () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(SQL_TAG);
+	}
+	
+	/**
+	 * Set the driver that is used by this EPR.
+	 * 
+	 * @param driver the driver.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setDriver (String driver) throws URISyntaxException
+	{
+		if (driver == null)
+			throw new IllegalArgumentException();
+		
+		if (driverSet)
+			throw new IllegalStateException("Driver already set.");
+		
+		getAddr().addExtension(DRIVER_TAG, driver);
+		driverSet = true;
+	}
+	
+	/**
+	 * @return the driver used by this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getDriver () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(DRIVER_TAG);
+	}
+	
+	/**
+	 * Set the tablename that is used by this EPR.
+	 * 
+	 * @param tableName the table name.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setTableName (String tableName) throws URISyntaxException
+	{
+		if (tableName == null)
+			throw new IllegalArgumentException();
+		
+		if (tableNameSet)
+			throw new IllegalStateException("Table name already set.");
+		
+		getAddr().addExtension(TABLE_NAME_TAG, tableName);
+		tableNameSet = true;
+	}
+	
+	/**
+	 * @return the table name used by this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getTableName () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(TABLE_NAME_TAG);
+	}
+	
+	/**
+	 * Set the message id column name that is used by this EPR.
+	 * 
+	 * @param columnName the column name for the message ID.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setMessageIdColumn (String columnName) throws URISyntaxException
+	{
+		if (columnName == null)
+			throw new IllegalArgumentException();
+		
+		if (messageIdSet)
+			throw new IllegalStateException("Message Id column already set.");
+		
+		getAddr().addExtension(MESSAGE_ID_COLUMN_TAG, columnName);
+		messageIdSet = true;
+	}
+	
+	/**
+	 * @return the message id column used by this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getMessageIdColumn () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(MESSAGE_ID_COLUMN_TAG);
+	}
+	
+	/**
+	 * Set the status column that is used by this EPR.
+	 * 
+	 * @param statusColumn the status column.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setStatusColumn (String statusColumn) throws URISyntaxException
+	{
+		if (statusColumn == null)
+			throw new IllegalArgumentException();
+		
+		if (statusSet)
+			throw new IllegalStateException("Status column already set.");
+		
+		getAddr().addExtension(STATUS_COLUMN_TAG, statusColumn);
+		statusSet = true;
+	}
+	
+	/**
+	 * @return the status column name used by this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getStatusColumn () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(STATUS_COLUMN_TAG);
+	}
+	
+	/**
+	 * Set the column that is used by this EPR to store message data.
+	 * 
+	 * @param dataColumn the column name.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setDataColumn (String dataColumn) throws URISyntaxException
+	{
+		if (dataColumn == null)
+			throw new IllegalArgumentException();
+		
+		if (dataSet)
+			throw new IllegalStateException("Data column already set.");
+		
+		getAddr().addExtension(DATA_COLUMN_TAG, dataColumn);
+		dataSet = true;
+	}
+	
+	/**
+	 * @return the data column name used by this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getDataColumn () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(DATA_COLUMN_TAG);
+	}
+	
+	/**
+	 * Set the column that is used by this EPR to store timestamp when the message was inserted.
+	 * 
+	 * @param timeColumn the column name.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setTimestampColumn (String timeColumn) throws URISyntaxException
+	{
+		if (timeColumn == null)
+			throw new IllegalArgumentException();
+		
+		if (timestampSet)
+			throw new IllegalStateException("Timestamp column already set.");
+		
+		getAddr().addExtension(TIMESTAMP_COLUMN_TAG, timeColumn);
+		timestampSet = true;
+	}
+	
+	/**
+	 * @return the timestamp column name used by this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getTimestampColumn () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(TIMESTAMP_COLUMN_TAG);
+	}
+	
+	
+	public final String getPostDelete() throws URISyntaxException
+	{
+	    return getAddr().getExtensionValue(POST_DEL_TAG);
+	}
+	
+	public final String getErrorDelete() throws URISyntaxException
+	{
+	    return getAddr().getExtensionValue(ERROR_DEL_TAG);
+	}
+	
+	public static final URI type ()
+	{
+	    return _type;
+	}
+	
+	private boolean userSet = false;
+	private boolean passwordSet = false;
+	private boolean sqlSet = false;
+	private boolean driverSet = false;
+	private boolean tableNameSet = false;
+	private boolean messageIdSet = false;
+	private boolean statusSet = false;
+	private boolean dataSet = false;
+	private boolean timestampSet = false;
+	
+	private static URI _type;
+	
+	static
+	{
+	    try
+		{
+		    _type = new URI("urn:jboss/esb/epr/type/jdbc");
+		}
+		catch (Exception ex)
+		{
+		    ex.printStackTrace();
+		    
+		    throw new ExceptionInInitializerError(ex.toString());
+		}
+	}
+	
+} 
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/JMSEpr.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/JMSEpr.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/JMSEpr.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,367 @@
+package org.jboss.soa.esb.addressing.eprs;
+
+/*
+ * 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 class represents the endpoint reference for services.
+ */
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.jboss.soa.esb.addressing.XMLUtil;
+import org.jboss.soa.esb.helpers.NamingContext;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * A helper class for using JMS style EPRs. Simply create and use instances of
+ * this type.
+ * 
+ * @author marklittle
+ * 
+ */
+
+public class JMSEpr extends EPR
+{
+	public static final String JMS_PROTOCOL = "jms";
+
+	public static final String PROTOCOL_SEPARATOR = "://";
+
+	public static final String ONE_ONE_PROTOCOL = "1.1";
+
+	public static final String ONE_ZERO_TWO_PROTOCOL = "1.0.2b";
+
+	public static final String SPECIFICATION_VERSION_TAG = "specification-version";
+
+	public static final String DESTINATION_TYPE_TAG = "destination-type";
+
+	public static final String DESTINATION_NAME_TAG = "destination-name";
+
+	public static final String CONNECTION_FACTORY_TAG = "connection-factory";
+
+	public static final String JNDI_PKG_PREFIX_TAG = "jndi-pkg-prefix";
+
+	public static final String JNDI_URL_TAG = "jndi-URL";
+
+	public static final String JNDI_CONTEXT_FACTORY_TAG = "jndi-context-factory";
+
+	public static final String MESSAGE_SELECTOR_TAG = "message-selector";
+
+	public static final String QUEUE_TYPE = "queue";
+
+	public static final String TOPIC_TYPE = "topic";
+
+	public JMSEpr(EPR epr)
+	{
+		copy(epr);
+	}
+	
+	public JMSEpr(EPR epr, Element header)
+	{
+		copy(epr);
+		
+		NodeList nl = header.getChildNodes();
+
+		for (int i = 0; i < nl.getLength(); i++)
+		{
+			String prefix = nl.item(i).getPrefix();
+			String tag = nl.item(i).getLocalName();
+			
+			if ((prefix != null) && (prefix.equals(XMLUtil.JBOSSESB_PREFIX)))
+			{
+				if (tag != null)
+				{
+					if (tag.equals(SPECIFICATION_VERSION_TAG))
+						getAddr().addExtension(SPECIFICATION_VERSION_TAG, nl.item(i).getTextContent());
+					else
+					{
+						if (tag.equals(DESTINATION_NAME_TAG))
+							getAddr().addExtension(DESTINATION_NAME_TAG, nl.item(i).getTextContent());
+						else
+						{
+							if (tag.equals(CONNECTION_FACTORY_TAG))
+								getAddr().addExtension(CONNECTION_FACTORY_TAG, nl.item(i).getTextContent());
+							else
+							{
+								if (tag.equals(JNDI_CONTEXT_FACTORY_TAG))
+									getAddr().addExtension(JNDI_CONTEXT_FACTORY_TAG, nl.item(i).getTextContent());
+								else
+								{
+									if (tag.equals(JNDI_PKG_PREFIX_TAG))
+										getAddr().addExtension(JNDI_PKG_PREFIX_TAG, nl.item(i).getTextContent());
+									else
+									{
+										if (tag.equals(JNDI_URL_TAG))
+											getAddr().addExtension(JNDI_URL_TAG, nl.item(i).getTextContent());
+										else
+										{
+											if (tag.equals(MESSAGE_SELECTOR_TAG))
+												getAddr().addExtension(MESSAGE_SELECTOR_TAG, nl.item(i).getTextContent());
+										}
+									}
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+
+	/**
+	 * Create a new JMS EPR. The protocol version is assumed to be 1.1. ,
+	 * jndi_type=jboss, jndi_url=localhost, messageSelector=null
+	 * 
+	 * @param destinationType
+	 *            the type of destination (queue/topic).
+	 * @param destinationName
+	 *            name of the queue/topic.
+	 * @param connection
+	 *            reference to the connection factory.
+	 */
+
+	public JMSEpr(String destinationType, String destinationName,
+			String connection)
+	{
+		this(ONE_ONE_PROTOCOL, destinationType, destinationName, connection,
+				NamingContext.JBOSS_PROVIDER_URL,
+				NamingContext.JBOSS_INITIAL_CONTEXT_FACTORY, null, null);
+	}
+
+	/**
+	 * Create a new JMS EPR. The protocol version is assumed to be 1.1.
+	 * 
+	 * @param destinationType
+	 *            the type of destination (queue/topic).
+	 * @param destinationName
+	 *            name of the queue/topic.
+	 * @param connection
+	 *            reference to the connection factory.
+	 * @param jndiType
+	 *            reference to the type of jndi to obtain the JMS objects from
+	 * @param jndiUrl
+	 *            reference to the location of the jndi to obtain the JMS
+	 *            objects from
+	 * @param messageSelector
+	 *            reference to the connection factory.
+	 */
+
+	public JMSEpr(String destinationType, String destinationName,
+			String connection, String jndiUrl, String jndiContextFactory,
+			String jndiPkgPrefix, String messageSelector)
+	{
+		this(ONE_ONE_PROTOCOL, destinationType, destinationName, connection,
+				jndiUrl, jndiContextFactory, jndiPkgPrefix, messageSelector);
+	}
+
+	/**
+	 * Create a new JMS EPR.
+	 * 
+	 * @param protocol
+	 *            the protocol version.
+	 * @param destinationType
+	 *            the type of destination (queue/topic).
+	 * @param destinationName
+	 *            name of the queue/topic.
+	 * @param connection
+	 *            reference to the connection factory.
+	 * @param jndiType
+	 *            reference to the type of jndi to obtain the JMS objects from
+	 * @param jndiUrl
+	 *            reference to the location of the jndi to obtain the JMS
+	 *            objects from
+	 * @param messageSelector
+	 *            reference to the connection factory.
+	 */
+
+	public JMSEpr(String protocol, String destinationType,
+			String destinationName, String connection, String jndiUrl,
+			String jndiContextFactory, String jndiPkgPrefix,
+			String messageSelector)
+	{
+		// how many of these do we really need? modify accordingly.
+
+		if ((protocol == null) || (destinationType == null)
+				|| (destinationName == null) || (connection == null))
+			throw new IllegalArgumentException();
+
+		if (protocol.equals(ONE_ONE_PROTOCOL)
+				|| (protocol.equals(ONE_ZERO_TWO_PROTOCOL)))
+		{
+			if (destinationType.equals(QUEUE_TYPE)
+					|| destinationType.equals(TOPIC_TYPE))
+			{
+				PortReference addr = new PortReference(JMS_PROTOCOL
+						+ PROTOCOL_SEPARATOR + destinationType);
+
+				addr.addExtension(SPECIFICATION_VERSION_TAG, protocol);
+
+				if (destinationName != null)
+					addr.addExtension(DESTINATION_NAME_TAG, destinationName);
+
+				if (connection != null)
+					addr.addExtension(CONNECTION_FACTORY_TAG, connection);
+
+				if (jndiContextFactory != null)
+					addr.addExtension(JNDI_CONTEXT_FACTORY_TAG, jndiContextFactory);
+
+				if (jndiPkgPrefix != null)
+					addr.addExtension(JNDI_PKG_PREFIX_TAG, jndiPkgPrefix);
+
+				if (jndiUrl != null)
+					addr.addExtension(JNDI_URL_TAG, jndiUrl);
+
+				if (messageSelector != null)
+					addr.addExtension(MESSAGE_SELECTOR_TAG, messageSelector);
+
+				setAddr(addr);
+			}
+			else
+				throw new IllegalArgumentException("Invalid destination type! "+destinationType);
+		}
+		else
+			throw new IllegalArgumentException("Invalid specification version!");
+	}
+
+	/*
+	 * There are deliberately no setters for the values once the EPR is created.
+	 */
+
+	/**
+	 * @return the destination type used.
+	 * @throws URISyntaxException
+	 *             thrown if the address is malformed.
+	 */
+
+	public final String getDestinationType() throws URISyntaxException
+	{
+		URI uri = new URI(getAddr().getAddress());
+
+		return uri.getHost(); // ;-)
+	}
+
+	/**
+	 * @return the specification version used.
+	 * @throws URISyntaxException
+	 *             thrown if the address is malformed.
+	 */
+
+	public final String getVersion() throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(SPECIFICATION_VERSION_TAG);
+	}
+
+	/**
+	 * @return the destination name used.
+	 * @throws URISyntaxException
+	 *             thrown if the address is malformed.
+	 */
+
+	public final String getDestinationName() throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(DESTINATION_NAME_TAG);
+	}
+
+	/**
+	 * @return the connection factory for this EPR, or <code>null</code> if
+	 *         none is set.
+	 * @throws URISyntaxException
+	 *             thrown if the address is malformed.
+	 */
+
+	public final String getConnectionFactory() throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(CONNECTION_FACTORY_TAG);
+	}
+
+	/**
+	 * @return the jndi context factory for this EPR, or <code>null</code> if
+	 *         none is set.
+	 * @throws URISyntaxException
+	 *             thrown if the address is malformed.
+	 */
+
+	public final String getJndiContextFactory() throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(JNDI_CONTEXT_FACTORY_TAG);
+	}
+
+	/**
+	 * @return the jndi pkg prefix for this EPR, or <code>null</code> if none
+	 *         is set.
+	 * @throws URISyntaxException
+	 *             thrown if the address is malformed.
+	 */
+
+	public final String getJndiPkgPrefix() throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(JNDI_PKG_PREFIX_TAG);
+	}
+
+	/**
+	 * @return the jndi URL for this EPR, or <code>null</code> if none is set.
+	 * @throws URISyntaxException
+	 *             thrown if the address is malformed.
+	 */
+
+	public final String getJndiURL() throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(JNDI_URL_TAG);
+	}
+
+	/**
+	 * @return the message selector for this EPR, or <code>null</code> if none
+	 *         is set.
+	 * @throws URISyntaxException
+	 *             thrown if the address is malformed.
+	 */
+
+	public final String getMessageSelector() throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(MESSAGE_SELECTOR_TAG);
+	}
+
+	public static final URI type()
+	{
+		return _type;
+	}
+
+	private static URI _type;
+
+	static
+	{
+		try
+		{
+			_type = new URI("urn:jboss/esb/epr/type/jms");
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+
+			throw new ExceptionInInitializerError(ex.toString());
+		}
+	}
+
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/SFTPEpr.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/SFTPEpr.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/eprs/SFTPEpr.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,164 @@
+package org.jboss.soa.esb.addressing.eprs;
+
+/*
+ * 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 class represents the endpoint reference for services.
+ */
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * A helper class for using FTP style EPRs. Simply create instances of this
+ * class instead of the base EPR. Since URLs can use FTP, we try to leverage
+ * that as much as possible.
+ * 
+ * @author marklittle
+ * 
+ */
+public class SFTPEpr extends FTPEpr
+{
+	public static final String CERTIFICATE_TAG = "certificate";
+
+	public SFTPEpr(EPR epr)
+	{
+		super(epr);
+
+		copy(epr);
+	}
+	
+	public SFTPEpr (EPR epr, Element header)
+	{
+		super(epr, header);
+		
+		copy(epr);
+		
+		NodeList nl = header.getChildNodes();
+
+		for (int i = 0; i < nl.getLength(); i++)
+		{
+			String prefix = nl.item(i).getPrefix();
+			String tag = nl.item(i).getLocalName();
+			
+			try
+			{
+				if ((prefix != null) && (prefix.equals(XMLUtil.JBOSSESB_PREFIX)))
+				{
+					if ((tag != null) && (tag.equals(CERTIFICATE_TAG)))
+						getAddr().addExtension(CERTIFICATE_TAG, nl.item(i).getTextContent());
+				}
+			}
+			catch (Exception ex)
+			{
+				ex.printStackTrace();
+			}
+		}
+	}
+
+	public SFTPEpr(URL url) throws URISyntaxException
+	{
+		super(url);
+	}
+
+	public SFTPEpr(URL url, URL cert) throws URISyntaxException
+	{
+		super(url);
+		
+		setCertificateURL(cert);
+	}
+
+	public SFTPEpr(String url, String cert) throws URISyntaxException, MalformedURLException
+	{
+		super(url);	
+
+		setCertificateURL(new URL(cert));
+	}
+
+	/**
+	 * Set the Certificate URL for this endpoint.
+	 * 
+	 * @param url
+	 *            the address.
+	 * @throws URISyntaxException
+	 *             thrown if this EPR is malformed.
+	 */
+
+	public final void setCertificateURL(URL cert) throws URISyntaxException
+	{
+		if (cert == null)
+			throw new IllegalArgumentException();
+
+		if (certificateSet)
+			throw new IllegalStateException("Certificate URL already set.");
+
+		getAddr().addExtension(CERTIFICATE_TAG, cert.toString());
+		certificateSet = true;
+	}
+
+	/**
+	 * @return the certificate URL for this EPR.
+	 * @throws URISyntaxException
+	 *             thrown if this EPR is malformed.
+	 */
+
+	public final URL getCertificateURL () throws URISyntaxException,
+			MalformedURLException
+	{
+		String cert = getAddr().getExtensionValue(CERTIFICATE_TAG);
+
+		if (cert != null)
+			return new URL(cert);
+		else
+			return null;
+	}
+
+	public static URI type ()
+	{
+		return _type;
+	}
+
+	private boolean certificateSet = false;
+
+	private static URI _type;
+
+	static
+	{
+		try
+		{
+			_type = new URI("urn:jboss/esb/epr/type/sftp");
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+
+			throw new ExceptionInInitializerError(ex.toString());
+		}
+	}
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/util/EPRManager.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/util/EPRManager.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/addressing/util/EPRManager.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,226 @@
+/*
+ * 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
+ */
+
+package org.jboss.soa.esb.addressing.util;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Hashtable;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+/**
+ * Allows EPRs to be saved to and loaded from files. Mainly for testing
+ * purposes. This version assumes XML as the output format.
+ * 
+ * @author marklittle
+ * 
+ */
+
+public class EPRManager
+{
+
+	/**
+	 * All EPRs are saves in files within the current working directory.
+	 * 
+	 * @return the manager for the cwd.
+	 */
+
+	public static final EPRManager getInstance()
+	{
+		return getInstance("");
+	}
+
+	/**
+	 * All EPRs are saves in files within a defined directory. Get the right
+	 * manager for that directory.
+	 * 
+	 * @param domain
+	 *            the name of the directory. If <code>null</code> then the
+	 *            null String is assumed.
+	 * @return the manager for the directory. If it does not exist, then one
+	 *         will be created.
+	 */
+
+	public static final EPRManager getInstance(String domain)
+	{
+		if (domain == null)
+			domain = "";
+
+		synchronized (_instances)
+		{
+			EPRManager theInstance = _instances.get(domain);
+
+			if (theInstance == null)
+			{
+				theInstance = new EPRManager(domain);
+
+				_instances.put(domain, theInstance);
+			}
+
+			return theInstance;
+		}
+	}
+
+	public final String getDomain()
+	{
+		return _directory;
+	}
+
+	public boolean equals(Object manager)
+	{
+		if (manager instanceof EPRManager)
+		{
+			EPRManager comp = (EPRManager) manager;
+
+			if (_directory.equals(comp.getDomain()))
+				return true;
+		}
+
+		return false;
+	}
+
+	/**
+	 * Save the EPR into the specified file.
+	 * 
+	 * @param name
+	 *            the name of the file to use (the logical service name).
+	 * @param address
+	 *            the EPR to save.
+	 * 
+	 * @throws IOException
+	 *             thrown if there is an error.
+	 */
+
+	public final void saveEPR(String name, EPR address) throws IOException
+	{
+		if ((name == null) || (address == null))
+			throw new IllegalArgumentException();
+
+		try
+		{
+			String documentAsString = EPRHelper.toXMLString(address);
+
+			FileOutputStream output = new FileOutputStream(_directory
+					+ File.separator + name);
+
+			output.write(documentAsString.getBytes());
+			output.flush();
+			output.getFD().sync(); // make sure it's on disk!
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+	}
+
+	/**
+	 * Remove the EPR-to-file association.
+	 * 
+	 * @param name
+	 *            the logical name for the service.
+	 * @throws IOException
+	 *             thrown if there are any errors.
+	 */
+
+	public final void removeEPR(String name) throws IOException
+	{
+		if (name == null)
+			throw new IllegalArgumentException();
+
+		File theFile = new File(_directory + File.separator + name);
+
+		if (theFile.exists())
+			theFile.delete();
+		else
+			throw new FileNotFoundException();
+	}
+
+	/**
+	 * Get the EPR specified by the logical name.
+	 * 
+	 * @param name
+	 *            the service name.
+	 * @return the EPR, or <code>null</code> if none exists.
+	 * @throws IOException
+	 *             thrown if there is an error.
+	 */
+
+	public final EPR loadEPR(String name) throws IOException
+	{
+		if (name == null)
+			throw new IllegalArgumentException();
+
+		File theFile = new File(_directory + File.separator + name);
+
+		try
+		{
+			if (theFile.exists())
+			{
+				DocumentBuilderFactory factory = DocumentBuilderFactory
+						.newInstance();
+				
+				factory.setNamespaceAware(true);
+				
+				DocumentBuilder builder = factory.newDocumentBuilder();
+				Document doc = builder.parse(theFile);
+				Element rootElement = doc.getDocumentElement();
+
+				return EPRHelper.fromXML(rootElement);
+			}
+			else
+				throw new FileNotFoundException(theFile.toString());
+		}
+		catch (UnmarshalException ex)
+		{
+			throw new IOException(ex.toString());
+		}
+		catch (SAXException ex)
+		{
+			throw new IOException(ex.toString());
+		}
+		catch (ParserConfigurationException ex)
+		{
+			throw new IllegalArgumentException(ex.toString());
+		}
+	}
+
+	protected EPRManager(String domain)
+	{
+		_directory = domain;
+	}
+
+	private String _directory;
+
+	private static Hashtable<String, EPRManager> _instances = new Hashtable<String, EPRManager>();
+
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/common/Environment.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/common/Environment.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/common/Environment.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,123 @@
+/*
+ * 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.common;
+
+public class Environment
+{
+	public static final String PROPERTIES_FILE = "org.jboss.soa.esb.propertyFile";
+	
+	/*
+	 * Transport specific properties.
+	 */
+	
+	public static final String SMTP_HOST     = "org.jboss.soa.esb.mail.smtp.host";
+	public static final String SMTP_USERNAME = "org.jboss.soa.esb.mail.smtp.user";
+	public static final String SMTP_PASSWORD = "org.jboss.soa.esb.mail.smtp.password";
+	public static final String SMTP_PORT     = "org.jboss.soa.esb.mail.smtp.port";
+	public static final String SMTP_FROM     = "org.jboss.soa.esb.mail.smtp.from";
+	public static final String SMTP_AUTH     = "org.jboss.soa.esb.mail.smtp.auth";
+	
+	public static final String FTP_LOCALDIR  = "org.jboss.soa.esb.ftp.localdir";
+	public static final String FTP_REMOTEDIR = "org.jboss.soa.esb.ftp.remotedir";
+	
+	/*
+	 * Code properties
+	 */
+	public static final String JNDI_SERVER_URL                = "org.jboss.soa.esb.jndi.server.url";
+	public static final String JNDI_SERVER_CONTEXT_FACTORY    = "org.jboss.soa.esb.jndi.server.context.factory";
+	public static final String JNDI_SERVER_PKG_PREFIX         = "org.jboss.soa.esb.jndi.server.pkg.prefix";
+	public static final String PARAMS_REPOS_IMPL_CLASS        = "org.jboss.soa.esb.paramsRepository.class";
+	public static final String OBJECT_STORE_CONFIG_FILE       = "org.jboss.soa.esb.objStore.configFile";
+	public static final String ENCRYPT_FACTORY_CLASS          = "org.jboss.soa.esb.encryption.factory.class";
+	/** 
+	 * The Registry Query Manager URI defines the endPoint where registry queries can be made. 
+	 */
+	public static final String REGISTRY_QUERY_MANAGER_URI     = "org.jboss.soa.esb.registry.queryManagerURI";
+	/** 
+	 * The Registry Lifecycle Manager URI defines the endPoint where service information can be published to.
+	 */
+	public static final String REGISTRY_LIFECYCLE_MANAGER_URI = "org.jboss.soa.esb.registry.lifeCycleManagerURI";
+    /**
+     * The Registry Implementation class, a light wrapper class.
+     */
+	public static final String REGISTRY_IMPEMENTATION_CLASS = "org.jboss.soa.esb.registry.implementationClass";
+	/** 
+	 * The Registry Factory Class setting specifies which JAXR implementation should be used.
+	 */
+	public static final String REGISTRY_FACTORY_CLASS         = "org.jboss.soa.esb.registry.factoryClass";
+	/**
+	 * The user used to query and publish to the registry.
+	 */
+	public static final String REGISTRY_USER                  = "org.jboss.soa.esb.registry.user";
+	/**
+	 * The password for the registry user.
+	 */
+	public static final String REGISTRY_PASSWORD              = "org.jboss.soa.esb.registry.password";
+	/** 
+	 * The Registry Scout Transport Class property defines which communication protocol Scout should use to communicate
+	 * with the UDDI registry. Note that this parameter is Scout specific.
+	 */
+	public static final String REGISTRY_SCOUT_TRANSPORT_CLASS = "org.jboss.soa.esb.scout.proxy.transportClass";
+	/** 
+	 * Property that holds directory to use with the helper EPRManager class.
+	 */
+	public static final String REGISTRY_FILE_HELPER_DIR       = "org.jboss.soa.esb.registry.file.directory";
+	/**
+	 * The Content Based Router class property declares which CBR Implementation should be used.
+	 */
+	public static final String ROUTER_CBR_CLASS               = "org.jboss.soa.esb.routing.cbrClass";
+	/*
+	 * Connection specific properties
+	 */
+	public static String DB_DRIVER = "org.jboss.esb.db.driver";
+	public static String DB_URL = "org.jboss.esb.db.url";
+	public static String DB_USER = "org.jboss.esb.db.user";
+	public static String DB_PASSWORD = "org.jboss.esb.db.password";
+	
+	/*
+	 * Some default values.
+	 */
+	public static final String DEFAULT_PROPERTY_FILE                  = "jbossesb-properties.xml";
+	public static final String DEFAULT_HOST                           = "localhost";
+	public static final String DEFAULT_USERNAME                       = "";
+	public static final String DEFAULT_PASSWORD                       = "";
+	public static final String DEFAULT_PORT                           = "25";
+	public static final String DEFAULT_JNDI_CONTEXT_FACTORY           = "org.jnp.interfaces.NamingContextFactory";
+	public static final String DEFAULT_JNDI_PKG_PREFIX                = "org.jboss.naming:org.jnp.interfaces";
+	
+	/*
+	 * DatabaseMessageStore Persistence Store properties.
+	 */
+	public static final String MSG_STORE_CONN_FACTORY			= "org.jboss.soa.esb.persistence.connection.factory";
+	public static final String MSG_STORE_DB_CONNECTION_URL 		= "org.jboss.soa.esb.persistence.db.connection.url";
+	public static final String MSG_STORE_DB_CONNECTION_USER 	= "org.jboss.soa.esb.persistence.db.user";
+	public static final String MSG_STORE_DB_CONNECTION_PWD 		= "org.jboss.soa.esb.persistence.db.pwd";
+	public static final String MSG_STORE_DB_TABLE_NAME 			= "org.jboss.soa.esb.persistence.db.table";
+	public static final String MSG_STORE_DB_JDBC_DRIVER			= "org.jboss.soa.esb.persistence.db.jdbc.driver";
+	public static final String MSG_STORE_DB_POOL_INITIAL_SIZE	= "org.jboss.soa.esb.persistence.db.pool.initial.size";
+	public static final String MSG_STORE_DB_POOL_MIN_SIZE		= "org.jboss.soa.esb.persistence.db.pool.min.size";
+	public static final String MSG_STORE_DB_POOL_MAX_SIZE		= "org.jboss.soa.esb.persistence.db.pool.max.size";
+	public static final String MSG_STORE_DB_POOL_TEST_TABLE		= "org.jboss.soa.esb.persistence.db.pool.test.table";
+	public static final String MSG_STORE_DB_POOL_TIMEOUT_MILLIS	= "org.jboss.soa.esb.persistence.db.pool.timeout.millis";	
+
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/common/ModulePropertyManager.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/common/ModulePropertyManager.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/common/ModulePropertyManager.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,186 @@
+/*
+ * 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 JBoss Inc.
+ */
+/*
+ * Copyright (C) 2002
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: arjPropertyManager.java 2342 2006-03-30 13:06:17Z  $
+ */
+
+package org.jboss.soa.esb.common;
+
+import java.util.Hashtable;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.FatalError;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.common.ModulePropertyManager;
+
+import com.arjuna.common.internal.util.propertyservice.plugins.io.XMLFilePlugin;
+import com.arjuna.common.util.exceptions.LoadPropertiesException;
+import com.arjuna.common.util.propertyservice.PropertyManager;
+import com.arjuna.common.util.propertyservice.PropertyManagerFactory;
+
+/**
+ * The ESB configuration file is split into modules, each concerned with a
+ * specific capability. Each module may also depend upon another module. We use
+ * a PropertyManager per module to manage properties and relationships.
+ * 
+ * All properties are grouped within <properties/> sections and individual
+ * properties by <property/>. If you look at some you'll see that they may be
+ * named and may have a depends value, which relates to another section. This
+ * tells the PropertyManager to load the depends section first. A property value
+ * may be overridden by a dependant section, but the PropertyManager remembers
+ * the hierarchy, so if you want to you can inspect and change the lower level
+ * value and the PropertyManager can be used to preserve these changes if the
+ * values are written back out to the source location.
+ * 
+ * The way the PropertyManager works means that it builds up a list of dependant
+ * modules in a directed acyclic graph. This means that there is a root, which
+ * can see every property below it, but nodes below cannot see properties above
+ * them: there is a level of isolation.
+ * 
+ * When creating PropertyManagers, you need to specify where in the graph it is
+ * to "tie in". This obviously has an affect on what that instance can then see
+ * or do: if it goes in at the wrong level, it won't be able to see properties
+ * it may need (unless they were defined to be "system" properties, and in which
+ * case they are globally accessible.)
+ * 
+ * This means that we now have isolated PropertyManagers for each module. It
+ * helps the management side of things a lot, but does mean that we have to
+ * consider where in the graph a property needs to be, or which PropertyManager
+ * we want to use to try to access it.
+ * 
+ * @author marklittle
+ * 
+ */
+public class ModulePropertyManager
+{
+
+	/*
+	 * The names of the various modules in the property file.
+	 */
+
+	public static final String CORE_MODULE = "core";
+
+	public static final String CONNECTION_MODULE = "connection";
+
+	public static final String REGISTRY_MODULE = "registry";
+
+	public static final String TRANSPORTS_MODULE = "transports";
+
+	public static final String DBSTORE_MODULE = "dbstore";
+
+	public static final String ROUTER_MODULE = "messagerouting";
+
+	/**
+	 * Get the property manager responsible for the module component in the
+	 * file.
+	 * 
+	 * @param name
+	 *            the name of the module.
+	 * @return the relevant property manager.
+	 */
+
+	public static PropertyManager getPropertyManager(String name)
+	{
+		synchronized (managers)
+		{
+			PropertyManager theManager = managers.get(name);
+
+			if (theManager == null)
+			{
+				theManager = initialise(name);
+
+				if (theManager != null)
+				{
+					managers.put(name, theManager);
+				}
+			}
+
+			return theManager;
+		}
+	}
+
+	private static final PropertyManager initialise(String name)
+	{
+		/**
+		 * Retrieve the property manager from the factory and add the ESB
+		 * properties file to it.
+		 * 
+		 * set com.arjuna.common.util.propertyservice.verbosePropertyManager=ON
+		 * for verbose output from the PropertyManager.
+		 */
+
+		try
+		{
+			PropertyManager propertyManager = PropertyManagerFactory
+					.getPropertyManager(
+							"org.jboss.soa.esb.propertymanager." + name, name);
+	
+			String propertiesFilename = System.getProperty(
+					Environment.PROPERTIES_FILE, Environment.DEFAULT_PROPERTY_FILE);
+	
+			/*
+			 * Does not cause reloading of the same file over and over. Once it is
+			 * loaded, subsequent attempts to reload are ignored internally.
+			 */
+	
+			try
+			{
+				propertyManager.load(XMLFilePlugin.class.getName(),
+						propertiesFilename);
+			}
+			catch (LoadPropertiesException ex)
+			{
+				_logger.fatal("ModulePropertyManager failed to load property file "+propertiesFilename);
+				
+				throw new FatalError(ex);
+			}
+			catch (ClassNotFoundException e)
+			{
+				// something seriously wrong; better to terminate.
+				
+				_logger.fatal("ModulePropertyManager failed to load XML plugin", e);
+				
+				throw new FatalError(e);
+			}
+	
+			return propertyManager;
+		}
+		catch (Exception e)
+		{
+			// something seriously wrong; better to terminate.
+			
+			_logger.fatal("ModulePropertyManager failed to load PropertyManager", e);
+			
+			throw new FatalError(e);
+		}
+	}
+
+	private static Hashtable<String, PropertyManager> managers = new Hashtable<String, PropertyManager>();
+	
+	private static Logger _logger = Logger.getLogger(ModulePropertyManager.class);
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/helpers/NamingContext.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/helpers/NamingContext.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/helpers/NamingContext.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,98 @@
+/*
+ * 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.helpers;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Obtains JNDI naming context.
+ */
+
+public abstract class NamingContext
+{
+	/**
+	 * Logger for this class
+	 */
+	private static final Logger _logger = Logger.getLogger(NamingContext.class);
+
+	public static final int MAX_RETRIES = 10;
+
+	public static final String JBOSS_PROVIDER_URL = "localhost";
+
+	public static final String JBOSS_INITIAL_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory";
+
+	public static final String JBOSS_URL_PKG_PREFIX = ""; // "org.jboss.naming:org.jnp.interfaces"
+
+	/**
+	 * Tries to connect to the server to obtain the server Context.
+	 * 
+	 * @param providerUrl
+	 * @param initialContextFactory
+	 * @param urlPkgPrefixes
+	 * @return the InitialContext.
+	 */
+	public static Context getServerContext(String providerUrl,
+			String initialContextFactory, String urlPkgPrefixes)
+	{
+		Properties properties = new Properties();
+		properties.setProperty(Context.PROVIDER_URL, providerUrl);
+		properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+				initialContextFactory);
+		if (urlPkgPrefixes != null && !"".equals(urlPkgPrefixes))
+		{
+			properties.setProperty(Context.URL_PKG_PREFIXES, urlPkgPrefixes);
+		}
+
+		boolean bCtxOK = false;
+		Context oCtx = null;
+		for (int i1 = 0; (!bCtxOK) && i1 < MAX_RETRIES; i1++)
+		{
+			// check if context is valid
+			try
+			{
+				oCtx = new InitialContext(properties);
+				oCtx.list("__dummy2@#$%");
+				bCtxOK = true;
+			}
+			catch (NamingException nex)
+			{
+				bCtxOK = true;
+			}
+		}
+		if (bCtxOK)
+		{
+			return oCtx;
+		}
+		else
+		{
+			_logger.error("Can't connect to JNDI Server <" + providerUrl + ">");
+			return null;
+		}
+	}
+
+}


Property changes on: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/helpers/NamingContext.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Attachment.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Attachment.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Attachment.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,110 @@
+package org.jboss.soa.esb.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
+ */
+
+/**
+ * Messages may contain attachments that do not appear in the main payload body.
+ * For example, binary document formats, zip files etc.
+ * <br/>Handles both 'named' attachment and a list of 'unnamed' attachments
+ * 
+ * @author Mark Little
+ */
+
+public interface Attachment
+{
+	/**
+	 * Returns the attachment to which this object maps the specified key. 
+	 * Returns null if the there's no value mapped for this key.
+	 * @param name String - The name of the attachment to get
+	 * @return Object - the value mapped to arg0 or &lt;null&gt; if none
+	 */
+	Object get(String name);
+	/**
+	 * Associates the specified value with the specified name
+	 * If there was already a mapping for this name, the old value is replaced by 
+	 * arg1
+	 * @param name String - the name for the object to be stored
+	 * @param value Object - the object to be associated with the name (arg0)
+	 * @return Object - previous value associated with specified name,
+	 * or null  if there was none
+	 */
+	Object put(String name, Object value);
+	/**
+	 * Removes the mapping for this name if it was present
+	 * @param name String - the name of the object to be removed
+	 * @return the value previously associated the name, or null if there was none
+	 */
+	Object remove(String name);
+	/**
+	 * @return String[] - the list of names of the named Objects
+	 */
+	String[] getNames();
+
+	/**
+     * get the item at the specified position in the list of unnamed objects
+     * @param index int - index of element to return
+     * @return Object the element at the specified position in the list of unnamed objects
+     * @throws IndexOutOfBoundsException - if the index is out of range
+     */
+	Object itemAt 		(int index) throws IndexOutOfBoundsException;
+	/**
+	 * Removes the element at the specified position in the list of unnamed objects
+	 * Shifts any subsequent elements to the left 
+	 * @param index int - index of element to remove
+	 * @return Object - the element that was removed from the list
+	 * @throws IndexOutOfBoundsException - if the index is out of range
+	 */
+	Object removeItemAt	(int index) throws IndexOutOfBoundsException;
+	/**
+	 * Replaces the element at the specified position in the list of unnamed objects 
+	 * with the value supplied
+	 * @param index int - index of element to be replaced
+	 * @param  value Object - the object to replace the one previously stored at that index
+	 * @return Object - previous value at that index
+	 * @throws IndexOutOfBoundsException - if the index is out of range
+	 */
+	Object replaceItemAt(int index, Object value) throws IndexOutOfBoundsException;
+	/**
+	 * Appends the specified element to the end of the list of unnamed objects
+	 * <br/>null values are allowed 
+	 * @param value Object - the object to be appended
+	 */
+	void addItem		(Object value);
+	/**
+	 * Replaces the element at the specified position in the list of unnamed objects
+	 * <br/> allows null values
+	 * @param index int - index where to insert the value - Shifts any subsequent elements to the right
+	 * @param value Object - value to be stored at the specified position
+	 * @throws IndexOutOfBoundsException
+	 */
+	void addItemAt	(int index, Object value) throws IndexOutOfBoundsException;
+	/**
+	 * getUnnamedCount()
+	 * @return the count of unnamed objects
+	 */
+	int	getUnnamedCount();
+	/**
+	 * getNamedCount()
+	 * @return the count of named objects
+	 */
+	public int getNamedCount(); 
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,108 @@
+package org.jboss.soa.esb.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
+ */
+
+/**
+ * The message body holds arbitrary information which represents the
+ * payload as far as clients and services are concerned. A body may contain:
+ * 
+ * (i) a byte array for arbitrary data. How that array is interpreted by the
+ * service is implementation specific and outside the scope of the ESB to
+ * enforce.
+ * 
+ * (ii) a list of Objects of arbitrary types. How these objects are serialized
+ * to/from the message body when it is transmitted is up to the specific
+ * Object type. The plan is to add support for various TYPES of Object and the message
+ * implementation will use external adapters to externalize/internalize the Objects.
+ * Currently we only support Serializable objects.
+ */
+
+public interface Body
+{
+	// TODO error handling exceptions
+	
+	/**
+	 * Add the specified Object to the body.
+	 * 
+	 * @param name the name of the object. MUST be unique within this body.
+	 * @param value the Object to add.
+	 */
+	
+	public void add (String name, Object value);
+	
+	/**
+	 * Get the specified Object, or <code>null</code> if not present.
+	 * 
+	 * @param name the name of the Object to retrieve.
+	 * @return the Object.
+	 */
+	
+	public Object get (String name);
+	
+	/**
+	 * Remove the specified Object and return it, or <code>null</code> if not present.
+	 * 
+	 * @param name the name of the Object to remove.
+	 * @return the Object removed.
+	 */
+	
+	public Object remove (String name);
+	
+	/**
+	 * Set the byte content of the body.
+	 * 
+	 * @param content the message bytes
+	 */
+	
+	public void setContents (byte[] content);
+	
+	/**
+	 * @return the byte content of the body.
+	 */
+	
+	public byte[] getContents ();
+
+	/**
+	 * Replace this body instance with the one given.
+	 * 
+	 * @param b the body to be replaced with.
+	 */
+	
+	public void replace (Body b);
+	
+	/**
+	 * Merge two bodies.
+	 * 
+	 * @param b the body to be merged with.
+	 */
+	
+	public void merge (Body b);
+	
+	/**
+	 * @return get the list of names in this instance.
+	 */
+	
+	public String[] getNames ();
+	
+	// TODO replace an entry in the body
+
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Context.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Context.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Context.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,33 @@
+package org.jboss.soa.esb.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
+ */
+
+/**
+ * The context is the section of the message containing information such as session
+ * management, transaction information, security data etc. Entries in the context
+ * may be ordered.
+ */
+
+public interface Context
+{
+	// TODO add some methods!
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Fault.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Fault.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Fault.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,61 @@
+package org.jboss.soa.esb.message;
+
+import java.net.URI;
+
+/*
+ * 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
+ */
+
+/**
+ * Faults may be returned from a service in response to receiving and acting upon messages.
+ * A fault consists of a unique code (MANDATORY) and a reason string (OPTIONAL).
+ */
+
+public interface Fault
+{
+	/**
+	 * @return the unique code representing this fault.
+	 */
+	
+	public URI getCode ();
+	
+	/**
+	 * Set the unique code for this fault.
+	 * 
+	 * @param code the code.
+	 */
+	
+	public void setCode (URI code);
+	
+	/**
+	 * @return a String representing the reason for the fault. Typically used for
+	 * logging purposes.
+	 */
+	
+	public String getReason ();
+	
+	/**
+	 * Set the optional reason for this fault.
+	 * 
+	 * @param reason the reason for the fault.
+	 */
+	
+	public void setReason (String reason);
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Header.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Header.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Header.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,45 @@
+package org.jboss.soa.esb.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
+ */
+
+import org.jboss.soa.esb.addressing.Call;
+
+/**
+ * The message header. Contains such things as routing information.
+ */
+
+public interface Header
+{
+	/**
+	 * @return get the Call information for this message.
+	 */
+	
+	public Call getCall ();
+	
+	/**
+	 * Set the call information for this message.
+	 * 
+	 * @param call the information.
+	 */
+	
+	public void setCall (Call call);
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Message.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Message.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Message.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,92 @@
+package org.jboss.soa.esb.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
+ */
+
+import java.net.URI;
+
+/**
+ * This is the basic internal core message abstraction. A message consists of the following
+ * components:
+ * 
+ * Header: the header information contains information such as the destination EPR, the
+ * sender EPR, where the reply goes etc, i.e., general message-level functional information.
+ * Context: additional information to contextualise the message; for example, transaction or
+ * security data, the identity of the ultimate receiver, or HTTP-cookie like information.
+ * Body: the actual payload of the message.
+ * Fault: any fault information associated with the message.
+ * Attachment: any attachments associated with the message.
+ * Properties: any message specific properties.
+ * 
+ * Each message, once created, has a corresponding element for these 5 components. That element
+ * may be empty (<b>NOT NULL</b>). The object representing the element can then be used to act
+ * on the corresponding data item in the message.
+ * 
+ * @author Mark Little
+ *
+ */
+
+public interface Message
+{
+	/**
+	 * @return get the header component of the message.
+	 */
+	
+	public Header getHeader ();
+
+	/**
+	 * @return get the context component of the message.
+	 */
+	
+	public Context getContext ();
+	
+	/**
+	 * @return get the body component of the message.
+	 */
+	
+	public Body getBody ();
+
+	/**
+	 * @return get any faults associated with the message. These should not
+	 * be application level faults, but comms level.
+	 */
+	
+	public Fault getFault ();
+	
+	/**
+	 * @return get any message attachments.
+	 */
+	
+	public Attachment getAttachment ();
+	
+	/**
+	 * @return the type of this message.
+	 */
+	
+	public URI getType ();
+	
+	/**
+	 * @return Properties - any message properties.
+	 */
+	
+	public Properties getProperties ();
+	
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Properties.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Properties.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Properties.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,88 @@
+/*
+ * 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 schifest at heuristica.com.ar
+ */
+
+package org.jboss.soa.esb.message;
+
+/**
+ * The message properties hold arbitrary information in the form of
+ * &lt;String,Object&gt; pairs
+ * 
+ */
+
+public interface Properties
+{
+	/**
+	 * getProperty(name)
+	 * 
+	 * @param name
+	 *            String - name of property
+	 * @return Object - the value stored under the specified name
+	 */
+	public Object getProperty(String name);
+
+	/**
+	 * getProperty(name,defaultVal)
+	 * 
+	 * @param name
+	 *            String - name of property
+	 * @param defaultVal
+	 *            Object - value to return if no value found
+	 * @return Object - the value stored under the specified name
+	 */
+	public Object getProperty(String name, Object defaultVal);
+
+	/**
+	 * setProperty(name,value)
+	 * 
+	 * @param name
+	 *            String - name of property to store
+	 * @param value
+	 *            Object - value of property to store under specified name
+	 * @return Object - the previous value of the specified name, or null if it
+	 *         did not have one
+	 */
+	public Object setProperty(String name, Object value);
+
+	/**
+	 * remove(name)
+	 * 
+	 * @param name
+	 *            String - name of property to remove
+	 * @return Object - the previous value of the specified name, or null if it
+	 *         did not have one
+	 */
+	public Object remove(String name);
+
+	/**
+	 * size()
+	 * 
+	 * @return int - Returns the number of properties in this object
+	 */
+	public int size();
+
+	/**
+	 * getNames()
+	 * 
+	 * @return String[] - containing the names of all properties
+	 */
+	public String[] getNames();
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/MessageFactory.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/MessageFactory.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/MessageFactory.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,76 @@
+package org.jboss.soa.esb.message.format;
+
+import java.net.URI;
+
+import org.jboss.internal.soa.esb.message.format.MessageFactoryImpl;
+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
+ */
+
+/**
+ * You get a message of a specific type when you need it. Obviously that type 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.
+ * 
+ * @author Mark Little
+ *
+ */
+
+public abstract class MessageFactory
+{
+	/**
+	 * @return some default implementation.
+	 */
+	
+	public abstract Message getMessage ();
+	
+	/**
+	 * @param type the unique identifier representing the type of this message.
+	 * @return the message, or <code>null</code> if no suitable plugin is available.
+	 */
+	
+	public abstract Message getMessage (URI type);
+	
+	/**
+	 * @param msg the message to convert.
+	 * @param type the type of the message we want to convert to.
+	 * @return a translated message, or <code>null</code> if no suitable plugin is available.
+	 */
+	
+	public abstract Message getMessage (Message msg, URI type);
+	
+	/**
+	 * Reload the plugins.
+	 */
+	
+	public abstract void reset ();
+	
+	// TODO setters/getters for the plugin programmatically too.
+	
+	public static MessageFactory getInstance ()
+	{
+		return theFactory;
+	}
+	
+	private static final MessageFactory theFactory = new MessageFactoryImpl();
+	
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/MessagePlugin.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/MessagePlugin.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/MessagePlugin.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,52 @@
+package org.jboss.soa.esb.message.format;
+
+import java.net.URI;
+
+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
+ */
+
+/**
+ * Used to plug in new message formats dynamically. Each plugin is responsible for
+ * returning a message implementation that knows how to serialize its state in a
+ * specific manner, e.g., XML or ASN.1.
+ *  
+ * @author Mark Little
+ *
+ */
+
+public interface MessagePlugin
+{
+	public static final String MESSAGE_PLUGIN = "org.jboss.soa.esb.message.format.plugin";
+	
+	/**
+	 * @return the message instance.
+	 */
+	
+	public Message getMessage ();
+	
+	/**
+	 * @return the unique identifier for this message plugin.
+	 */
+	
+	public URI getType ();
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/MessageType.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/MessageType.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/format/MessageType.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,62 @@
+package org.jboss.soa.esb.message.format;
+
+import java.net.URI;
+
+/*
+ * 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. Obviously that type 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.
+ * 
+ * @author Mark Little
+ *
+ */
+
+public abstract class MessageType
+{
+	/*
+	 * DO NOT reorder this list. New types may be added as required.
+	 */
+	
+	public static URI JBOSS_XML = null;
+	public static URI JAVA_SERIALIZED = null;
+
+	public static URI DEFAULT_TYPE = null;
+	
+	static
+	{
+		try
+		{
+			JBOSS_XML = new URI("urn:jboss/esb/message/type/JBOSS_XML");
+			JAVA_SERIALIZED = new URI("urn:jboss/esb/message/type/JAVA_SERIALIZED");
+			
+			DEFAULT_TYPE = JBOSS_XML;
+		}
+		catch (Exception ex)
+		{
+			throw new ExceptionInInitializerError(ex.toString());
+		}
+
+	}
+	
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/EmailUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/EmailUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/EmailUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,68 @@
+/*
+ * 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.addressing.helpers.tests;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.addressing.eprs.EmailEpr;
+
+/**
+ * Unit tests for the EPR class.
+ * 
+ * @author Mark Little
+ */
+
+public class EmailUnitTest extends TestCase
+{
+
+	public void testConstructor ()
+	{
+		try
+		{
+			new EmailEpr(EmailEpr.SMTP_PROTOCOL, "myhost", "25", "foo", "bar");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGet ()
+	{
+		try
+		{
+			EmailEpr em = new EmailEpr(EmailEpr.SMTP_PROTOCOL, "myhost", "25", "foo", "bar");
+			
+			assertEquals(em.getHost(), "myhost");
+			assertEquals(em.getProtocol(), EmailEpr.SMTP_PROTOCOL);
+			assertEquals(em.getPort(), 25);
+			assertEquals(em.getUserName(), "foo");
+			assertEquals(em.getPassword(), "bar");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/FTPUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/FTPUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/FTPUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,72 @@
+/*
+ * 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.addressing.helpers.tests;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+
+/**
+ * Unit tests for the EPR class.
+ * 
+ * @author Mark Little
+ */
+
+public class FTPUnitTest extends TestCase
+{
+
+	public void testConstructor ()
+	{
+		try
+		{
+			new FTPEpr("ftp://foo.com");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGet ()
+	{
+		try
+		{
+			FTPEpr ftp = new FTPEpr("ftp://foo.com");
+			
+			assertEquals(ftp.getURL().toString(), "ftp://foo.com");
+			assertEquals(ftp.getURL().getHost(), "foo.com");
+			assertEquals(ftp.getURL().getProtocol(), "ftp");
+			
+			ftp.setPassword("foobar");
+			assertEquals(ftp.getPassword(), "foobar");
+			
+			ftp.setUserName("barfoo");
+			assertEquals(ftp.getUserName(), "barfoo");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/HTTPUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/HTTPUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/HTTPUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,73 @@
+/*
+ * 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.addressing.helpers.tests;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.addressing.eprs.HTTPEpr;
+
+/**
+ * Unit tests for the EPR class.
+ * 
+ * @author Mark Little
+ */
+
+public class HTTPUnitTest extends TestCase
+{
+
+	public void testConstructor ()
+	{
+		try
+		{
+			String url1 = "http://www.local.bar:8080";
+			new HTTPEpr(url1);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGet ()
+	{
+		try
+		{
+			String url1 = "http://www.local.bar:8080";
+			HTTPEpr epr = new HTTPEpr(url1);
+			
+			assertEquals(epr.getURL().toString(), url1);
+			
+			String url2 = "http://foo.com";
+			epr.setURL(new URL(url2));
+			
+			assertEquals(epr.getURL().toString(), url2);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/JDBCUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/JDBCUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/JDBCUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,91 @@
+/*
+ * 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.addressing.helpers.tests;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
+
+/**
+ * Unit tests for the EPR class.
+ * 
+ * @author Mark Little
+ */
+
+public class JDBCUnitTest extends TestCase
+{
+
+	public void testConstructor ()
+	{
+		try
+		{
+			new JDBCEpr("jdbc:arjuna:oracle:thin", "CREATE TABLE foo");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGet ()
+	{
+		try
+		{
+			JDBCEpr em = new JDBCEpr("jdbc:arjuna:oracle:thin", "CREATE TABLE foo");
+			
+			assertEquals(em.getURL(), "jdbc:arjuna:oracle:thin");
+			assertEquals(em.getSQL(), "CREATE TABLE foo");
+			
+			em.setURL("jdbc:arjuna:oracle:thin");
+			assertEquals(em.getURL(), "jdbc:arjuna:oracle:thin");
+			
+			em.setUserName("me");
+			assertEquals(em.getUserName(), "me");
+			
+			em.setPassword("foobar");
+			assertEquals(em.getPassword(), "foobar");
+			
+			try
+			{
+				em.setSQL("INVALID");
+				
+				fail();
+			}
+			catch (IllegalStateException ex)
+			{
+			}
+			catch (Exception ex)
+			{
+				fail(ex.toString());
+			}
+			
+			em.setDriver("cloudscape");
+			assertEquals(em.getDriver(), "cloudscape");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/JMSUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/JMSUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/helpers/tests/JMSUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,67 @@
+/*
+ * 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.addressing.helpers.tests;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+
+/**
+ * Unit tests for the EPR class.
+ * 
+ * @author Mark Little
+ */
+
+public class JMSUnitTest extends TestCase
+{
+
+	public void testConstructor ()
+	{
+		try
+		{
+			new JMSEpr(JMSEpr.ONE_ONE_PROTOCOL, JMSEpr.QUEUE_TYPE, "bar", "foobar",null,null,null,null);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGet ()
+	{
+		try
+		{
+			JMSEpr jms = new JMSEpr(JMSEpr.ONE_ONE_PROTOCOL, JMSEpr.QUEUE_TYPE, "bar", "foobar", null,null,null,null);
+			
+			assertEquals(jms.getVersion(), JMSEpr.ONE_ONE_PROTOCOL);
+			assertEquals(jms.getConnectionFactory(), "foobar");
+			assertEquals(jms.getDestinationType(), JMSEpr.QUEUE_TYPE);
+			assertEquals(jms.getDestinationName(), "bar");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/CallUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/CallUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/CallUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,195 @@
+/*
+ * 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.addressing.tests;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class CallUnitTest extends TestCase
+{
+	public void testConstructor ()
+	{
+		Call call = new Call();
+		
+		try
+		{
+			assertEquals((call.getTo() == null), true);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testEPRConstructor ()
+	{
+		try
+		{
+			EPR epr = new EPR(new URI("http://localhost"));
+			Call call = new Call(epr);
+			
+			assertEquals(call.getTo().equals(epr), true);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGetTo ()
+	{
+		Call call = new Call();
+		
+		try
+		{
+			EPR epr = new EPR(new URI("http://localhost"));
+			
+			call.setTo(epr);
+			
+			assertEquals(call.getTo().equals(epr), true);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGetFrom ()
+	{
+		Call call = new Call();
+		
+		try
+		{
+			EPR epr = new EPR(new URI("http://localhost"));
+			
+			call.setFrom(epr);
+			
+			assertEquals(call.getFrom().equals(epr), true);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGetReplyTo ()
+	{
+		Call call = new Call();
+		
+		try
+		{
+			EPR epr = new EPR(new URI("http://localhost"));
+			
+			call.setReplyTo(epr);
+			
+			assertEquals(call.getReplyTo().equals(epr), true);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGetFaultTo ()
+	{
+		Call call = new Call();
+		
+		try
+		{
+			EPR epr = new EPR(new URI("http://localhost"));
+			
+			call.setFaultTo(epr);
+			
+			assertEquals(call.getFaultTo().equals(epr), true);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGetRelatesTo ()
+	{
+		Call call = new Call();
+		
+		try
+		{
+			URI uri = new URI("urn:1234");
+			
+			call.setRelatesTo(uri);
+			
+			assertEquals(call.getRelatesTo().equals(uri), true);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGetAction ()
+	{
+		Call call = new Call();
+		
+		try
+		{
+			URI uri = new URI("urn:1234");
+			
+			call.setAction(uri);
+			
+			assertEquals(call.getAction().equals(uri), true);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGetMessageID ()
+	{
+		Call call = new Call();
+		
+		try
+		{
+			URI uri = new URI("urn:1234");
+			
+			call.setMessageID(uri);
+			
+			assertEquals(call.getMessageID().equals(uri), true);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/EPRUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/EPRUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/tests/EPRUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,168 @@
+/*
+ * 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.addressing.tests;
+
+import java.io.StringWriter;
+import java.net.URI;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.internal.soa.esb.addressing.helpers.PortReferenceHelper;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.jboss.soa.esb.addressing.XMLUtil;
+import org.jboss.soa.esb.addressing.eprs.EmailEpr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
+/**
+ * Unit tests for the EPR class.
+ * 
+ * @author Mark Little
+ */
+
+public class EPRUnitTest extends TestCase
+{
+
+	public void testConstructor ()
+	{
+		EPR epr = new EPR();
+		
+		System.err.println("Default EPR: "+epr);
+	}
+	
+	public void testPortReferenceConstructor ()
+	{
+		EPR epr = new EPR(new PortReference("http://localhost:8080"));
+		
+		assertEquals(epr.toString(), "EPR: PortReference < http://localhost:8080 >");
+	}
+	
+	public void testURIConstructor ()
+	{
+		try
+		{
+			EPR epr = new EPR(new URI("urn:foo/bar"));
+			
+			assertEquals(epr.toString(), "EPR: PortReference < urn:foo/bar >");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testGetAddr ()
+	{
+		try
+		{
+			EPR epr = new EPR(new URI("urn:foo/bar"));
+		
+			assertEquals(epr.getAddr().getAddress(), "urn:foo/bar");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetAddr ()
+	{
+		EPR epr = new EPR();
+		
+		epr.setAddr(new PortReference("http://localhost"));
+
+		try
+		{
+			assertEquals(epr.getAddr().getAddress(), "http://localhost");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testToFromXML ()
+	{
+		try
+		{
+			EmailEpr email = new EmailEpr(EmailEpr.SMTP_PROTOCOL, "foobar", "25", "me", "letmein");
+			
+			final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+			final DocumentBuilder builder = factory.newDocumentBuilder();
+			Document doc = builder.newDocument();
+			Element header = doc.createElement("header");
+			Element fromElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FROM_TAG);
+			
+			doc.appendChild(header);
+			header.appendChild(fromElement);
+			
+			PortReferenceHelper.toXML(header, doc, fromElement, email.getAddr(), false);
+
+			final StringWriter sWriter = new StringWriter() ;
+			final OutputFormat format = new OutputFormat() ;
+			format.setIndenting(true) ;
+
+			final XMLSerializer xmlS = new XMLSerializer(sWriter, format) ;
+
+			xmlS.asDOMSerializer() ;
+			xmlS.serialize(doc) ;
+
+			System.err.println("Exported XML: "+sWriter.toString());
+			
+			PortReference pr = PortReferenceHelper.fromXML(fromElement, false);			
+			
+			EPR basicEpr = new EPR(pr);
+			EmailEpr nEpr = new EmailEpr(basicEpr);
+
+			assertEquals(nEpr.getAddr().getAddress(), email.getAddr().getAddress());
+		}
+		catch (Exception ex)
+		{
+			fail();
+		}		
+	}
+	
+	public void testEquals ()
+	{
+		try
+		{
+			EPR epr1 = new EPR(new URI("http://localhost"));
+			EPR epr2 = new EPR(new URI("http://localhost"));
+			EPR epr3 = new EPR(new URI("http://localhost:8080"));
+			
+			assertEquals(epr1.equals(epr2), true);
+			assertEquals(epr1.equals(epr3), false);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/util/tests/EPRHelperUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/util/tests/EPRHelperUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/util/tests/EPRHelperUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,59 @@
+/*
+ * 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.addressing.util.tests;
+
+import junit.framework.TestCase;
+
+import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.EmailEpr;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class EPRHelperUnitTest extends TestCase
+{
+	
+	public void testToFromXMLString () throws MarshalException, UnmarshalException
+	{
+		EmailEpr email = new EmailEpr(EmailEpr.SMTP_PROTOCOL, "foobar", "25", "me", "letmein");
+		
+		String xmlString = EPRHelper.toXMLString(email);
+		
+		System.err.println("xmlString is: "+xmlString);
+		
+		EPR epr = EPRHelper.fromXMLString(xmlString);
+		
+		if (epr instanceof EmailEpr)
+		{
+		}
+		else
+		    fail();
+	}
+	
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/util/tests/EPRManagerUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/util/tests/EPRManagerUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/addressing/util/tests/EPRManagerUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,121 @@
+/*
+ * 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.addressing.util.tests;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.EmailEpr;
+import org.jboss.soa.esb.addressing.util.EPRManager;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class EPRManagerUnitTest extends TestCase
+{
+	public void testCreate ()
+	{
+		EPRManager manager1 = EPRManager.getInstance(null);
+		EPRManager manager2 = EPRManager.getInstance("");
+		EPRManager manager3 = EPRManager.getInstance("/tmp");
+		
+		assertEquals(manager1.equals(manager2), true);
+		assertEquals(manager1.equals(manager3), false);
+	}
+	
+	public void testInputOutput ()
+	{
+		EmailEpr email = new EmailEpr(EmailEpr.SMTP_PROTOCOL, "foobar", "25", "me", "letmein");
+		
+		String tmpDir = System.getProperty("java.io.tmpdir");
+		EPRManager manager = EPRManager.getInstance(tmpDir);
+
+		try
+		{
+			manager.saveEPR("MyEmail", email);
+
+			EmailEpr loaded = new EmailEpr(manager.loadEPR("MyEmail"));
+		
+			assertEquals(loaded.getHost().equals("foobar"), true);
+			assertEquals(loaded.getPassword().equals("letmein"), true);
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			fail(ex.toString());
+		}
+		finally
+		{
+			try
+			{
+				manager.removeEPR("MyEmail");
+			}
+			catch (Exception ex)
+			{
+			}
+		}
+	}
+	
+	public void testSpecificInputOutput ()
+	{
+		EmailEpr email = new EmailEpr(EmailEpr.SMTP_PROTOCOL, "foobar", "25", "me", "letmein");
+		
+		String tmpDir = System.getProperty("java.io.tmpdir");
+		EPRManager manager = EPRManager.getInstance(tmpDir);
+
+		try
+		{
+			manager.saveEPR("MyEmail", email);
+			
+			EPR epr = manager.loadEPR("MyEmail");
+			
+			if (epr instanceof EmailEpr)
+			{
+			    
+			}
+			else
+			    fail();
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			fail(ex.toString());
+		}
+		finally
+		{
+			try
+			{
+				manager.removeEPR("MyEmail");
+			}
+			catch (Exception ex)
+			{
+			}
+		}
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/ExampleMessageImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/ExampleMessageImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/ExampleMessageImpl.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,117 @@
+package org.jboss.soa.esb.message.format.tests;
+
+import java.net.URI;
+
+import org.jboss.soa.esb.message.Attachment;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Context;
+import org.jboss.soa.esb.message.Fault;
+import org.jboss.soa.esb.message.Header;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.Properties;
+
+/*
+ * 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
+ */
+
+/**
+ * Used to plug in new message formats dynamically. Each plugin is responsible for
+ * returning a message implementation that knows how to serialize its state in a
+ * specific manner, e.g., XML or ASN.1.
+ *  
+ * @author Mark Little
+ *
+ */
+
+public class ExampleMessageImpl implements Message
+{
+	
+	/**
+	 * @return get the header component of the message.
+	 */
+	
+	public Header getHeader ()
+	{
+		return null;
+	}
+
+	/**
+	 * @return get the context component of the message.
+	 */
+	
+	public Context getContext ()
+	{
+		return null;
+	}
+	
+	/**
+	 * @return get the body component of the message.
+	 */
+	
+	public Body getBody ()
+	{
+		return null;
+	}
+
+	/**
+	 * @return get any faults associated with the message. These should not
+	 * be application level faults, but comms level.
+	 */
+	
+	public Fault getFault ()
+	{
+		return null;
+	}
+	
+	/**
+	 * @return get any message attachments.
+	 */
+	
+	public Attachment getAttachment ()
+	{
+		return null;
+	}
+	/**
+	 * @return get any message properties 
+	 */	
+	public Properties getProperties() 
+	{
+		return null;
+	}
+	
+	/**
+	 * @return the type of this message.
+	 */
+	
+	public URI getType ()
+	{
+		try
+		{
+			return new URI(ExampleMessagePlugin.URN);
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			return null;
+		}
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/ExampleMessagePlugin.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/ExampleMessagePlugin.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/ExampleMessagePlugin.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,69 @@
+package org.jboss.soa.esb.message.format.tests;
+
+import java.net.URI;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessagePlugin;
+
+/*
+ * 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
+ */
+
+/**
+ * Used to plug in new message formats dynamically. Each plugin is responsible for
+ * returning a message implementation that knows how to serialize its state in a
+ * specific manner, e.g., XML or ASN.1.
+ *  
+ * @author Mark Little
+ *
+ */
+
+public class ExampleMessagePlugin implements MessagePlugin
+{
+	
+	public static final String URN = "foobar";
+	
+	/**
+	 * @return the message instance.
+	 */
+	
+	public Message getMessage ()
+	{
+		return new ExampleMessageImpl();
+	}
+	
+	/**
+	 * @return the unique identifier for this message plugin.
+	 */
+	
+	public URI getType ()
+	{
+		try
+		{
+			return new URI(URN);
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			return null;
+		}
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/MessageFactoryUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/MessageFactoryUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/format/tests/MessageFactoryUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,131 @@
+/*
+ * 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.format.tests;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessagePlugin;
+import org.jboss.soa.esb.message.format.MessageType;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class MessageFactoryUnitTest extends TestCase
+{
+	public void testDefaultMessage ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage();
+		
+		assertEquals((msg != null), true);
+	}
+	
+	public void testURIMessage ()
+	{
+		Message msg1 = MessageFactory.getInstance().getMessage(MessageType.DEFAULT_TYPE);
+		Message msg2 = MessageFactory.getInstance().getMessage();
+		
+		assertEquals(msg1.getType().equals(msg2.getType()), true);
+		
+		Message msg3 = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+		
+		assertEquals(msg1.getType().equals(msg3.getType()), false);
+	}
+	
+	public void testInvalidURIMessage ()
+	{
+		try
+		{
+			Message msg = MessageFactory.getInstance().getMessage(new URI("urn:foo"));
+			
+			assertEquals((msg == null), true);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testNullURIMessage ()
+	{
+		try
+		{
+			@SuppressWarnings("unused")
+			Message msg = MessageFactory.getInstance().getMessage(null);
+			
+			fail();
+		}
+		catch (IllegalArgumentException ex)
+		{
+			// success
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testNullURIConvertMessage ()
+	{
+		try
+		{
+			@SuppressWarnings("unused")
+			Message msg = MessageFactory.getInstance().getMessage(null, null);
+			
+			fail();
+		}
+		catch (IllegalArgumentException ex)
+		{
+			// success
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testPlugin ()
+	{
+		System.setProperty(MessagePlugin.MESSAGE_PLUGIN+"1", ExampleMessagePlugin.class.getName());
+		
+		MessageFactory.getInstance().reset();
+		
+		try
+		{
+			URI uri = new URI(ExampleMessagePlugin.URN);
+			Message msg = MessageFactory.getInstance().getMessage(uri);
+
+			assertEquals(msg.getType().equals(uri), true);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,207 @@
+/*
+ * 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.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.StringWriter;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
+import org.jboss.soa.esb.message.Attachment;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.w3c.dom.Document;
+
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class AttachmentUnitTest extends TestCase
+{
+
+	public void testSerializeAttachment()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+
+		Attachment at = msg.getAttachment();
+
+		assertEquals((msg != null), true);
+
+		at.addItem(new ExampleObject(0)); // un-named
+		at.addItemAt(0, new ExampleObject(0)); // un-named;
+
+		try
+		{
+			at.addItem(new Object());
+
+			fail();
+		}
+		catch (IllegalArgumentException ex)
+		{
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+
+		assertEquals(at.getUnnamedCount(), 2);
+
+		assertEquals(at.get("foo"), null);
+
+		at.put("foobar", new ExampleObject(1));
+
+		assertEquals(at.getNamedCount(), 1);
+
+		at.addItem(new ExampleObject(1));
+		at.addItem(new ExampleObject(2));
+
+		assertEquals((at.getNames() != null), true);
+
+		assertEquals((at.removeItemAt(0) != null), true);
+
+		at.replaceItemAt(0, new ExampleObject(2));
+
+		int count = at.getUnnamedCount();
+
+		try
+		{
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+
+			o.writeObject(msg);
+			o.close();
+
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+
+			assertEquals(nImpl.getAttachment().getUnnamedCount(), count);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+	public void testXMLAttachment()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertEquals((msg != null), true);
+
+		Attachment at = msg.getAttachment();
+
+		assertEquals((msg != null), true);
+
+		at.addItem(new ExampleObject(0)); // un-named
+		at.addItemAt(0, new ExampleObject(0)); // un-named;
+
+		try
+		{
+			at.addItem(new Object());
+
+			fail();
+		}
+		catch (IllegalArgumentException ex)
+		{
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+
+		assertEquals(at.getUnnamedCount(), 2);
+
+		assertEquals(at.get("foo"), null);
+
+		at.put("foobar", new ExampleObject(1));
+
+		assertEquals(at.getNamedCount(), 1);
+
+		at.addItem(new ExampleObject(1));
+		at.addItem(new ExampleObject(2));
+
+		assertEquals((at.getNames() != null), true);
+
+		assertEquals((at.removeItemAt(0) != null), true);
+
+		at.replaceItemAt(0, new ExampleObject(2));
+
+		int count = at.getUnnamedCount();
+
+		try
+		{
+			DocumentBuilderFactory factory = DocumentBuilderFactory
+					.newInstance();
+			DocumentBuilder builder = factory.newDocumentBuilder();
+			Document doc = builder.newDocument();
+			org.jboss.internal.soa.esb.message.format.xml.MessageImpl theImpl = (org.jboss.internal.soa.esb.message.format.xml.MessageImpl) msg;
+
+			doc = theImpl.toXML(doc);
+
+			StringWriter sWriter = new StringWriter();
+			OutputFormat format = new OutputFormat();
+			format.setIndenting(true);
+
+			XMLSerializer xmlS = new XMLSerializer(sWriter, format);
+
+			xmlS.asDOMSerializer();
+			xmlS.serialize(doc);
+
+			String documentAsString = sWriter.toString();
+
+			System.err.println("Message looks like: " + documentAsString);
+
+			org.jboss.internal.soa.esb.message.format.xml.MessageImpl nImpl = new org.jboss.internal.soa.esb.message.format.xml.MessageImpl();
+
+			nImpl.fromXML(doc);
+
+			assertEquals(nImpl.getAttachment().getUnnamedCount(), count);
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			fail(ex.toString());
+		}
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/BodyUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/BodyUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/BodyUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,227 @@
+/*
+ * 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.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.StringWriter;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.internal.soa.esb.message.format.xml.MessageImpl;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.w3c.dom.Document;
+
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class BodyUnitTest extends TestCase
+{
+
+	public void testXMLAddString ()
+	{
+		// get XML message
+
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertEquals((msg != null), true);
+
+		try
+		{
+			msg.getBody().add("foo", "bar");
+			
+			assertEquals(msg.getBody().get("foo"), "bar");
+			
+			DocumentBuilderFactory factory = DocumentBuilderFactory
+					.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			DocumentBuilder builder = factory.newDocumentBuilder();
+			Document doc = builder.newDocument();
+			MessageImpl theImpl = (MessageImpl) msg;
+
+			doc = theImpl.toXML(doc);
+
+			StringWriter sWriter = new StringWriter();
+			OutputFormat format = new OutputFormat();
+			format.setIndenting(true);
+
+			XMLSerializer xmlS = new XMLSerializer(sWriter, format);
+
+			xmlS.asDOMSerializer();
+			xmlS.serialize(doc);
+
+			String documentAsString = sWriter.toString();
+
+			MessageImpl nImpl = new MessageImpl();
+
+			System.err.println("Document is "+documentAsString);
+			
+			nImpl.fromXML(doc);
+			
+			assertEquals(nImpl.getBody().get("foo"), "bar");
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testXMLAddBoolean ()
+	{
+		// get XML message
+
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertEquals((msg != null), true);
+
+		try
+		{
+			msg.getBody().add("foo", new Boolean(true));
+			
+			assertEquals(msg.getBody().get("foo"), new Boolean(true));
+			
+			DocumentBuilderFactory factory = DocumentBuilderFactory
+					.newInstance();
+			factory.setNamespaceAware(true);
+			
+			DocumentBuilder builder = factory.newDocumentBuilder();
+			Document doc = builder.newDocument();
+			MessageImpl theImpl = (MessageImpl) msg;
+
+			doc = theImpl.toXML(doc);
+
+			StringWriter sWriter = new StringWriter();
+			OutputFormat format = new OutputFormat();
+			format.setIndenting(true);
+
+			XMLSerializer xmlS = new XMLSerializer(sWriter, format);
+
+			xmlS.asDOMSerializer();
+			xmlS.serialize(doc);
+
+			String documentAsString = sWriter.toString();
+
+			MessageImpl nImpl = new MessageImpl();
+
+			System.err.println("Document is "+documentAsString);
+			
+			nImpl.fromXML(doc);
+			
+			assertEquals(nImpl.getBody().get("foo"), new Boolean(true));
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSerializedAddString ()
+	{
+		// get XML message
+
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+
+		try
+		{
+			msg.getBody().add("foo", "bar");
+			
+			assertEquals(msg.getBody().get("foo"), "bar");
+			
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+			
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			org.jboss.internal.soa.esb.message.format.serialized.MessageImpl nImpl = (org.jboss.internal.soa.esb.message.format.serialized.MessageImpl) io.readObject();
+			
+			o.close();
+
+			assertEquals(nImpl.getBody().get("foo"), "bar");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSerializedAddBoolean ()
+	{
+		// get XML message
+
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+
+		try
+		{
+			msg.getBody().add("foo", new Boolean(true));
+			
+			assertEquals(msg.getBody().get("foo"), new Boolean(true));
+			
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+			
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			org.jboss.internal.soa.esb.message.format.serialized.MessageImpl nImpl = (org.jboss.internal.soa.esb.message.format.serialized.MessageImpl) io.readObject();
+			
+			assertEquals(nImpl.getBody().get("foo"), new Boolean(true));
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/ExampleObject.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/ExampleObject.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/ExampleObject.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,49 @@
+/*
+ * 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.tests;
+
+import java.io.Serializable;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class ExampleObject implements Serializable
+{
+	private static final long serialVersionUID = 0x0;
+
+	public ExampleObject (long val)
+	{
+		value = val;
+	}
+	
+	public long getValue ()
+	{
+		return value;
+	}
+	
+	private long value;
+	
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/FaultUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/FaultUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/FaultUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,143 @@
+/*
+ * 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.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.StringWriter;
+import java.net.URI;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.w3c.dom.Document;
+
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class FaultUnitTest extends TestCase
+{
+
+	public void testSerializeFault ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+
+		try
+		{
+			URI code = new URI("urn:code");
+		
+			msg.getFault().setCode(code);
+			msg.getFault().setReason("because");
+			
+			assertEquals(msg.getFault().getCode(), code);
+			assertEquals(msg.getFault().getReason(), "because");
+
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+
+			o.writeObject(msg);
+			o.close();
+
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+
+			assertEquals(nImpl.getFault().getReason(), "because");
+			
+			o.close();
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+	public void testXMLFault ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertEquals((msg != null), true);
+
+		try
+		{
+			URI code = new URI("urn:code");
+			
+			msg.getFault().setCode(code);
+			msg.getFault().setReason("because");
+			
+			assertEquals(msg.getFault().getCode(), code);
+			assertEquals(msg.getFault().getReason(), "because");
+		
+			DocumentBuilderFactory factory = DocumentBuilderFactory
+					.newInstance();
+			DocumentBuilder builder = factory.newDocumentBuilder();
+			Document doc = builder.newDocument();
+			org.jboss.internal.soa.esb.message.format.xml.MessageImpl theImpl = (org.jboss.internal.soa.esb.message.format.xml.MessageImpl) msg;
+
+			doc = theImpl.toXML(doc);
+
+			StringWriter sWriter = new StringWriter();
+			OutputFormat format = new OutputFormat();
+			format.setIndenting(true);
+
+			XMLSerializer xmlS = new XMLSerializer(sWriter, format);
+
+			xmlS.asDOMSerializer();
+			xmlS.serialize(doc);
+
+			String documentAsString = sWriter.toString();
+
+			System.err.println("Message looks like: " + documentAsString);
+			
+			org.jboss.internal.soa.esb.message.format.xml.MessageImpl nImpl = new org.jboss.internal.soa.esb.message.format.xml.MessageImpl();
+			
+			nImpl.fromXML(doc);
+
+			assertEquals(nImpl.getFault().getReason(), "because");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/MessageUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/MessageUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/MessageUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,76 @@
+/*
+ * 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.tests;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class MessageUnitTest extends TestCase
+{
+	
+	public void testDefaultMessageFields ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage();
+		
+		assertEquals((msg.getBody() != null), true);
+		assertEquals((msg.getHeader() != null), true);
+		assertEquals((msg.getContext() != null), true);
+		assertEquals((msg.getAttachment() != null), true);
+		assertEquals((msg.getFault() != null), true);
+		assertEquals((msg.getProperties() != null), true);
+	}
+	
+	public void testXMLMessageFields ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+		
+		assertEquals((msg.getBody() != null), true);
+		assertEquals((msg.getHeader() != null), true);
+		assertEquals((msg.getContext() != null), true);
+		assertEquals((msg.getAttachment() != null), true);
+		assertEquals((msg.getFault() != null), true);
+		assertEquals((msg.getProperties() != null), true);
+	}
+	
+	public void testSerializedMessageFields ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+		
+		assertEquals((msg.getBody() != null), true);
+		assertEquals((msg.getHeader() != null), true);
+		assertEquals((msg.getContext() != null), true);
+		assertEquals((msg.getAttachment() != null), true);
+		assertEquals((msg.getFault() != null), true);
+		assertEquals((msg.getProperties() != null), true);
+	}
+	
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,161 @@
+/*
+ * 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.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.w3c.dom.Document;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class PropertiesUnitTest extends TestCase
+{
+
+	public void testSerializeProperties()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+
+		msg.getProperties().setProperty("foo", "bar");
+
+		assertEquals(msg.getProperties().getProperty("foo"), "bar");
+		assertEquals((msg.getProperties().getProperty("foobar") == null), true);
+
+		assertEquals(msg.getProperties().getProperty("foobar", "barfoo"),
+				"barfoo");
+
+		try
+		{
+			msg.getProperties().setProperty("1234", new Object());
+			
+			fail();
+		}
+		catch (IllegalArgumentException ex)
+		{
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+		
+		msg.getProperties().getNames();
+		
+		try
+		{
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+
+			o.writeObject(msg);
+			o.close();
+
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+
+			assertEquals(nImpl.getProperties().getProperty("foo"), "bar");
+
+			o.close();
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+
+		assertEquals(msg.getProperties().remove("foo"), "bar");
+	}
+
+	public void testXMLProperties()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertEquals((msg != null), true);
+
+		msg.getProperties().setProperty("foo", "bar");
+
+		assertEquals(msg.getProperties().getProperty("foo"), "bar");
+		assertEquals((msg.getProperties().getProperty("foobar") == null), true);
+
+		assertEquals(msg.getProperties().getProperty("foobar", "barfoo"),
+				"barfoo");
+
+		try
+		{
+			msg.getProperties().setProperty("1234", new Object());
+			
+			fail();
+		}
+		catch (IllegalArgumentException ex)
+		{
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+		
+		msg.getProperties().getNames();
+		
+		try
+		{
+			DocumentBuilderFactory factory = DocumentBuilderFactory
+					.newInstance();
+			DocumentBuilder builder = factory.newDocumentBuilder();
+			Document doc = builder.newDocument();
+			org.jboss.internal.soa.esb.message.format.xml.MessageImpl theImpl = (org.jboss.internal.soa.esb.message.format.xml.MessageImpl) msg;
+
+			doc = theImpl.toXML(doc);
+
+			org.jboss.internal.soa.esb.message.format.xml.MessageImpl nImpl = new org.jboss.internal.soa.esb.message.format.xml.MessageImpl();
+			
+			nImpl.fromXML(doc);
+
+			assertEquals(nImpl.getProperties().getProperty("foo"), "bar");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+
+		assertEquals(msg.getProperties().remove("foo"), "bar");
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,667 @@
+/*
+ * 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.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.EmailEpr;
+import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
+import org.jboss.soa.esb.addressing.eprs.HTTPEpr;
+import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.addressing.eprs.SFTPEpr;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class SerializedMessageUnitTest extends TestCase
+{
+
+	public void testSerialize()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+
+		try
+		{
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+		
+	}
+
+	public void testDeserialize()
+	{
+		// get XML message
+
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+
+		try
+		{
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+			
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			@SuppressWarnings("unused")
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+			
+			o.close();
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testHeader ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+
+		Call call = new Call();
+
+		msg.getHeader().setCall(call);
+		
+		call = msg.getHeader().getCall();
+		
+		assertEquals((call != null), true);
+		
+		try
+		{
+			msg.getHeader().setCall(null);
+			
+			fail();
+		}
+		catch (IllegalArgumentException ex)
+		{
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testInvalidAdd ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+		
+		try
+		{
+			msg.getBody().add(null, null);
+			
+			fail();
+		}
+		catch (IllegalArgumentException ex)
+		{
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+	public void testAddBytes ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+		
+		String testString = "test";
+		
+		msg.getBody().setContents(testString.getBytes());
+		
+		try
+		{
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+			
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+			
+			o.close();
+			
+			String val = new String(nImpl.getBody().getContents());
+			
+			assertEquals(val, testString);
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testReplace ()
+	{
+		Message msg1 = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg1 != null), true);
+		
+		String foo = "foo";
+		
+		Message msg2 = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg2 != null), true);
+		
+		String bar = "bar";
+		
+		msg1.getBody().setContents(foo.getBytes());
+		msg2.getBody().setContents(bar.getBytes());
+		
+		msg1.getBody().replace(msg2.getBody());
+		
+		String foobar = new String(msg1.getBody().getContents());
+		
+		assertEquals(foobar.equals("bar"), true);
+	}
+	
+	public void testMerge ()
+	{
+		Message msg1 = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg1 != null), true);
+		
+		String foo = "foo";
+		
+		Message msg2 = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg2 != null), true);
+		
+		String bar = "bar";
+		
+		msg1.getBody().setContents(foo.getBytes());
+		msg2.getBody().setContents(bar.getBytes());
+		
+		msg1.getBody().merge(msg2.getBody());
+		
+		String foobar = new String(msg1.getBody().getContents());
+		
+		assertEquals(foobar, "foobar");
+	}
+	
+	public void testAddObjects ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+		
+		ExampleObject value = new ExampleObject(1234);
+		
+		msg.getBody().add("foo", value);
+		
+		try
+		{
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+			
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+			
+			o.close();
+			
+			ExampleObject foo = (ExampleObject) nImpl.getBody().get("foo");
+			
+			assertEquals((foo.getValue() == value.getValue()), true);
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testGetNames ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+		
+		ExampleObject value = new ExampleObject(1234);
+		
+		msg.getBody().add("foo", value);
+		msg.getBody().add("bar", value);
+		
+		String[] names = msg.getBody().getNames();
+		
+		assertNotNull(names);
+		
+		assertEquals(names.length, 2);
+		
+		/*
+		 * The array comes back ordered alphabetically.
+		 */
+		
+		assertEquals(names[0], "bar");
+		assertEquals(names[1], "foo");
+		
+		try
+		{
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+			
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+			
+			o.close();
+			
+			ExampleObject foo = (ExampleObject) nImpl.getBody().get("foo");
+			
+			assertEquals((foo.getValue() == value.getValue()), true);
+			
+			names = nImpl.getBody().getNames();
+			
+			assertNotNull(names);
+			
+			assertEquals(names.length, 2);
+			assertEquals(names[0], "foo");
+			assertEquals(names[1], "bar");
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testAddInvalidObject ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+
+		try
+		{
+			msg.getBody().add("foo", new Object());
+			
+			fail();
+		}
+		catch (IllegalArgumentException ex)
+		{
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testRemoveObjects ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JAVA_SERIALIZED);
+
+		assertEquals((msg != null), true);
+		
+		ExampleObject value = new ExampleObject(1234);
+		
+		msg.getBody().add("bar", value);
+		
+		msg.getBody().remove("bar");
+		
+		try
+		{
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+			
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+			
+			o.close();
+			
+			ExampleObject foo = (ExampleObject) nImpl.getBody().get("bar");
+			
+			assertEquals((foo == null), true);
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}	
+	}
+	
+	public void testJmsEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+		JMSEpr epr = new JMSEpr(JMSEpr.TOPIC_TYPE, "foo", "bar");
+		
+		msg.getHeader().getCall().setTo(epr);
+		
+		try
+		{
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+		
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+			
+			o.close();
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+
+			assertEquals(theEpr instanceof JMSEpr, true);
+			
+			assertEquals(((JMSEpr) theEpr).getConnectionFactory(), "bar");
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testHttpEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+
+		try
+		{
+			HTTPEpr epr = new HTTPEpr("http://www.foo.bar");
+			
+			msg.getHeader().getCall().setTo(epr);
+			
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+		
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+			
+			o.close();
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+
+			assertEquals(theEpr instanceof HTTPEpr, true);
+			
+			assertEquals(((HTTPEpr) theEpr).getURL().toString(), "http://www.foo.bar");
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testEmailEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+
+		try
+		{
+			EmailEpr epr = new EmailEpr(EmailEpr.SMTP_PROTOCOL, "foo.bar", "25", "me", "password");
+			
+			msg.getHeader().getCall().setTo(epr);
+			
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+		
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+			
+			o.close();
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+
+			assertEquals(theEpr instanceof EmailEpr, true);
+			
+			assertEquals(((EmailEpr) theEpr).getPassword(), "password");
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testFtpEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+
+		try
+		{
+			FTPEpr epr = new FTPEpr("http://www.foo.bar");
+			
+			epr.setPassive(true);
+			
+			msg.getHeader().getCall().setTo(epr);
+			
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+		
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+			
+			o.close();
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+
+			assertEquals(theEpr instanceof FTPEpr, true);
+			
+			assertEquals(((FTPEpr) theEpr).getPassive(), true);
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testJdbcEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+
+		try
+		{
+			JDBCEpr epr = new JDBCEpr("http://www.foo.bar", "SOME FAKE SQL");
+			
+			msg.getHeader().getCall().setTo(epr);
+			
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+		
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+			
+			o.close();
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+
+			assertEquals(theEpr instanceof JDBCEpr, true);
+			
+			assertEquals(((JDBCEpr) theEpr).getSQL(), "SOME FAKE SQL");
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testFileEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+
+		try
+		{
+			FileEpr epr = new FileEpr("file://tmp/bar.txt");
+			
+			epr.setErrorDelete(true);
+			
+			msg.getHeader().getCall().setTo(epr);
+			
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+		
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+			
+			o.close();
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+
+			assertEquals(theEpr instanceof FileEpr, true);
+			
+			assertEquals(((FileEpr) theEpr).getErrorDelete(), true);
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSFtpEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+
+		try
+		{
+			SFTPEpr epr = new SFTPEpr(new URL("http://www.foo.bar"), new URL("http://www.bar.foo"));
+
+			assertEquals(epr.getCertificateURL().toString(), "http://www.bar.foo");
+			
+			msg.getHeader().getCall().setTo(epr);
+			
+			ByteArrayOutputStream s = new ByteArrayOutputStream();
+			ObjectOutputStream o = new ObjectOutputStream(s);
+	
+			o.writeObject(msg);
+			o.close();
+		
+			ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+			ObjectInputStream io = new ObjectInputStream(is);
+
+			MessageImpl nImpl = (MessageImpl) io.readObject();
+			
+			o.close();
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+
+			assertEquals(theEpr instanceof SFTPEpr, true);
+			
+			assertEquals(((SFTPEpr) theEpr).getCertificateURL().toString(), "http://www.bar.foo");
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			fail(ex.toString());
+		}
+	}
+	
+}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java	2007-02-21 17:03:54 UTC (rev 9679)
@@ -0,0 +1,590 @@
+/*
+ * 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.tests;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.internal.soa.esb.message.format.xml.MessageImpl;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.EmailEpr;
+import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
+import org.jboss.soa.esb.addressing.eprs.HTTPEpr;
+import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.addressing.eprs.SFTPEpr;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
+/**
+ * Unit tests for the Class class.
+ * 
+ * @author Mark Little
+ */
+
+public class XMLMessageUnitTest extends TestCase
+{
+
+	public void testToXML()
+	{
+		// get XML message
+
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertNotNull("created message", msg);
+
+		try
+		{
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+
+			System.err.println("Message looks like: " + xmlRepresentation);
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+	public void testFromXML()
+	{
+		// get XML message
+
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertNotNull("created message", msg);
+
+		try
+		{
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+			@SuppressWarnings("unused")
+			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+	public void testHeader ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertNotNull("created message", msg);
+
+		Call call = new Call();
+
+		msg.getHeader().setCall(call);
+		
+		call = msg.getHeader().getCall();
+		
+		assertNotNull("message call", call);
+		
+		try
+		{
+			msg.getHeader().setCall(null);
+			
+			fail();
+		}
+		catch (IllegalArgumentException ex)
+		{
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+	public void testInvalidAdd ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertNotNull("created message", msg);
+		
+		try
+		{
+			msg.getBody().add(null, null);
+			
+			fail();
+		}
+		catch (IllegalArgumentException ex)
+		{
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testAddBytes ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertNotNull("created message", msg);
+		
+		String testString = "test";
+		
+		msg.getBody().setContents(testString.getBytes());
+		
+		try
+		{
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+			System.err.println("Document is "+xmlRepresentation);
+			
+			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+			
+			String val = new String(nImpl.getBody().getContents());
+			
+			assertEquals(val, testString);
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testReplace ()
+	{
+		Message msg1 = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertNotNull("created message", msg1);
+		
+		String foo = "foo";
+		
+		Message msg2 = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertNotNull("second created message", msg2);
+		
+		String bar = "bar";
+		
+		msg1.getBody().setContents(foo.getBytes());
+		msg2.getBody().setContents(bar.getBytes());
+		
+		msg1.getBody().replace(msg2.getBody());
+		
+		String foobar = new String(msg1.getBody().getContents());
+		
+		assertEquals(foobar, "bar");
+	}
+	
+	public void testMerge ()
+	{
+		Message msg1 = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertNotNull("created message", msg1);
+		
+		String foo = "foo";
+		
+		Message msg2 = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertNotNull("second created message", msg2);
+		
+		String bar = "bar";
+		
+		msg1.getBody().setContents(foo.getBytes());
+		msg2.getBody().setContents(bar.getBytes());
+		
+		msg1.getBody().merge(msg2.getBody());
+		
+		String foobar = new String(msg1.getBody().getContents());
+		
+		assertEquals(foobar, "foobar");
+	}
+	
+	public void testAddObjects ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertNotNull("created message", msg);
+		
+		ExampleObject value = new ExampleObject(1234);
+		
+		msg.getBody().add("foo", value);
+		
+		try
+		{
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+			System.err.println("Document is "+xmlRepresentation);
+			
+			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+			
+			ExampleObject foo = (ExampleObject) nImpl.getBody().get("foo");
+			
+			assertNotNull("deserialised example object", foo) ;
+			
+			assertEquals((foo.getValue() == value.getValue()), true);
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testGetNames ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertNotNull("created message", msg);
+		
+		ExampleObject value = new ExampleObject(1234);
+		
+		msg.getBody().add("foo", value);
+		msg.getBody().add("bar", value);
+		
+		String[] names = msg.getBody().getNames();
+		
+		assertNotNull(names);
+		
+		assertEquals(names.length, 2);
+		
+		/*
+		 * The array comes back ordered alphabetically.
+		 */
+		
+		assertEquals(names[0], "bar");
+		assertEquals(names[1], "foo");
+		
+		try
+		{
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+			System.err.println("Document is "+xmlRepresentation);
+			
+			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+			
+			ExampleObject foo = (ExampleObject) nImpl.getBody().get("foo");
+			
+			assertNotNull("deserialised example object", foo) ;
+			
+			assertEquals((foo.getValue() == value.getValue()), true);
+			
+			names = nImpl.getBody().getNames();
+			
+			assertNotNull(names);
+			
+			assertEquals(names.length, 2);	
+			
+			/*
+			 * The array comes back ordered alphabetically.
+			 */
+			
+			assertEquals(names[0], "bar");
+			assertEquals(names[1], "foo");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testRemoveObjects ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(
+				MessageType.JBOSS_XML);
+
+		assertNotNull("created message", msg);
+		
+		ExampleObject value = new ExampleObject(1234);
+		
+		msg.getBody().add("bar", value);
+		
+		msg.getBody().remove("bar");
+		
+		try
+		{
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+			System.err.println("Document is "+xmlRepresentation);
+			
+			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+			
+			ExampleObject foo = (ExampleObject) nImpl.getBody().get("bar");
+			
+			assertNull("deserialised example object", foo);
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}	
+	}
+	
+	public void testJmsEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+		JMSEpr epr = new JMSEpr(JMSEpr.TOPIC_TYPE, "foo", "bar");
+		
+		msg.getHeader().getCall().setTo(epr);
+		
+		try
+		{
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+			System.err.println("Document is "+xmlRepresentation);
+			
+			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+			
+			assertEquals(theEpr instanceof JMSEpr, true);
+			
+			assertEquals(((JMSEpr) theEpr).getConnectionFactory(), "bar");
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testHttpEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+		try
+		{
+			HTTPEpr epr = new HTTPEpr("http://www.foo.bar");
+			
+			msg.getHeader().getCall().setTo(epr);
+			
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+			System.err.println("Document is "+xmlRepresentation);
+			
+			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+			
+			assertEquals(theEpr instanceof HTTPEpr, true);
+			
+			assertEquals(((HTTPEpr) theEpr).getURL().toString(), "http://www.foo.bar");
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testEmailEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+		try
+		{
+			EmailEpr epr = new EmailEpr(EmailEpr.SMTP_PROTOCOL, "foo.bar", "25", "me", "password");
+			
+			msg.getHeader().getCall().setTo(epr);
+			
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+			System.err.println("Document is "+xmlRepresentation);
+			
+			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+			
+			assertEquals(theEpr instanceof EmailEpr, true);
+			
+			assertEquals(((EmailEpr) theEpr).getPassword(), "password");
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testFtpEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+		try
+		{
+			FTPEpr epr = new FTPEpr("http://www.foo.bar");
+			
+			epr.setPassive(true);
+			
+			msg.getHeader().getCall().setTo(epr);
+			
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+			System.err.println("Document is "+xmlRepresentation);
+			
+			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+			
+			assertEquals(theEpr instanceof FTPEpr, true);
+			
+			assertEquals(((FTPEpr) theEpr).getPassive(), true);
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testJdbcEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+		try
+		{
+			JDBCEpr epr = new JDBCEpr("http://www.foo.bar", "SOME FAKE SQL");
+			
+			msg.getHeader().getCall().setTo(epr);
+			
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+			System.err.println("Document is "+xmlRepresentation);
+			
+			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+			
+			assertEquals(theEpr instanceof JDBCEpr, true);
+			
+			assertEquals(((JDBCEpr) theEpr).getSQL(), "SOME FAKE SQL");
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testFileEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+		try
+		{
+			FileEpr epr = new FileEpr("file://tmp/bar.txt");
+			
+			epr.setErrorDelete(true);
+			
+			msg.getHeader().getCall().setTo(epr);
+			
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+			System.err.println("Document is "+xmlRepresentation);
+			
+			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+			
+			assertEquals(theEpr instanceof FileEpr, true);
+			
+			assertEquals(((FileEpr) theEpr).getErrorDelete(), true);
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSFtpEPRType ()
+	{
+		Message msg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+		try
+		{
+			SFTPEpr epr = new SFTPEpr(new URL("http://www.foo.bar"), new URL("http://www.bar.foo"));
+
+			assertEquals(epr.getCertificateURL().toString(), "http://www.bar.foo");
+			
+			msg.getHeader().getCall().setTo(epr);
+			
+			final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+			System.err.println("Document is "+xmlRepresentation);
+			
+			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+			
+			EPR theEpr = nImpl.getHeader().getCall().getTo();
+			
+			assertEquals(theEpr instanceof SFTPEpr, true);
+			
+			assertEquals(((SFTPEpr) theEpr).getCertificateURL().toString(), "http://www.bar.foo");
+		}
+		catch (Exception ex)
+		{			
+			fail(ex.toString());
+		}
+	}
+	
+	private String msgToXML(final MessageImpl msg)
+		throws Exception
+	{
+		final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance() ;
+		
+		factory.setNamespaceAware(true);
+		
+		final DocumentBuilder builder = factory.newDocumentBuilder() ;
+		Document doc = builder.newDocument() ;
+		
+		doc = msg.toXML(doc) ;
+		
+		final StringWriter sWriter = new StringWriter() ;
+		final OutputFormat format = new OutputFormat() ;
+		format.setIndenting(true) ;
+
+		final XMLSerializer xmlS = new XMLSerializer(sWriter, format) ;
+
+		xmlS.asDOMSerializer() ;
+		xmlS.serialize(doc) ;
+
+		return sWriter.toString() ;
+	}
+	
+	private MessageImpl msgFromXML(final String xmlRepresentation)
+		throws Exception
+	{
+		final StringReader stringReader = new StringReader(xmlRepresentation) ;
+		final InputSource inputSource = new InputSource(stringReader) ;
+		
+		final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance() ;
+		
+		factory.setNamespaceAware(true);
+		
+		final DocumentBuilder builder = factory.newDocumentBuilder() ;
+		final Document doc = builder.parse(inputSource) ;
+
+		final MessageImpl message = new MessageImpl() ;
+		message.fromXML(doc) ;
+		return message ;
+	}
+}




More information about the jboss-svn-commits mailing list