[jboss-svn-commits] JBL Code SVN: r6166 - in labs/jbossesb/workspace/rearchitecture: . product/core product/core/babel product/core/babel/src/org/jboss product/core/babel/src/org/jboss/internal product/core/babel/src/org/jboss/internal/soa product/core/babel/src/org/jboss/internal/soa/esb product/core/babel/src/org/jboss/soa/esb product/core/babel/src/org/jboss/soa/esb/addressing product/core/babel/src/org/jboss/soa/esb/exceptions product/core/babel/src/org/jboss/soa/esb/message

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Sep 12 06:56:35 EDT 2006


Author: mark.little at jboss.com
Date: 2006-09-12 06:56:29 -0400 (Tue, 12 Sep 2006)
New Revision: 6166

Added:
   labs/jbossesb/workspace/rearchitecture/WARNING.txt
   labs/jbossesb/workspace/rearchitecture/product/core/babel/
   labs/jbossesb/workspace/rearchitecture/product/core/babel/ant.bat
   labs/jbossesb/workspace/rearchitecture/product/core/babel/build.xml
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/internal/
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/internal/soa/
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/internal/soa/esb/
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/internal/soa/esb/PortReferenceHelper.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/Call.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/EPR.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/PortReference.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/XMLUtil.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/exceptions/
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/exceptions/BaseException.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Attachment.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Body.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Context.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Fault.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Header.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Message.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/tests/
Removed:
   labs/jbossesb/workspace/rearchitecture/product/core/babel/ant.bat
   labs/jbossesb/workspace/rearchitecture/product/core/babel/build.xml
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/
   labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/BaseException.java
   labs/jbossesb/workspace/rearchitecture/product/core/babel/tests/
   labs/jbossesb/workspace/rearchitecture/product/core/common/
Log:


Added: labs/jbossesb/workspace/rearchitecture/WARNING.txt
===================================================================
--- labs/jbossesb/workspace/rearchitecture/WARNING.txt	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/WARNING.txt	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,2 @@
+This branch IS NOT MEANT TO BUILD at present. It is being used for restructuring purposes only.
+

Copied: labs/jbossesb/workspace/rearchitecture/product/core/babel (from rev 6137, labs/jbossesb/workspace/rearchitecture/product/core/common)

Deleted: labs/jbossesb/workspace/rearchitecture/product/core/babel/ant.bat
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/ant.bat	2006-09-11 09:58:46 UTC (rev 6137)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/ant.bat	2006-09-12 10:56:29 UTC (rev 6166)
@@ -1,12 +0,0 @@
- at echo off
-set ANT_CMD_LINE_ARGS=%1
-if ""%1""=="""" goto doneStart
-shift
-:setupArgs
-if ""%1""=="""" goto doneStart
-set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1
-shift
-goto setupArgs
-:doneStart
-%ANT_HOME%\bin\ant %ANT_CMD_LINE_ARGS%
-

Copied: labs/jbossesb/workspace/rearchitecture/product/core/babel/ant.bat (from rev 6165, labs/jbossesb/workspace/rearchitecture/product/core/common/ant.bat)

Deleted: labs/jbossesb/workspace/rearchitecture/product/core/babel/build.xml
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/build.xml	2006-09-11 09:58:46 UTC (rev 6137)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/build.xml	2006-09-12 10:56:29 UTC (rev 6166)
@@ -1,88 +0,0 @@
-<?xml version="1.0"?>
-<project name="BuildJbossEsbCommon" default="org.jboss.esb.common.compile" basedir=".">
-
-	<property name="org.jboss.esb.common.jar.name" value="jbossesb-common"/>
-	<property name="org.jboss.esb.common.distrib.dir" value="${org.jboss.esb.internal.dest}/dist"/>
-	<property name="org.jboss.esb.common.classes.dir" value="${org.jboss.esb.internal.dest}/classes/common"/>
-    <property name="org.jboss.esb.common.src.dir" value="${basedir}/src"/>
-	<property name="org.jboss.esb.root.dir" value="../.."/>
-    <property environment="env"/>
-
-	<property name="org.jboss.esb.ext.lib.dir" value="${org.jboss.esb.root.dir}/lib/ext"/>
-	<property name="org.jboss.esb.ejb3.lib.dir" value="${org.jboss.esb.root.dir}/lib/ejb3"/>
-	<condition property="org.jboss.esb.ext.lib.dir" value="{org.jboss.esb.jboss.home}/client">
-		<equals arg1="${org.jboss.esb.frominstall}" arg2="yes"/>
-	</condition>
-	
-	<path id="org.jboss.esb.common.base.classpath">
-        <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="activation.jar jbossall-client.jar log4j.jar mail.jar"/>
-		<fileset dir="${org.jboss.esb.ejb3.lib.dir}" includes="*.jar,*.zip"/>
-	</path>
-
-    <target name="org.jboss.esb.common.init">
-        <tstamp>
-            <format property="TODAY" pattern="dd-MM-yy"/>
-        </tstamp>
-    </target>
-
-    <target name="org.jboss.esb.common.prepare" depends="org.jboss.esb.common.init">
-        <mkdir dir="${org.jboss.esb.common.classes.dir}"/>
-        <mkdir dir="${org.jboss.esb.common.distrib.dir}"/>
-    	<mkdir dir="${org.jboss.esb.common.distrib.dir}/lib"/>
-    </target>
-
-    <target name="clean" description="Remove classes directory">
-    	<delete dir="${org.jboss.esb.common.classes.dir}"/>
-    </target>
-
-	<target name="purge" depends="clean">
-	</target>
-
-
-    <target name="org.jboss.esb.common.compile">
-        <!-- Compile common -->
-        <antcall target="org.jboss.esb.common.internal.compile"/>
-        <!-- Compile common tests -->
-        <ant inheritAll="true" dir="tests" target="org.jboss.esb.common.tests.compile"/>
-    </target>
-
-
-    <target name="org.jboss.esb.common.internal.compile" depends="org.jboss.esb.common.prepare"
-        description="Compile all classes">
-
-        <javac
-            destdir="${org.jboss.esb.common.classes.dir}"
-            classpathref="org.jboss.esb.common.base.classpath"
-            debug="${org.jboss.esb.debug}"
-            optimize="${org.jboss.esb.optimize}"
-            >
-            <src path="${org.jboss.esb.common.src.dir}"/>
-        </javac>
-
-    </target>
-
-	<target name="recompile" depends="clean,org.jboss.esb.common.compile"
-        description="Clean and compile"/>
-
-    <target name="jar" depends="org.jboss.esb.common.compile" description="Assemble jar files">
-    	<delete file="${org.jboss.esb.common.distrib.dir}/lib/${org.jboss.esb.common.jar.name}.jar" />
-        <jar    destfile="${org.jboss.esb.common.distrib.dir}/lib/${org.jboss.esb.common.jar.name}.jar" 
-                basedir="${org.jboss.esb.common.classes.dir}" 
-                includes="**/*.class"
-		excludes="test/**"
-                />
-    </target>
-
-
-
-    <target name="org.jboss.esb.common.test" description="Run tests for this module">
-        <!-- Compile common tests -->
-        <ant dir="tests" target="org.jboss.esb.common.internal.test"/>
-    </target>
-
-
-
-
-    <target name="all" depends="recompile,jar" />
-
-</project>

Copied: labs/jbossesb/workspace/rearchitecture/product/core/babel/build.xml (from rev 6165, labs/jbossesb/workspace/rearchitecture/product/core/common/build.xml)

Copied: labs/jbossesb/workspace/rearchitecture/product/core/babel/src (from rev 6165, labs/jbossesb/workspace/rearchitecture/product/core/common/src)

Added: labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/internal/soa/esb/PortReferenceHelper.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/internal/soa/esb/PortReferenceHelper.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/internal/soa/esb/PortReferenceHelper.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,373 @@
+/*
+ * 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;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.HashMap;
+import java.util.Map;
+
+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;
+
+import org.jboss.soa.esbcore.addressing.PortReference;
+import org.jboss.soa.esbcore.addressing.XMLUtil;
+import org.jboss.soa.esbcore.addressing.PortReference.Extension;
+import org.jboss.soa.esbcore.exceptions.MarshalException;
+
+/*
+ * 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 MarshalException {
+		PortReference portReference = new PortReference();;
+		
+		if (toField)
+			portReference.setAddress(portReferenceElement.getTextContent());
+		
+		org.w3c.dom.NodeList elements = portReferenceElement.getChildNodes();
+
+		for (int i = 1; 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) {
+					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 p = new HashMap();
+						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 p = new HashMap();
+			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.toString();
+				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);
+		}
+	}
+}

Deleted: labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/BaseException.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/soa/esb/BaseException.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/BaseException.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -1,42 +0,0 @@
-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/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/Call.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/soa/esb/addressing/Call.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/Call.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,300 @@
+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 org.jboss.soa.esb.addressing.PortReference.Extension;
+import org.jboss.soa.internal.esbcore.addressing.PortReferenceHelper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * This class represents the endpoint reference for services.
+ */
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class Call
+{
+	public Call ()
+	{
+		_to = _from = _replyTo = _relatesTo = _faultTo = null;
+		_action = _messageID = null;
+	}
+	
+	public EPR (EPR epr)
+	{
+		_to = epr;
+		
+		_from = _replyTo = _relatesTo = _faultTo = null;
+		_action = _messageID = null;
+	}
+	
+	public void setTo (EPR epr)
+	{
+		_to = epr;
+	}
+	
+	public EPR getTo () throws URISyntaxException
+	{
+		return _to;
+	}
+	
+	public void setFrom (EPR from)
+	{
+		_from = from;
+	}
+	
+	public EPR getFrom () throws URISyntaxException
+	{
+		return _from;
+	}
+	
+	public void setReplyTo (EPR replyTo)
+	{
+		_replyTo = replyTo;
+	}
+	
+	public PortReference getReplyTo () throws URISyntaxException
+	{
+		return _replyTo;
+	}
+	
+	public void setFaultTo (PortReference uri)
+	{
+		_faultTo = uri;
+	}
+	
+	public EPR getFaultTo () throws URISyntaxException
+	{
+		return _faultTo;
+	}
+	
+	public void setRelatesTo (EPR uri)
+	{
+		_relatesTo = uri;
+	}
+	
+	public EPR getRelatesTo () throws URISyntaxException
+	{
+		return _relatesTo;
+	}
+	
+	public void setAction (URI uri)
+	{
+		_action = uri;
+	}
+
+	public URI getAction () throws URISyntaxException
+	{
+		return _action;
+	}
+	
+	public void setMessageID (URI uri)
+	{
+		_messageID = uri;
+	}
+	
+	public URI getMessageID () throws URISyntaxException
+	{
+		return _messageID;
+	}
+	
+	public void copy (EPR from)
+	{
+		EPR fromImpl = (EPR) 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;
+	}
+	
+
+	public Element toXML (Document doc, Element header)
+	{
+		try
+		{
+			Element toElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.TO_TAG);
+			PortReferenceHelper.toXML(header, doc, toElement, _to.getAddr(), true);
+			header.appendChild(toElement);
+			
+			Element fromElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FROM_TAG);
+			PortReferenceHelper.toXML(header, doc, fromElement, _from.getAddr(), false);
+			header.appendChild(fromElement);
+			
+			Element replyToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.REPLY_TO_TAG);
+			PortReferenceHelper.toXML(header, doc, replyToElement, _replyTo.getAddr(), false);
+			header.appendChild(replyToElement);
+			
+			Element relatesToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.RELATES_TO_TAG);
+			PortReferenceHelper.toXML(header, doc, relatesToElement, _relatesTo.getAddr(), false);
+			header.appendChild(relatesToElement);
+			
+			Element faultToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FAULT_TO_TAG);
+			PortReferenceHelper.toXML(header, doc, faultToElement, _faultTo.getAddr(), false);
+			header.appendChild(faultToElement);
+			
+			Element actionElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.ACTION_TAG);
+			actionElement.setNodeValue(_action.toString());
+			header.appendChild(actionElement);
+			
+			Element messageIDElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.MESSAGE_IDENTIFIER_TAG);
+			messageIDElement.setNodeValue(_messageID.toString());
+			header.appendChild(messageIDElement);
+			
+			return header;
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			
+			return null;
+		}
+	}
+	
+	public void fromXML (Element header)
+	{
+		try
+		{
+			NodeList nl = header.getChildNodes();
+			
+			for (int i = 0; i < nl.getLength(); i++)
+			{
+				Node n = nl.item(i);
+				
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.TO_TAG))
+				{
+					try
+					{
+						_to = new EPR(PortReferenceHelper.fromXML((Element) n, true));
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+				
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.FROM_TAG))
+				{
+					try
+					{
+						_from = new EPR(PortReferenceHelper.fromXML((Element) n, false));
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+				
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.REPLY_TO_TAG))
+				{
+					try
+					{
+						_replyTo = new EPR(PortReferenceHelper.fromXML((Element) n, false));
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.RELATES_TO_TAG))
+				{
+					try
+					{
+						_relatesTo = new EPR(PortReferenceHelper.fromXML((Element) n, false));
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.FAULT_TO_TAG))
+				{
+					try
+					{
+						_faultTo = new EPR(PortReferenceHelper.fromXML((Element) n, false));
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.ACTION_TAG))
+				{			
+					try
+					{
+						_action = new URI(n.getNodeValue());
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+				
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.MESSAGE_IDENTIFIER_TAG))
+				{
+					try
+					{
+						_messageID = new URI(n.getNodeValue());
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+			}
+		}
+		catch (Exception ex)
+		{
+			// TODO error checking!!
+			
+			ex.printStackTrace();
+		}
+	}
+	
+	private EPR _to;
+	private EPR _from;
+	private EPR _faultTo;
+	private EPR _replyTo;
+	private EPR _relatesTo;
+	private URI _action;
+	private URI _messageID;
+	
+} 
\ No newline at end of file

Added: labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/EPR.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/soa/esb/addressing/EPR.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/EPR.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,78 @@
+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 org.jboss.soa.esb.addressing.PortReference.Extension;
+import org.jboss.soa.internal.esbcore.addressing.PortReferenceHelper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * This class represents the endpoint reference for services.
+ */
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class EPR
+{
+	public EPR ()
+	{
+		_to = new PortReference();
+	}
+	
+	public EPR (URI uri)
+	{
+		_addr = new PortReference(uri.toString());
+	}
+	
+	public void setAddr (PortReference uri)
+	{
+		_addr = uri;
+	}
+	
+	public PortReference getAddr () throws URISyntaxException
+	{
+		return _addr;
+	}
+
+	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;
+	}
+
+	private PortReference _addr;
+
+} 
\ No newline at end of file

Added: labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/PortReference.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/soa/esb/addressing/PortReference.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/PortReference.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,331 @@
+/*
+ * 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.Iterator;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.HashMap;
+
+
+/**
+ * An implementation of a WS-Addressing EPR. It needs completely rewriting after
+ * the interoperability workshop as it is not extensible and not guaranteed to
+ * work in the general case. 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.WSARJADDR_PREFIX,
+				XMLUtil.WSARJADDR_NAMESPACE_URI, value,
+				Extension.REFERENCE_PROPERTIES);
+	}
+
+	public void addExtension(String tag, String value) {
+		addExtension(tag, XMLUtil.WSARJADDR_PREFIX,
+				XMLUtil.WSARJADDR_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;
+		}
+
+		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();
+
+			_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 _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 _extensions = new LinkedList();
+	private Extension _portType = null;
+	private Extension _serviceName = null;
+	private List _policies = null;
+
+}

Added: labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/XMLUtil.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/soa/esb/addressing/XMLUtil.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/addressing/XMLUtil.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,53 @@
+/*
+ * 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";
+    
+    // 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/rearchitecture/product/core/babel/src/org/jboss/soa/esb/exceptions/BaseException.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/soa/esb/exceptions/BaseException.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/exceptions/BaseException.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,42 @@
+package jboss.soa.esb.exceptions;
+
+/**
+ * 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/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Attachment.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/soa/esb/message/Attachment.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Attachment.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,50 @@
+package org.jboss.soa.esb.message;
+
+import org.jboss.soa.esb.addressing.EPR;
+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
+ */
+
+/**
+ * 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 Attachment
+{
+	public Element toXML (Document doc, Element envelope)
+	{
+		Element attachmentElement = doc.createElement("attachment");
+		
+		envelope.appendChild(attachmentElement);
+		
+		return attachmentElement;
+	}
+	
+	public void fromXML (Element envelope)
+	{
+	}
+	
+}

Added: labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Body.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/soa/esb/message/Body.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Body.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,117 @@
+package org.jboss.soa.esb.message;
+
+import java.security.InvalidParameterException;
+
+import org.jboss.soa.esbcore.addressing.EPR;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+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
+ */
+
+/*
+ * Placeholder class. Just enough to do the initial POC.
+ */
+
+public class Body
+{
+	public Body ()
+	{
+		_content = null;
+	}
+	
+	public Element toXML (Document doc, Element envelope)
+	{
+		Element bodyElement = doc.createElement("body");
+		
+		envelope.appendChild(bodyElement);
+		
+		bodyElement.appendChild(doc.createCDATASection(new String(_content)));
+		
+		return bodyElement;
+	}
+	
+	public void fromXML (Element envelope)
+	{
+		NodeList nl = envelope.getChildNodes();
+		
+		for (int i = 0; i < nl.getLength(); i++)
+		{
+			if (nl.item(i).getNodeName().equals("body"))
+			{
+				CDATASection cdata = (CDATASection) nl.item(i).getFirstChild();
+		
+				_content = cdata.getWholeText().getBytes();
+				
+				break;
+			}
+		}
+	}
+	
+	public void setContents (byte[] content)
+	{
+		_content = content;
+	}
+
+	public byte[] getContents ()
+	{
+		return _content;
+	}
+	
+	public void replace (Body b)
+	{
+		if (b == null)
+			throw new InvalidParameterException();
+		
+		setContents(b.getContents());
+	}
+	
+	public void merge (Body b)
+	{
+		if (b == null)
+			throw new InvalidParameterException();
+		
+		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];
+				
+				for (int i = 0; i < _content.length; i++)
+					buffer[i] = _content[i];
+				
+				for (int j = 0; j < toAdd.length; j++)
+					buffer[_content.length+j] = toAdd[j];
+			}
+		}
+	}
+	
+	private byte[] _content;
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Context.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/soa/esb/message/Context.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Context.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,42 @@
+package org.jboss.soa.esb.message;
+
+import org.jboss.soa.esb.addressing.EPR;
+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 Context
+{
+	public Element toXML (Document doc, Element envelope)
+	{
+		Element contextElement = doc.createElement("context");
+		
+		envelope.appendChild(contextElement);
+		
+		return contextElement;
+	}
+	
+	public void fromXML (Element envelope)
+	{
+	}
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Fault.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/soa/esb/message/Fault.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Fault.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,43 @@
+package org.jboss.soa.esb.message;
+
+import org.jboss.soa.esb.addressing.EPR;
+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 Fault
+{
+	public Element toXML (Document doc, Element envelope)
+	{
+		Element faultElement = doc.createElement("fault");
+		
+		envelope.appendChild(faultElement);
+		
+		return faultElement;
+	}
+	
+	public void fromXML (Element envelope)
+	{
+	}
+	
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Header.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/soa/esb/message/Header.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Header.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,89 @@
+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.EPR;
+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 Header
+{
+	public Header ()
+	{
+		_epr = null;
+	}
+	
+	// TODO add other setters/getters for artibitrary attributes
+	
+	public EPR getEPR ()
+	{
+		return _epr;
+	}
+	
+	public void setEPR (EPR addr)
+	{
+		_epr = addr;
+	}
+	
+	public Element toXML (Document doc, Element envelope)
+	{
+		// TODO remove MAGIC strings!!
+		
+		Element headerElement = doc.createElement("header");
+		
+		envelope.appendChild(headerElement);
+		
+		return _epr.toXML(doc, headerElement);
+	}
+	
+	public void fromXML (Element envelope)
+	{
+		_epr = new EPR();
+		
+		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"))
+			{
+				headerElement = (Element) n;
+				break;
+			}
+		}
+		
+		// TODO error handling!!
+		
+		if (headerElement != null)
+			_epr.fromXML(headerElement);
+	}
+	
+	private EPR _epr;
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Message.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/core/common/src/org/jboss/soa/esb/message/Message.java	2006-09-11 23:44:47 UTC (rev 6165)
+++ labs/jbossesb/workspace/rearchitecture/product/core/babel/src/org/jboss/soa/esb/message/Message.java	2006-09-12 10:56:29 UTC (rev 6166)
@@ -0,0 +1,174 @@
+package org.jboss.soa.esb.message;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSSerializer;
+
+import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
+
+/*
+ * 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 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 Message
+{
+	/**
+	 * @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;
+	}
+	
+	/*
+	 * Should be to/from Normalized, where XML is just one of the possible
+	 * implementations.
+	 */
+	
+	// to/from XML here, rather than on individual elements
+	
+	public Document toXML (Document doc)
+	{
+		try
+		{		
+			// TODO remove magic strings!
+			
+			Element envelope = doc.createElement("envelope");
+
+			doc.appendChild(envelope);
+			
+			_theHeader.toXML(doc, envelope);
+			_theContext.toXML(doc, envelope);
+			_theBody.toXML(doc, envelope);
+			_theFault.toXML(doc, envelope);
+			_theAttachment.toXML(doc, envelope);
+			
+			return doc;
+		}
+		catch (Exception ex)
+		{
+			// TODO error handling
+			
+			ex.printStackTrace();
+			
+			return null;
+		}
+	}
+	
+	public void fromXML (Document doc)
+	{
+		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"))
+				{
+					envelope = (Element) n;
+					break;
+				}
+			}
+
+			_theHeader.fromXML(envelope);
+			_theContext.fromXML(envelope);
+			_theBody.fromXML(envelope);
+			_theFault.fromXML(envelope);
+			_theAttachment.fromXML(envelope);			
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+	}
+	
+	private Header _theHeader = new Header();
+	private Context _theContext = new Context();
+	private Body _theBody = new Body();
+	private Fault _theFault = new Fault();
+	private Attachment _theAttachment = new Attachment();
+	
+}

Copied: labs/jbossesb/workspace/rearchitecture/product/core/babel/tests (from rev 6165, labs/jbossesb/workspace/rearchitecture/product/core/common/tests)




More information about the jboss-svn-commits mailing list