[jboss-svn-commits] JBL Code SVN: r7638 - in labs/jbossesb/workspace/b_georges/product/core: listeners/src/org/jboss/soa/esb/actions listeners/src/org/jboss/soa/esb/listeners/message listeners/src/org/jboss/soa/esb/listeners/old rosetta/src/org/jboss/internal/soa/esb/addressing rosetta/src/org/jboss/internal/soa/esb/addressing/helpers rosetta/src/org/jboss/internal/soa/esb/couriers rosetta/src/org/jboss/soa/esb/addressing/eprs rosetta/src/org/jboss/soa/esb/couriers services/src/org/jboss/internal/soa/esb/persistence/format/db services/src/org/jboss/internal/soa/esb/services services/src/org/jboss/internal/soa/esb/services/routing services/src/org/jboss/internal/soa/esb/services/routing/cbr services/src/org/jboss/soa/esb/services/persistence services/src/org/jboss/soa/esb/services/routing/cbr services/tests/src/org/jboss services/tests/src/org/jboss/internal services/tests/src/org/jboss/internal/soa services/tests/src/org/jboss/internal/soa/esb services/tests/src/org/jboss/internal/soa! /esb/services services/tests/src/org/jboss/internal/soa/esb/services/registry services/tests/src/org/jboss/internal/soa/esb/services/routing services/tests/src/org/jboss/internal/soa/esb/services/routing/cbr services/tests/src/org/jboss/soa/esb/services services/tests/src/org/jboss/soa/esb/services/routing services/tests/src/org/jboss/soa/esb/services/routing/cbr

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Nov 16 06:01:01 EST 2006


Author: b_georges
Date: 2006-11-16 06:00:17 -0500 (Thu, 16 Nov 2006)
New Revision: 7638

Added:
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/PortReferenceHelper.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverOnlyCourier.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpOnlyCourier.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/EmailEpr.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/HTTPEpr.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/JDBCEpr.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierException.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierTimeoutException.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java
   labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/TwoWayCourier.java
   labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManager.java
   labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManagerDBCP.java
   labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java
   labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStorePlugin.java
   labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/services/routing/
   labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/
   labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/DslHelper.java
   labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouter.java
   labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/soa/esb/services/persistence/db/
   labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRouter.java
   labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRouterFactory.java
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/services/
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/services/registry/
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryUnitTest.java
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/services/routing/
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/services/routing/cbr/
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/soa/esb/services/routing/
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/soa/esb/services/routing/cbr/
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRoutingUnitTest.java
   labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/soa/esb/services/util/
Modified:
   labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/actions/CbrProxyAction.java
   labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/message/HttpListener.java
   labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/old/DirectoryPoller.java
   labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/old/RemoteDirectoryPoller.java
Log:


Modified: labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/actions/CbrProxyAction.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/actions/CbrProxyAction.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/actions/CbrProxyAction.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -36,6 +36,7 @@
 import org.jboss.soa.esb.couriers.CourierFactory;
 import org.jboss.soa.esb.couriers.CourierTimeoutException;
 import org.jboss.soa.esb.couriers.CourierUtil;
+import org.jboss.soa.esb.couriers.TwoWayCourier;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.listeners.ListenerTagNames;
 import org.jboss.soa.esb.message.Message;
@@ -122,7 +123,7 @@
 				try {
 					//Just use the first EPR in the list.
 					EPR epr = eprIterator.next();
-					Courier courier = CourierFactory.getCourier(epr);
+					TwoWayCourier courier = CourierFactory.getCourier(epr,null);
 					EPR replyEpr =  getReplyToEpr(epr);
 					if (message.getHeader().getCall()==null) {
 						Call call = new Call();

Modified: labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/message/HttpListener.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/message/HttpListener.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/message/HttpListener.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -121,7 +121,9 @@
 		// Start the action processing pipeline
 		ActionProcessingPipeline pipelineRunner = new ActionProcessingPipeline(
 						(Message)payload, this._config);
-		this.pipelineExecutorPool.submit(pipelineRunner);
+		//this.pipelineExecutorPool.submit(pipelineRunner);
+		//The above does not invoke the process action, using the following instead.
+		new Thread(pipelineRunner).start();
 		} else {
 			this.logger.error("Unsupported HttpListener message type: " + payload.getClass().getName());
 		}

Modified: labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/old/DirectoryPoller.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/old/DirectoryPoller.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/old/DirectoryPoller.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -32,11 +32,19 @@
 import org.jboss.soa.esb.actions.ActionDefinitionFactory;
 import org.jboss.soa.esb.actions.ActionProcessor;
 import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
 import org.jboss.soa.esb.util.Util;
 
 public class DirectoryPoller extends AbstractPoller
 {
+  public static final String FILE_INPUT_DIR 	= "inputDirURI";
+  public static final String FILE_INPUT_SFX 	= "inputSuffix";
+  public static final String FILE_WORK_SFX 		= "workSuffix";
+  public static final String FILE_ERROR_DIR   	= "errorDirURI";
+  public static final String FILE_ERROR_SFX   	= "errorSuffix";
+  public static final String FILE_POST_DIR  	= "postDirURI";
+  public static final String FILE_POST_SFX  	= "postSuffix";
+  public static final String FILE_POST_DEL  	= "postDelete";
+
   public DirectoryPoller(GpListener p_oDad, ConfigTree p_oParms, ActionDefinitionFactory actionDefinitionFactory) throws Exception
   {
 	super(p_oDad, p_oParms, actionDefinitionFactory);
@@ -89,49 +97,49 @@
 	private void checkMyParms() throws Exception
     { 
 	//  INPUT directory and suffix  (used for FileFilter)
-	  String sInpDir = GpListener.obtainAtt(listenerConfig,ListenerTagNames.FILE_INPUT_DIR_TAG,null);
+	  String sInpDir = GpListener.obtainAtt(listenerConfig,FILE_INPUT_DIR,null);
       m_oInpDir = getFile(sInpDir);
       seeIfOkToWorkOnDir(m_oInpDir);
 
-      m_sInpSfx  = GpListener.obtainAtt(listenerConfig,ListenerTagNames.FILE_INPUT_SFX_TAG,null);
+      m_sInpSfx  = GpListener.obtainAtt(listenerConfig,FILE_INPUT_SFX,null);
       m_sInpSfx  = m_sInpSfx.trim();
       if (m_sInpSfx.length()<1)
-    	  throw new Exception ("Invalid "+ListenerTagNames.FILE_INPUT_SFX_TAG+" attribute");
+    	  throw new Exception ("Invalid "+FILE_INPUT_SFX+" attribute");
 	  m_oFFilt = new FileEndsWith(m_sInpSfx);
 
 	//  WORK suffix (will rename in input directory)
-      m_sWrkSfx	= GpListener.obtainAtt(listenerConfig,ListenerTagNames.FILE_WORK_SFX_TAG,".esbWork").trim();
+      m_sWrkSfx	= GpListener.obtainAtt(listenerConfig,FILE_WORK_SFX,".esbWork").trim();
       if (m_sWrkSfx.length()<1)
-    	  throw new Exception ("Invalid "+ListenerTagNames.FILE_WORK_SFX_TAG+" attribute");
+    	  throw new Exception ("Invalid "+FILE_WORK_SFX+" attribute");
       if (m_sInpSfx.equals(m_sWrkSfx))
     	  throw new Exception("Work suffix must differ from input suffix <"+m_sWrkSfx+">");
 
     //    ERROR directory and suffix (defaults to input dir and ".esbError" suffix)
-      String sErrDir = GpListener.obtainAtt(listenerConfig,ListenerTagNames.FILE_ERROR_DIR_TAG,sInpDir);
+      String sErrDir = GpListener.obtainAtt(listenerConfig,FILE_ERROR_DIR,sInpDir);
       m_oErrorDir = getFile(sErrDir);
       seeIfOkToWorkOnDir(m_oErrorDir);
 
-      m_sErrSfx  = GpListener.obtainAtt(listenerConfig,ListenerTagNames.FILE_ERROR_SFX_TAG,".esbError").trim();
+      m_sErrSfx  = GpListener.obtainAtt(listenerConfig,FILE_ERROR_SFX,".esbError").trim();
       if (m_sErrSfx.length()<1)
-    	  throw new Exception ("Invalid "+ListenerTagNames.FILE_ERROR_SFX_TAG+" attribute");
+    	  throw new Exception ("Invalid "+FILE_ERROR_SFX+" attribute");
       if (m_oErrorDir.equals(m_oInpDir) && m_sInpSfx.equals(m_sErrSfx))
     	  throw new Exception("Error suffix must differ from input suffix <"+m_sErrSfx+">");
 
 
    //    Do users wish to delete files that were processed OK ?
-      String sPostDel = GpListener.obtainAtt(listenerConfig,ListenerTagNames.FILE_POST_DEL_TAG,"false").trim();
+      String sPostDel = GpListener.obtainAtt(listenerConfig,FILE_POST_DEL,"false").trim();
       m_bPostDel = Boolean.parseBoolean(sPostDel);
       if (m_bPostDel)
     	  return;
 
     //    POST (done) directory and suffix (defaults to input dir and ".esbDone" suffix)
-      String sPostDir = GpListener.obtainAtt(listenerConfig,ListenerTagNames.FILE_POST_DIR_TAG,sInpDir);
+      String sPostDir = GpListener.obtainAtt(listenerConfig,FILE_POST_DIR,sInpDir);
       m_oPostDir = getFile(sPostDir);
       seeIfOkToWorkOnDir(m_oPostDir);
-      m_sPostSfx  = GpListener.obtainAtt(listenerConfig,ListenerTagNames.FILE_POST_SFX_TAG,".esbDone").trim();
+      m_sPostSfx  = GpListener.obtainAtt(listenerConfig,FILE_POST_SFX,".esbDone").trim();
       if (m_oPostDir.equals(m_oInpDir))
       {	if (m_sPostSfx.length()<1)
-    	  throw new Exception ("Invalid "+ListenerTagNames.FILE_POST_SFX_TAG+" attribute");
+    	  throw new Exception ("Invalid "+FILE_POST_SFX+" attribute");
       	if (m_sPostSfx.equals(m_sInpSfx))
     	  throw new Exception("Post process suffix must differ from input suffix <"+m_sPostSfx+">");
       }

Modified: labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/old/RemoteDirectoryPoller.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/old/RemoteDirectoryPoller.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/old/RemoteDirectoryPoller.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -32,12 +32,20 @@
 import org.jboss.soa.esb.actions.ActionProcessor;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.helpers.KeyValuePair;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
 import org.jboss.soa.esb.util.FtpClientUtil;
 import org.jboss.soa.esb.util.Util;
 
 public class RemoteDirectoryPoller extends AbstractPoller
 {
+  public static final String FILE_INPUT_DIR 	= "inputDir";
+  public static final String FILE_INPUT_SFX 	= "inputSuffix";
+  public static final String FILE_WORK_SFX 		= "workSuffix";
+  public static final String FILE_ERROR_DIR   	= "errorDir";
+  public static final String FILE_ERROR_SFX   	= "errorSuffix";
+  public static final String FILE_POST_DIR  	= "postDir";
+  public static final String FILE_POST_SFX  	= "postSuffix";
+  public static final String FILE_POST_DEL  	= "postDelete";
+  
   private ConfigTree _params;
   private Logger	_logger = Logger.getLogger(this.getClass());
   FtpClientUtil		_ftpClient;
@@ -123,45 +131,45 @@
 	protected void checkMyParms() throws Exception
     { 
 	//  INPUT directory and suffix  (used for FileFilter)
-	  String sInpDir = GpListener.obtainAtt(_params,ListenerTagNames.FILE_INPUT_DIR_TAG,null);
+	  String sInpDir = GpListener.obtainAtt(_params,FILE_INPUT_DIR,null);
       m_oInpDir = new File(sInpDir);
 
-      m_sInpSfx  = GpListener.obtainAtt(_params,ListenerTagNames.FILE_INPUT_SFX_TAG,null);
+      m_sInpSfx  = GpListener.obtainAtt(_params,FILE_INPUT_SFX,null);
       m_sInpSfx  = m_sInpSfx.trim();
       if (m_sInpSfx.length()<1)
-    	  throw new Exception ("Invalid "+ListenerTagNames.FILE_INPUT_SFX_TAG+" attribute");
+    	  throw new Exception ("Invalid "+FILE_INPUT_SFX+" attribute");
 
 	//  WORK suffix (will rename in input directory)
-      m_sWrkSfx	= GpListener.obtainAtt(_params,ListenerTagNames.FILE_WORK_SFX_TAG,".esbWork").trim();
+      m_sWrkSfx	= GpListener.obtainAtt(_params,FILE_WORK_SFX,".esbWork").trim();
       if (m_sWrkSfx.length()<1)
-    	  throw new Exception ("Invalid "+ListenerTagNames.FILE_WORK_SFX_TAG+" attribute");
+    	  throw new Exception ("Invalid "+FILE_WORK_SFX+" attribute");
       if (m_sInpSfx.equals(m_sWrkSfx))
     	  throw new Exception("Work suffix must differ from input suffix <"+m_sWrkSfx+">");
 
     //    ERROR directory and suffix (defaults to input dir and ".esbError" suffix)
-      String sErrDir = GpListener.obtainAtt(_params,ListenerTagNames.FILE_ERROR_DIR_TAG,sInpDir);
+      String sErrDir = GpListener.obtainAtt(_params,FILE_ERROR_DIR,sInpDir);
       m_oErrorDir = new File(sErrDir);
 
-      m_sErrSfx  = GpListener.obtainAtt(_params,ListenerTagNames.FILE_ERROR_SFX_TAG,".esbError").trim();
+      m_sErrSfx  = GpListener.obtainAtt(_params,FILE_ERROR_SFX,".esbError").trim();
       if (m_sErrSfx.length()<1)
-    	  throw new Exception ("Invalid "+ListenerTagNames.FILE_ERROR_SFX_TAG+" attribute");
+    	  throw new Exception ("Invalid "+FILE_ERROR_SFX+" attribute");
       if (m_oErrorDir.equals(m_oInpDir) && m_sInpSfx.equals(m_sErrSfx))
     	  throw new Exception("Error suffix must differ from input suffix <"+m_sErrSfx+">");
 
 
    //    Do users wish to delete files that were processed OK ?
-      String sPostDel = GpListener.obtainAtt(_params,ListenerTagNames.FILE_POST_DEL_TAG,"false").trim();
+      String sPostDel = GpListener.obtainAtt(_params,FILE_POST_DEL,"false").trim();
       m_bPostDel = Boolean.parseBoolean(sPostDel);
       if (m_bPostDel)
     	  return;
 
     //    POST (done) directory and suffix (defaults to input dir and ".esbDone" suffix)
-      String sPostDir = GpListener.obtainAtt(_params,ListenerTagNames.FILE_POST_DIR_TAG,sInpDir);
+      String sPostDir = GpListener.obtainAtt(_params,FILE_POST_DIR,sInpDir);
       m_oPostDir = new File(sPostDir);
-      m_sPostSfx  = GpListener.obtainAtt(_params,ListenerTagNames.FILE_POST_SFX_TAG,".esbDone").trim();
+      m_sPostSfx  = GpListener.obtainAtt(_params,FILE_POST_SFX,".esbDone").trim();
       if (m_oPostDir.equals(m_oInpDir))
       {	if (m_sPostSfx.length()<1)
-    	  throw new Exception ("Invalid "+ListenerTagNames.FILE_POST_SFX_TAG+" attribute");
+    	  throw new Exception ("Invalid "+FILE_POST_SFX+" attribute");
       	if (m_sPostSfx.equals(m_sInpSfx))
     	  throw new Exception("Post process suffix must differ from input suffix <"+m_sPostSfx+">");
       }

Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,215 @@
+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.security.InvalidParameterException;
+
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+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 class CallHelper
+{
+
+	public static Element toXML (Call call, Document doc, Element header)
+	{
+		if (call == null)
+			throw new InvalidParameterException();
+		
+		try
+		{
+			if (call.getTo() != null)
+			{
+				Element toElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.TO_TAG);
+				PortReferenceHelper.toXML(header, doc, toElement, call.getTo().getAddr(), true);
+				header.appendChild(toElement);
+			}
+			
+			if (call.getFrom() != null)
+			{
+				Element fromElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FROM_TAG);
+				PortReferenceHelper.toXML(header, doc, fromElement, call.getFrom().getAddr(), false);
+				header.appendChild(fromElement);
+			}
+			
+			if (call.getReplyTo() != null)
+			{
+				Element replyToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.REPLY_TO_TAG);
+				PortReferenceHelper.toXML(header, doc, replyToElement, call.getReplyTo().getAddr(), false);
+				header.appendChild(replyToElement);
+			}
+			
+			if (call.getRelatesTo() != null)
+			{
+				Element relatesToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.RELATES_TO_TAG);
+				relatesToElement.setNodeValue(call.getRelatesTo().toString());
+				header.appendChild(relatesToElement);
+			}
+			
+			if (call.getFaultTo() != null)
+			{
+				Element faultToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FAULT_TO_TAG);
+				PortReferenceHelper.toXML(header, doc, faultToElement, call.getFaultTo().getAddr(), false);
+				header.appendChild(faultToElement);
+			}
+			
+			if (call.getAction() != null)
+			{
+				Element actionElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.ACTION_TAG);
+				actionElement.setNodeValue(call.getAction().toString());
+				header.appendChild(actionElement);
+			}
+			
+			if (call.getMessageID() != null)
+			{
+				Element messageIDElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.MESSAGE_IDENTIFIER_TAG);
+				messageIDElement.setNodeValue(call.getMessageID().toString());
+				header.appendChild(messageIDElement);
+			}
+				
+			return header;
+		}
+		catch (Exception ex)
+		{
+			// TODO improve error handling.
+			
+			ex.printStackTrace();
+			
+			throw new InvalidParameterException(ex.toString());
+		}
+	}
+	
+	public static Call fromXML (Element header)
+	{
+		Call call = null;
+		
+		try
+		{
+			call = new Call();
+			
+			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
+					{
+						call.setTo(new EPR(PortReferenceHelper.fromXML((Element) n, true)));
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+				
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.FROM_TAG))
+				{
+					try
+					{
+						call.setFrom(new EPR(PortReferenceHelper.fromXML((Element) n, false)));
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+				
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.REPLY_TO_TAG))
+				{
+					try
+					{
+						call.setReplyTo(new EPR(PortReferenceHelper.fromXML((Element) n, false)));
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.RELATES_TO_TAG))
+				{
+					try
+					{
+						call.setRelatesTo(new URI(n.getNodeValue()));
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.FAULT_TO_TAG))
+				{
+					try
+					{
+						call.setFaultTo(new EPR(PortReferenceHelper.fromXML((Element) n, false)));
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.ACTION_TAG))
+				{			
+					try
+					{
+						call.setAction(new URI(n.getNodeValue()));
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+				
+				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.MESSAGE_IDENTIFIER_TAG))
+				{
+					try
+					{
+						call.setMessageID(new URI(n.getNodeValue()));
+					}
+					catch (Exception ex)
+					{
+						
+					}
+				}
+			}
+		}
+		catch (Exception ex)
+		{
+			// TODO error checking!!
+			
+			ex.printStackTrace();
+		}
+		
+		return call;
+	}
+	
+} 
\ No newline at end of file

Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,278 @@
+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 java.net.URISyntaxException;
+import java.security.InvalidParameterException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.jboss.soa.esb.MarshalException;
+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.HTTPEpr;
+import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+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;
+
+public class EPRHelper
+{
+    public static final String ELEMENT_NAME = "epr";
+    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)
+    {
+	if (epr == null)
+	    throw new InvalidParameterException();
+
+	try
+	{
+	    PortReferenceHelper.toXML(null, doc, header, epr.getAddr(), false);
+
+	    return header;
+	}
+	catch (URISyntaxException ex)
+	{
+	    ex.printStackTrace();
+
+	    return null;
+	}
+	catch (MarshalException ex)
+	{
+	    ex.printStackTrace();
+
+	    return null;
+	}
+    }
+
+    /**
+     * Deserialize the EPR from an XML representation.
+     * 
+     * @param header
+     * @return
+     */
+    
+    public static final EPR fromXML (Element header)
+    {
+	if (header == null)
+	    throw new InvalidParameterException();
+
+	try
+	{
+	    if (header.getNodeName().equals(ELEMENT_NAME))
+		return getSpecificEPR(new EPR(PortReferenceHelper.fromXML(header, false)), header);
+	    else
+		return new EPR(PortReferenceHelper.fromXML(header, false));
+	}
+	catch (MarshalException ex)
+	{
+	    ex.printStackTrace();
+
+	    return null;
+	}
+    }
+
+    /**
+     * 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
+     */
+    
+    public static final String toXMLString (EPR epr)
+    {
+	if (epr == null)
+	    throw new InvalidParameterException();
+
+	try
+	{
+	    DocumentBuilderFactory factory = DocumentBuilderFactory
+		    .newInstance();
+	    DocumentBuilder builder = factory.newDocumentBuilder();
+	    Document doc = builder.newDocument();
+	    Element portReferenceElement = doc.createElement(ELEMENT_NAME);
+
+	    setSpecificEPR(epr, portReferenceElement);
+	    
+	    doc.appendChild(portReferenceElement);
+
+	    toXML(epr, doc, portReferenceElement);
+
+	    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 (IOException ex)
+	{
+	    ex.printStackTrace();
+
+	    return null;
+	}
+	catch (ParserConfigurationException ex)
+	{
+	    ex.printStackTrace();
+
+	    return null;
+	}
+    }
+
+    /**
+     * 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
+     */
+    
+    public static final EPR fromXMLString (String xml)
+    {
+	if (xml == null)
+	    throw new InvalidParameterException();
+
+	try
+	{
+	    DocumentBuilderFactory factory = DocumentBuilderFactory
+		    .newInstance();
+	    DocumentBuilder builder = factory.newDocumentBuilder();
+	    Document doc = builder.parse(new ByteArrayInputStream(xml
+		    .getBytes()));
+	    Element rootElement = doc.getDocumentElement();
+
+	    return getSpecificEPR(new EPR(PortReferenceHelper.fromXML(rootElement, false)), rootElement);
+	}
+	catch (MarshalException ex)
+	{
+	    ex.printStackTrace();
+
+	    return null;
+	}
+	catch (SAXException ex)
+	{
+	    ex.printStackTrace();
+
+	    return null;
+	}
+	catch (IOException ex)
+	{
+	    ex.printStackTrace();
+
+	    return null;
+	}
+	catch (ParserConfigurationException ex)
+	{
+	    ex.printStackTrace();
+
+	    return null;
+	}
+    }
+
+    private final static void setSpecificEPR (EPR epr, Element header)
+    {
+	try
+	{
+	    String eprType = null;
+
+	    if (epr instanceof EmailEpr)
+		    eprType = EmailEpr.type().toString();
+		else if (epr instanceof FTPEpr)
+		    eprType = FTPEpr.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();
+		
+		System.err.println("**eprType "+eprType);
+		
+		if (eprType != null)
+		    header.setAttribute(EPR_TYPE, eprType);
+	}
+	catch (Exception ex)
+	{
+	    ex.printStackTrace();
+	}
+    }
+
+    private final static EPR getSpecificEPR (EPR epr, Element header)
+    {
+	try
+	{
+	    String eprType = header.getAttribute(EPR_TYPE);
+
+	    if (eprType != null)
+	    {
+		if (eprType.equals(EmailEpr.type().toString()))
+		    return new EmailEpr(epr);
+		else if (eprType.equals(FTPEpr.type().toString()))
+		    return new FTPEpr(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
+		    return epr;
+	    }
+	    else
+		return epr;
+	}
+	catch (Exception ex)
+	{
+	    ex.printStackTrace();
+
+	    return epr;
+	}
+    }
+
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/PortReferenceHelper.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/PortReferenceHelper.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/PortReferenceHelper.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,430 @@
+/*
+ * 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.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 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 && !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/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverOnlyCourier.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverOnlyCourier.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverOnlyCourier.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,31 @@
+/*
+ * 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.internal.soa.esb.couriers;
+
+import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.message.Message;
+
+public interface DeliverOnlyCourier 
+{
+	public boolean	deliver(Message message) throws CourierException;
+}

Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,337 @@
+/*
+ * 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.internal.soa.esb.couriers;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.List;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSession;
+import javax.naming.Context;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.helpers.AppServerContext;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.util.Util;
+import org.xml.sax.SAXException;
+
+public class JmsCourier implements PickUpOnlyCourier, DeliverOnlyCourier 
+{
+	/**
+	 * disable default constructor
+	 */
+	private JmsCourier() { }
+
+	/**
+	 * package protected constructor - Objects of Courier should only be instantiated by the Factory
+	 * @param epr
+	 */
+	JmsCourier(JMSEpr epr) throws CourierException { this(epr,false); }
+
+	/**
+	 * package protected constructor - Objects of Courier should only be instantiated by the Factory
+	 * @param epr
+	 */
+	JmsCourier(JMSEpr epr, boolean isReceiver) throws CourierException
+	{
+		_isReceiver = isReceiver;
+		_epr		= epr;
+		_sleepForRetries	= 3000;
+
+		if (! _isReceiver)
+			try { _messageProperties = Util.propertiesFromSelector(_epr.getMessageSelector()); }
+			catch (Exception e) { throw new CourierException(e); }
+		
+    } //________________________________
+
+	void cleanup() 
+	{
+		if (null != _messageProducer)
+			try { _messageProducer.close(); }
+			catch (JMSException e) {/*  OK do nothing  */ }
+		
+		if (null != _messageConsumer)
+			try { _messageConsumer.close(); }
+			catch (JMSException e) {/*  OK do nothing  */ }
+		
+		if (null != _jmsSession)
+			try { _jmsSession.close(); }
+			catch (JMSException e) {/*  OK do nothing  */ }
+		
+		if (null != _jmsConnection)
+			try { _jmsConnection.close(); }
+			catch (JMSException e) {/*  OK do nothing  */ }
+
+		_messageProducer 	= null;
+		_messageConsumer 	= null;
+		_jmsSession 		= null;
+		_jmsConnection 		= null;
+    } //________________________________
+
+	/**
+	 * package the ESB message in a javax.jms.ObjectMessage, and send it
+	 * @param message Message - the message to deliver 
+	 * @return boolean - the result of the delivery
+	 * @throws CourierException - if problems were encountered
+	 */
+	public boolean deliver(Message message) throws CourierException 
+	{
+		if (_isReceiver)
+			throw new CourierException("This is a read-only Courier");
+
+		if (null==message)
+			return false;
+		if (null==_messageProducer)
+			try {  createMessageProducer();}
+			catch (Exception e) {throw new CourierException(e); }
+
+		while (null!=_messageProducer)
+		{
+			try 
+			{
+				// obtain Serializable version of arg0 and package it in a jms ObjectMessage
+				ObjectMessage msg = _jmsSession.createObjectMessage(Util.serialize(message));
+				for (KeyValuePair kvp : _messageProperties)
+					msg.setStringProperty(kvp.getKey(), kvp.getValue());
+				sendMessage(msg);
+				return true;
+			}
+			catch (JMSException e)	{ jmsConnectRetry(e); }
+			catch (Exception e)		{ throw new CourierException(e);}
+		}
+		return false;
+	} //________________________________
+	
+	/**
+	 * send/publish a javax.jms.ObjectMessage (that will contain the serialized ESB Message)
+	 * @param jmsMessage
+	 */
+	private void sendMessage(javax.jms.Message jmsMessage) throws JMSException
+    {
+    	if (_messageProducer instanceof TopicPublisher)
+    		((TopicPublisher)_messageProducer).publish(jmsMessage);
+    	else
+    		_messageProducer.send(jmsMessage);
+    } //________________________________
+    
+    private void jmsConnectRetry(Exception exc)
+    {
+    	_logger.error("JMS error.  Attempting JMS reconnect.", exc);
+        _jmsConnection	= null;
+        _jmsSession		= null;
+		_messageProducer= null;
+		_messageConsumer= null;
+
+		for (int i1 = 0; i1 < 5; i1++)
+		{
+    		// try to reconnect to the queue
+    		try 
+    		{ 
+    			if (_isReceiver)
+    				createMessageConsumer();
+    			else
+    				createMessageProducer(); 
+    		} 
+    		catch (Exception e)
+    		{
+    			_logger.error("Reconnecting to JMS", e);
+    			try {	Thread.sleep(_sleepForRetries); }
+    			catch (InterruptedException e1)
+    			{ // Just return after logging
+    				_logger.error("Unexpected thread interupt exception.", e);
+    				break;
+                }
+            }
+		}
+    } //________________________________
+    
+    private void createMessageProducer() throws Exception
+    {
+        String sJndiType = _epr.getJndiType();
+        if (Util.isNullString(sJndiType))
+        	sJndiType = "jboss";
+        String sJndiURL = _epr.getJndiURL();
+        if (Util.isNullString(sJndiURL))
+        	sJndiURL = "localhost";
+        Context oJndiCtx = AppServerContext.getServerContext(sJndiType,sJndiURL);
+
+        String sFactoryClass = _epr.getConnectionFactory();
+        if (Util.isNullString(sFactoryClass))
+        	sFactoryClass = "ConnectionFactory";
+        
+        Object tmp = oJndiCtx.lookup(sFactoryClass);
+        
+        String sType = _epr.getDestinationType();
+        if (JMSEpr.QUEUE_TYPE.equals(sType))
+        {
+            javax.jms.Queue queue = (javax.jms.Queue) oJndiCtx.lookup(_epr.getDestinationName());
+            QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+            QueueConnection qConn = qcf.createQueueConnection();
+            QueueSession qSess = qConn.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE);
+            _jmsConnection	 = qConn;
+            _jmsSession		 = qSess;
+            _messageProducer = qSess.createSender(queue);
+        }
+        else if(JMSEpr.TOPIC_TYPE.equals(sType))
+        {
+            Topic topic = (Topic) oJndiCtx.lookup(_epr.getDestinationName());
+            TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
+            TopicConnection tConn = tcf.createTopicConnection();
+            TopicSession tSess = tConn.createTopicSession(false,TopicSession.AUTO_ACKNOWLEDGE);
+            _jmsConnection	 = tConn;
+            _jmsSession		 = tSess;
+            _messageProducer = tSess.createPublisher(topic);
+        }
+        else
+        	throw new CourierException("Unknown destination type");
+                
+    } //________________________________
+
+	public Message pickup(long millis) throws CourierException 
+	{
+		if (! _isReceiver)
+			throw new CourierException("This is an outgoing-only Courier");
+		if (millis < 1)
+			throw new IllegalArgumentException("Timeout millis must be > 0");
+		if (null==_messageConsumer)
+			try {  createMessageConsumer();}
+			catch (Exception e) {throw new CourierException(e); }
+		
+	    javax.jms.Message jmsMessage = null;
+		while (null!=_messageConsumer)
+		{
+			try 
+			{ 
+            	jmsMessage = _messageConsumer.receive(millis);
+            	break;
+			}
+			catch (JMSException e)	{ jmsConnectRetry(e); }
+			catch (Exception e)		{ throw new CourierException(e);}
+		}
+    	if (null == jmsMessage)
+        	return null;
+
+        if (!(jmsMessage instanceof ObjectMessage))
+        {
+        	_logger.error("Unsupported JMS message type: " + jmsMessage.getClass().getName());
+        	return null;
+        }
+        try
+        {
+        	Serializable obj = (Serializable)((ObjectMessage)jmsMessage).getObject();
+        	return Util.deserialize(obj);
+        } 
+        catch (JMSException e1)
+        { _logger.error("Failed to read Serialized Object from JMS message.", e1);
+          return null;
+        }
+        catch (ClassCastException e2)
+        { _logger.error("Object in JMS message is not a org.jboss.soa.esb.message.Message", e2);
+        }
+        catch (IOException e3)
+        { _logger.error("Object in JMS message is not a Serializeable", e3);
+        }
+        catch (ParserConfigurationException e4)
+        { _logger.error("Object in JMS message has invalid XML", e4);
+        }
+        catch (SAXException e5)
+        { _logger.error("Object in JMS message has invalid XML", e5);
+        }
+    	return null;
+    } //________________________________
+
+    private void createMessageConsumer() throws Exception
+    {
+        String sJndiType = _epr.getJndiType();
+        if (Util.isNullString(sJndiType))
+        	sJndiType = "jboss";
+        String sJndiURL = _epr.getJndiURL();
+        if (Util.isNullString(sJndiURL))
+        	sJndiURL = "localhost";
+        Context oJndiCtx = AppServerContext.getServerContext(sJndiType,sJndiURL);
+
+        String sFactoryClass = _epr.getConnectionFactory();
+        if (Util.isNullString(sFactoryClass))
+        	sFactoryClass = "ConnectionFactory";
+        
+        Object tmp = oJndiCtx.lookup(sFactoryClass);
+        
+        String sType = _epr.getDestinationType();
+        if (JMSEpr.QUEUE_TYPE.equals(sType))
+        {
+            javax.jms.Queue queue = (javax.jms.Queue) oJndiCtx.lookup(_epr.getDestinationName());
+            QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+            QueueConnection qConn = qcf.createQueueConnection();
+            QueueSession qSess = qConn.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE);
+            _jmsConnection	 = qConn;
+            _jmsSession		 = qSess;
+            _messageConsumer = qSess.createReceiver(queue,_epr.getMessageSelector());
+            qConn.start();
+        }
+        else if(JMSEpr.TOPIC_TYPE.equals(sType))
+        {
+            Topic topic = (Topic) oJndiCtx.lookup(_epr.getDestinationName());
+            TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
+            TopicConnection tConn = tcf.createTopicConnection();
+            TopicSession tSess = tConn.createTopicSession(false,TopicSession.AUTO_ACKNOWLEDGE);
+            _jmsConnection	 = tConn;
+            _jmsSession		 = tSess;
+            _messageConsumer = tSess.createConsumer(topic,_epr.getMessageSelector());
+            tConn.start();
+        }
+        else
+        	throw new CourierException("Unknown destination type");
+
+                
+    } //________________________________
+
+			long 				_sleepForRetries = 3000;   //  milliseconds
+
+	protected boolean			_isReceiver;	  
+    protected JMSEpr			_epr;
+    protected Logger			_logger = Logger.getLogger(JmsCourier.class);
+    protected String 			_messageSelector;
+    protected Connection 		_jmsConnection;
+    protected Session 			_jmsSession;
+    protected MessageProducer 	_messageProducer;
+    protected MessageConsumer	_messageConsumer;
+    protected List<KeyValuePair> _messageProperties;
+
+}

Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpOnlyCourier.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpOnlyCourier.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpOnlyCourier.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,36 @@
+/*
+ * 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.internal.soa.esb.couriers;
+
+import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.couriers.CourierTimeoutException;
+import org.jboss.soa.esb.message.Message;
+/**
+ * 
+ * @author kstam
+ *
+ */
+public interface PickUpOnlyCourier 
+{
+	public Message	pickup(long millis) throws CourierException, CourierTimeoutException;
+}

Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,150 @@
+/*
+ * 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.internal.soa.esb.couriers;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.couriers.CourierTimeoutException;
+import org.jboss.soa.esb.couriers.TwoWayCourier;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * A two-way-courier can perform message deliveries and pickups.
+ * 
+ * @author esteban
+ * @author kstam at redhat.com
+ */
+public class TwoWayCourierImpl implements TwoWayCourier
+{
+	private DeliverOnlyCourier	_deliverCourier;
+	private PickUpOnlyCourier	_pickupCourier;
+	/**
+	 * Constructor. 
+	 * @param toEpr             - to address
+	 * @param replyToEpr        - reply to address
+	 * @throws CourierException
+	 */
+	public TwoWayCourierImpl(EPR toEpr, EPR replyToEpr) throws CourierException
+	{
+		setToEpr		(toEpr);
+		setReplyToEpr	(replyToEpr);
+	}
+	/**
+	 * @see  org.jboss.soa.esb.couriers.TwoWayCourier#setToEpr(toEPR).
+	 */
+	public void setToEpr(EPR toEPR) throws CourierException
+	{
+		DeliverOnlyCourier old = _deliverCourier;
+		_deliverCourier	= getDeliverCourier(toEPR);
+		tryToCleanup(old);
+	}
+	/**
+	 * @see  org.jboss.soa.esb.couriers.TwoWayCourier#setReplyEpr(toReplyEPR).
+	 */
+	public void setReplyToEpr(EPR replyToEPR) throws CourierException
+	{
+		PickUpOnlyCourier old = _pickupCourier;
+		_pickupCourier	= getPickupCourier(replyToEPR);
+		tryToCleanup(old);
+	}
+
+	private DeliverOnlyCourier getDeliverCourier(EPR toEPR) throws CourierException
+	{
+		if (null==toEPR)
+			return null;
+		if (toEPR instanceof JMSEpr)
+			return new JmsCourier((JMSEpr)toEPR);
+		throw new CourierException ("Deliver courier for "+toEPR.getClass().getSimpleName()+" not supported yet");
+	}
+
+	private PickUpOnlyCourier getPickupCourier(EPR replyToEPR) throws CourierException
+	{
+		if (null==replyToEPR)
+			return null;
+		if (replyToEPR instanceof JMSEpr)
+			return new JmsCourier((JMSEpr)replyToEPR,true);
+		throw new CourierException ("Couriers for "+replyToEPR.getClass().getSimpleName()+" not supported yet");
+	}
+	/**
+	 * @see  org.jboss.soa.esb.couriers.Courier#deliver(Message message).
+	 */
+	public boolean deliver(Message message) throws CourierException 
+	{
+		boolean bRet=false;
+		try {
+			if (null==_deliverCourier)
+				throw new CourierException("No deliver courier");
+			bRet = _deliverCourier.deliver(message);
+		} finally {
+			tryToCleanup(_deliverCourier);
+		}
+		return bRet;
+	}
+	/**
+	 * @see  org.jboss.soa.esb.couriers.TwoWayCourier#pickup(long waitTime).
+	 */
+	public Message pickup(long waitTime) throws CourierException, CourierTimeoutException 
+	{	
+		return pickup(waitTime,_pickupCourier);
+	}
+
+	/**
+	 * @see  org.jboss.soa.esb.couriers.TwoWayCourier#pickup(long waitTime, EPR epr).
+	 */
+	public Message pickup(long waitTime, EPR epr) throws CourierException, CourierTimeoutException 
+	{
+		return pickup(waitTime,getPickupCourier(epr));
+	}
+	
+
+	private Message pickup(long waitTime, PickUpOnlyCourier courier) throws CourierException, CourierTimeoutException 
+	{	
+		Message replyMessage = null;
+		try {
+			if (null==courier)
+				throw new CourierException("No courier defined for pick ups");
+			replyMessage = courier.pickup(waitTime);
+		} finally {
+			tryToCleanup(courier);
+		}
+		return replyMessage;
+	}
+
+	private void tryToCleanup(Object obj)
+	{
+		if (null==obj)
+			return;
+		try 
+		{ 
+			Method mth = obj.getClass().getMethod("cleanup", new Class[]{});
+			mth.invoke(obj, new Object[] {});
+		}
+		catch (NoSuchMethodException e) 	{ /*  OK - nothing to call */ }
+		catch (IllegalAccessException e)	{ /* tried to cleanup - just return  */ }
+		catch (InvocationTargetException e)	{ /* tried to cleanup - just return  */ }
+	}
+}

Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/EmailEpr.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/EmailEpr.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/EmailEpr.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,189 @@
+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;
+
+/**
+ * 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);
+	}
+	
+	/**
+	 * 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/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,169 @@
+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;
+
+/**
+ * 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 EPR
+{
+	public static final String USERNAME_TAG = "username";
+	public static final String PASSWORD_TAG = "password";
+	
+	public FTPEpr (EPR epr)
+	{
+		copy(epr);
+	}
+	
+	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.
+	 * 
+	 * @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);
+	}
+	
+	public static final URI type ()
+	{
+	    return _type;
+	}
+
+	private boolean passwordSet = false;
+	private boolean userSet = 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/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/HTTPEpr.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/HTTPEpr.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/HTTPEpr.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,105 @@
+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;
+
+/**
+ * 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 (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/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/JDBCEpr.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/JDBCEpr.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/JDBCEpr.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,230 @@
+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;
+
+/**
+ * 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 JDBCEpr (EPR epr)
+	{
+		copy(epr);
+	}
+	
+	public JDBCEpr (String url, String sql) throws URISyntaxException
+	{
+		super(new URI(url));
+		
+		setSQL(sql);
+	}
+
+	/**
+	 * 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);
+	}
+	
+	public static final URI type ()
+	{
+	    return _type;
+	}
+	
+	private boolean userSet = false;
+	private boolean passwordSet = false;
+	private boolean sqlSet = false;
+	private boolean driverSet = 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/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,284 @@
+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;
+
+/**
+ * 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_TYPE_TAG = "jndi-type";
+    public static final String JNDI_URL_TAG = "jndi-URL";
+    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);
+    }
+
+    /**
+         * 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,
+		"jboss", "localhost", 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 jndiType, String jndiUrl,
+	    String messageSelector)
+    {
+	this(ONE_ONE_PROTOCOL, destinationType, destinationName, connection,
+		jndiType, jndiUrl, 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 jndiType,
+	    String jndiUrl, 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 (jndiType != null)
+		    addr.addExtension(JNDI_TYPE_TAG, jndiType);
+
+		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!");
+	}
+	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 type for this EPR, or <code>null</code> if none is
+         *         set.
+         * @throws URISyntaxException
+         *                 thrown if the address is malformed.
+         */
+
+    public final String getJndiType () throws URISyntaxException
+    {
+	return getAddr().getExtensionValue(JNDI_TYPE_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/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,43 @@
+/*
+ * 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.couriers;
+
+import org.jboss.soa.esb.message.Message;
+/**
+ * Courier interface. Deals relatively low level Message transport options.
+ * 
+ * @author esteban
+ * @author kstam at redhat.com
+ *
+ */
+public interface Courier
+{
+	/**
+	 * Try to deliver an ESB message. This is a one shot delivery.
+	 * 
+	 * @param message Message - the message to deliver 
+	 * @return boolean - the result of the delivery
+	 * @throws CourierException - if problems were encountered
+	 */
+	public boolean deliver(Message message) throws CourierException;
+}

Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierException.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierException.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierException.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,55 @@
+/*
+ * 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.couriers;
+
+import org.jboss.soa.esb.BaseException;
+
+/**
+ * Dispatch Exception.
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ * @since Version 4.0
+ */
+public class CourierException extends BaseException 
+{
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+     * Construct an exception instance. 
+     * @param message Exception message.
+     */
+    public CourierException(String message) { super(message); }
+
+    /**
+     * Construct an exception instance. 
+     * @param message Exception message.
+     * @param cause Exception cause.
+     */
+    public CourierException(String message, Throwable cause) { super(message, cause); }
+
+    /**
+     * Construct an exception instance. 
+     * @param cause Exception cause.
+     */
+    public CourierException(Throwable cause) { super(cause); }
+}

Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,80 @@
+/*
+ * 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.couriers;
+/**
+ * 
+ * @author - esteban
+ * @author - kstam at redhat.com
+ *
+ */
+import org.jboss.internal.soa.esb.couriers.TwoWayCourierImpl;
+import org.jboss.soa.esb.addressing.EPR;
+
+public class CourierFactory 
+{
+	private static final CourierFactory _instance = new CourierFactory();
+	
+	// private default constructor
+	private CourierFactory() {}
+
+	public static CourierFactory getInstance(Object obj)
+	{
+		return _instance;
+	}
+	/**
+	 * Obtain a courier which can perform deliveries only and prime it with the "to address" (toEPR).
+	 * 
+	 * @param toEPR - the 'to address', the address on where to deliver a Message.
+	 * @return
+	 * @throws CourierException if the specific courier implementation cannot be created.
+	 */
+	public static Courier getCourier(EPR toEPR) throws CourierException
+	{
+		return getCourier(toEPR, null);
+	}
+	/**
+	 * Obtain a courier which can perform pickups only and prime it with the "to address" (toEPR) 
+	 * and the "replyTo address" (replyToEPR). 
+	 * 
+	 * @param toEPR      - the 'to address', the address on where to deliver a Message.
+	 * @parem replyToEPR - the 'replyTo address', the address where to deliver the Message we pickup.
+	 * @return
+	 * @throws CourierException if the specific courier implementation cannot be created.
+	 */
+	public static TwoWayCourier getPickupCourier(EPR replyToEPR) throws CourierException
+	{
+		return getCourier(null, replyToEPR);
+	}
+	/**
+	 * Obtain a courier which can perform both deliveries and pickups and prime it with 
+	 * the "to address" (toEPR) and the "replyTo address" (replyToEPR). 
+	 * 
+	 * @param toEPR      - the 'to address', the address on where to deliver a Message.
+	 * @parem replyToEPR - the 'replyTo address', the address where to deliver the Message we pickup.
+	 * @return
+	 * @throws CourierException if the specific courier implementation cannot be created.
+	 */
+	public static TwoWayCourier getCourier(EPR toEPR, EPR replyToEPR) throws CourierException
+	{
+		return new TwoWayCourierImpl(toEPR, replyToEPR);
+	}
+}

Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierTimeoutException.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierTimeoutException.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierTimeoutException.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,55 @@
+/*
+ * 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.couriers;
+
+import org.jboss.soa.esb.BaseException;
+
+/**
+ * Timeout exception.
+ * 
+ * @author kstam at redhat.com
+ */
+public class CourierTimeoutException extends BaseException 
+{
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+     * Construct an exception instance. 
+     * @param message Exception message.
+     */
+    public CourierTimeoutException(String message) { super(message); }
+
+    /**
+     * Construct an exception instance. 
+     * @param message Exception message.
+     * @param cause Exception cause.
+     */
+    public CourierTimeoutException(String message, Throwable cause) { super(message, cause); }
+
+    /**
+     * Construct an exception instance. 
+     * @param cause Exception cause.
+     */
+    public CourierTimeoutException(Throwable cause) { super(cause); }
+}

Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,103 @@
+/*
+ * 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.couriers;
+
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.util.Util;
+
+public class CourierUtil
+{
+	public static final String CORRELATION_ID_TAG = "messageCorrelationId";
+	
+	private CourierUtil()
+	{
+	}
+
+	
+    public static List<KeyValuePair> propertiesFromSelector(String selector) throws Exception 
+    {
+		// No problem if selector is null - everything in queue will be returned
+		List<KeyValuePair> oRet = new ArrayList<KeyValuePair>();
+		if (! Util.isNullString(selector)) {
+			for (String sCurr : selector.split(",")) {
+				String[] sa = sCurr.split("=");
+				if (sa.length!=2
+				||  sa[1].charAt(0)!='\''
+				||  sa[1].charAt(-1+sa[1].length())!='\'')
+					throw new Exception("Illegal message selector syntax <"+selector+">");
+				KeyValuePair oNew = new KeyValuePair
+					(sa[0],sa[1].substring(0,-1+sa[1].length()).substring(1));
+				oRet.add(oNew);
+			}
+    	}
+		return oRet;
+    }
+    /**
+     * We will be listening the same queue, but with a 'temporary' message selector
+     * based of a UUID.
+     * 
+     * @param message to which we ill add the CORRELATION_ID_TAG.
+     * @return the generated unique reply selector.
+     */
+	public static String getReplySelector()
+	{
+    	String uuId = UUID.randomUUID().toString();
+    	String uniqueReplySelector = new StringBuilder()
+		.append(CORRELATION_ID_TAG).append("='")
+		.append(uuId).append("'").toString();
+    	return uniqueReplySelector;
+	}
+	
+    /**
+     * Build a temporary replyToEPR, based on the toEpr, to which we can reply to.
+     * <ul>
+     * <li> for JMS we will use the toEpr, but change the message selector.
+     * </ul>
+     *  
+     * @param toEpr - the toEPR which will be used a basis to generate the replyToEPR.
+     * @return replyToEPR - the EPR to which the pickup will be delivered.
+     * @throws URISyntaxException, CourierException
+     */
+    public static EPR getTemporaryReplyToEpr(EPR toEpr) throws URISyntaxException, CourierException
+    {
+    	EPR replyToEpr = null;
+    	if (toEpr instanceof JMSEpr) {
+	    	JMSEpr jpr = (JMSEpr) toEpr;
+            //Setting the replyTo to the queue we specific in the epr we are going to call
+			//The selectors will do the job.
+			replyToEpr =  new JMSEpr(jpr.getDestinationType()  ,jpr.getDestinationName()
+	            ,jpr.getConnectionFactory(),jpr.getJndiType()
+	            ,jpr.getJndiURL()          ,getReplySelector());
+    	} else {
+    		throw new CourierException("Found a non-JMS based EPR, JMS-EPRs is all we support right now");
+    	}
+    	return replyToEpr;
+    }
+}

Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/TwoWayCourier.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/TwoWayCourier.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/couriers/TwoWayCourier.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,45 @@
+package org.jboss.soa.esb.couriers;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.message.Message;
+
+public interface TwoWayCourier extends Courier 
+{
+	/**
+     * Instruct the courier to wait for a pickup in the replyToEpr
+     * 
+     * @param waitTime         - Pickup timeout for before giving up on this pickup. Time in millis.
+     * @return                 - the message that was picked up.
+     * @throws CourierException the courier fails (i.e. gets a flat tire).
+	 * @throws CourierTimeoutException if the pickup timed out (nobody home).
+     */
+	public Message pickup(long waitTime) throws CourierException, CourierTimeoutException;
+	/**
+     * Instruct the courier to wait for a pickup in the specified EPR
+     * 
+     * @param waitTime         - Pickup timeout for before giving up on this pickup. Time in millis.
+     * @param epr              - Pickup address
+     * @return                 - the message that was picked up.
+     * @throws CourierException the courier fails (i.e. gets a flat tire).
+	 * @throws CourierTimeoutException if the pickup timed out (nobody home).
+     */
+	public Message pickup(long waitTime, EPR epr) throws CourierException, CourierTimeoutException;
+	/**
+	 * Sets the toEPR. This can be used if the toEPR is not know at construction time of
+	 * the Courier.
+	 * 
+	 * @param toEPR - EPR specifying the 'to' address.
+	 * @throws CourierException
+	 */
+
+	public void setToEpr(EPR toEPR) throws CourierException;
+	/**
+	 * Sets the replyToEPR. This can be used if the replyToEPR is not know at construction time of
+	 * the Courier.
+	 * 
+	 * @param replyToEPR - EPR specifying the reply to address.
+	 * @throws CourierException
+	 */
+
+	public void setReplyToEpr(EPR replyToEPR) throws CourierException;
+}

Added: labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManager.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManager.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManager.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,103 @@
+/*
+ * 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 daniel.brum at jboss.com
+ */
+
+package org.jboss.internal.soa.esb.persistence.format.db;
+
+import java.sql.Connection;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.common.Configuration;
+
+import com.mchange.v2.c3p0.ComboPooledDataSource;
+
+
+public class DBConnectionManager {
+	
+	private static DBConnectionManager instance =null;
+	
+	protected ComboPooledDataSource pooledDS = null;
+	
+	private static final Object foo = new Integer(0);
+	
+	private static Logger _logger = Logger.getLogger(DBConnectionManager.class);
+	
+	
+	protected DBConnectionManager() {}
+	
+	public static DBConnectionManager getInstance() {		
+			if (null != instance) {				
+				return instance;
+			} synchronized(foo) {
+				if (null != instance)
+					return instance;
+				try {
+					instance = new DBConnectionManager();
+					instance.init();
+				}catch(Exception e) {
+					e.printStackTrace();
+					return null;
+				}
+				
+				return instance;
+			}				
+				
+	}
+	
+	private void init() throws Exception{
+		_logger.info("Initializing DBConnectionManager");		
+		pooledDS = new ComboPooledDataSource();
+		
+		
+		pooledDS.setDriverClass(Configuration.getStoreDriver());
+		pooledDS.setJdbcUrl(Configuration.getStoreUrl());
+		pooledDS.setUser(Configuration.getStoreUser());
+		pooledDS.setPassword(Configuration.getStorePwd());
+		pooledDS.setMinPoolSize(Integer.valueOf(Configuration.getStorePoolMinSize()));
+		pooledDS.setInitialPoolSize(Integer.valueOf(Configuration.getStorePoolInitialSize()));
+		pooledDS.setMaxPoolSize(Integer.valueOf(Configuration.getStorePoolMaxSize()));		
+		pooledDS.setAutomaticTestTable(Configuration.getStorePoolTestTable());
+		pooledDS.setCheckoutTimeout(Integer.valueOf(Configuration.getStorePoolTimeoutMillis()));
+	}
+		
+		
+	
+	public Connection getConnection() throws Exception{		
+		
+		Connection conn = null;
+		
+		//TODO: figure out why this is neccessary - pool should never return null if DB is up and can connect
+		//testing showed null was being returned from pool in QA test MessageStoreTest
+		while (true)
+		{
+			if (null!=pooledDS)
+				if (null != (conn=pooledDS.getConnection()))
+						break;
+			else
+				System.out.println("Null pooledDS");
+			try { Thread.sleep(1000); }
+			catch(Exception e) {}
+		}
+		
+		return conn;
+		
+	}
+
+}

Added: labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManagerDBCP.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManagerDBCP.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManagerDBCP.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,101 @@
+/*
+ * 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 daniel.brum at jboss.com
+ */
+
+package org.jboss.internal.soa.esb.persistence.format.db;
+
+
+import java.sql.Connection;
+
+import org.apache.commons.pool.ObjectPool;
+import org.apache.commons.pool.impl.GenericObjectPool;
+import org.apache.commons.dbcp.ConnectionFactory;
+import org.apache.commons.dbcp.PoolingDataSource;
+import org.apache.commons.dbcp.PoolableConnectionFactory;
+import org.apache.commons.dbcp.DriverManagerConnectionFactory;
+import org.jboss.soa.esb.common.Configuration;
+
+/*
+ * the DBConnectionManager class (singleton) is used by classes implenting the MessageStore interface
+ * to obtain a connection to the persistence store database.
+ * This class uses the Apache Commons DB Connection Pooling to handle all aspects of managing the connections
+ * in a pool.
+ * $author Daniel Brum
+ */
+
+
+public class DBConnectionManagerDBCP {
+	
+	
+	
+	private static DBConnectionManagerDBCP instance =null;
+	private PoolingDataSource dataSource = null;	
+	
+	protected DBConnectionManagerDBCP() {}
+	
+	public static DBConnectionManagerDBCP getInstance() {		
+			if (null == instance) {
+				try {
+					instance = new DBConnectionManagerDBCP();
+					instance.init();
+				}catch(Exception e) {
+					e.printStackTrace();
+					return null;
+				}
+			}		
+		return instance;		
+	}
+		
+	private void init() throws Exception{
+
+		String connectURL = Configuration.getStoreUrl();       
+		Class.forName(Configuration.getStoreDriver());
+        
+		ObjectPool connectionPool = new GenericObjectPool(null);		
+		
+		ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURL,
+				Configuration.getStoreUser(), Configuration.getStorePwd());
+		
+		@SuppressWarnings("unused")
+		
+		PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,
+				connectionPool,null,null,false,false);
+		
+		int poolSize = Integer.valueOf(Configuration.getStorePoolInitialSize());
+		
+		//add the max # of connections into the pool
+		for (int i=0 ; i<poolSize ; i++) {
+			   try {								
+				connectionPool.addObject();
+			} catch (Exception e) {				
+				e.printStackTrace();
+			}
+		}
+		dataSource = new PoolingDataSource(connectionPool);		
+	}
+	
+	public Connection getConnection() throws Exception{		
+		return dataSource.getConnection();
+	}
+
+
+
+
+}

Added: labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,127 @@
+/*
+ * 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 daniel.brum at jboss.com
+ */
+
+package org.jboss.internal.soa.esb.persistence.format.db;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.UUID;
+
+import org.jboss.internal.soa.esb.thirdparty.Base64;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.persistence.MessageStore;
+import org.jboss.soa.esb.util.Util;
+
+
+public class DBMessageStoreImpl implements MessageStore {
+	
+	
+	protected DBConnectionManager mgr = null;
+	protected Connection conn = null;
+	protected ResultSet rs = null;
+	protected PreparedStatement ps = null;
+	
+	public DBMessageStoreImpl() {		
+		mgr = DBConnectionManager.getInstance();
+	}
+	
+	public synchronized URI addMessage(Message message){
+				
+//		String messageString = null;
+		URI uid = null;		
+		
+		
+		try {			
+			conn = mgr.getConnection();
+			
+			uid = new URI("urn:jboss:esb:message:UID:" + UUID.randomUUID().toString());			
+			
+			String messageString = Base64.encodeObject(Util.serialize(message));			
+			
+			//insert into the database
+			String sql = "insert into message(uuid, type, message) values(?,?,?)";
+			ps = conn.prepareStatement(sql);
+			ps.setString(1, uid.toString());
+			ps.setString(2, message.getType().toString());
+			ps.setString(3, messageString);
+			ps.execute();			
+			
+		} catch (Exception e) {	e.printStackTrace(); }		
+		finally { release(); }
+		
+		return uid;
+	}
+
+	public synchronized Message getMessage(URI uid) throws Exception{		
+		
+		String sql = "select uuid,type,message from message where uuid=?";
+		Message message = null;
+			
+		try {			
+			conn = mgr.getConnection();
+			ps = conn.prepareStatement(sql);
+			ps.setString(1, uid.toString());
+			
+			rs = ps.executeQuery();
+			if (! rs.next()) throw new Exception("Non existing Message for UUID: " + uid);
+			
+			message = Util.deserialize((Serializable)Base64.decodeToObject(rs.getString(3)));			
+			
+			
+		} catch (SQLException e) {
+			e.printStackTrace();
+			return null;
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}finally { release(); }		
+		
+		return message;
+		
+	}
+	
+	private void release() {
+		
+		if (conn != null) {
+			if (rs != null) {
+				try{
+					rs.close();
+				}catch (Exception e) {}
+			}
+			try{
+				ps.close();
+			}catch (Exception e1){}
+			try{
+				conn.close();
+			}catch(Exception e2){}			
+		}
+	}
+
+	
+	
+	
+
+
+}

Added: labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStorePlugin.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStorePlugin.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStorePlugin.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,46 @@
+/*
+ * 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 daniel.brum at jboss.com
+ */
+
+package org.jboss.internal.soa.esb.persistence.format.db;
+
+import java.net.URI;
+
+import org.jboss.internal.soa.esb.persistence.format.MessageStorePlugin;
+import org.jboss.soa.esb.services.persistence.MessageStoreType;
+import org.jboss.soa.esb.services.persistence.MessageStore;
+
+/**
+ * @author dbrum
+ *
+ */
+public class DBMessageStorePlugin implements MessageStorePlugin {
+
+	
+	public MessageStore getMessageStore() {
+		return new DBMessageStoreImpl();
+	}
+
+	
+	public URI getType() {
+		return MessageStoreType.DATABASE;
+	}
+
+}

Added: labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/DslHelper.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/DslHelper.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/DslHelper.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -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.internal.soa.esb.services.routing.cbr;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.jboss.soa.esb.message.Message;
+import org.xml.sax.InputSource;
+/**
+ * Domain Specific Language helper. Right now this supports the use of XPath, but this class can
+ * be beefed up upo to use other technologies as well.
+ * 
+ * @author kstam at redhat.com
+ *
+ */
+public class DslHelper 
+{
+	/** XPath instance */
+	private static XPathFactory xpf = XPathFactory.newInstance();
+	/** 
+	 * Uses XPath to look for the occurence of a certain tag, specific in the xpath expression.
+	 * 
+	 * @param message - the ESB Message which body content will be used.
+	 * @param xpathExp - XPath expression to find a node.
+	 * @return true if the node is found and false in all other cases.
+	 * @throws XPathExpressionException
+	 */
+	public static boolean xmlContentMatches(Message message, String xpathExp) throws XPathExpressionException 
+	{
+		XPath xpath = xpf.newXPath();
+		InputSource inputSource = new InputSource(new ByteArrayInputStream(message.getBody().getContents()));
+		Object node = xpath.evaluate(xpathExp, inputSource, XPathConstants.NODE);
+		return node != null;
+	}
+	/** 
+	 * Uses XPath to look for the occurence of a certain tag, specific in the xpath expression.
+	 * 
+	 * @param message - the ESB Message which body content will be used.
+	 * @param xpathExp - XPath expression to find a node.
+	 * @param value - used to compare against the result found using the XPath expression.
+	 * @return true if equal, false in all other cases.
+	 * @throws XPathExpressionException
+	 */
+	public static boolean xmlContentEquals(Message message, String xpathExp, String value) throws XPathExpressionException 
+	{
+		XPath xpath = xpf.newXPath();
+		InputSource inputSource = new InputSource(new ByteArrayInputStream(message.getBody().getContents()));
+		String node = (String) xpath.evaluate(xpathExp, inputSource, XPathConstants.STRING);
+		return value.equals(node);
+	}
+}
+	

Added: labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouter.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouter.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouter.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,147 @@
+/*
+* 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.internal.soa.esb.services.routing.cbr;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.drools.FactHandle;
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.WorkingMemory;
+import org.drools.compiler.PackageBuilder;
+import org.drools.rule.Package;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.routing.MessageRouter;
+import org.jboss.soa.esb.services.routing.cbr.ContentBasedRouter;
+
+/**
+ * The Implementation of a rule based Content Router. Here we use JBossRules.
+ * We keep a HashMap of so called working memories for performance reasons.
+ * 
+ * @author kstam at redhat.com
+ *
+ */
+public class JBossRulesRouter extends ContentBasedRouter 
+{
+	private static Map<String,WorkingMemory> workingMemories=new ConcurrentHashMap<String,WorkingMemory>();
+	private static Logger logger = Logger.getLogger(JBossRulesRouter.class);
+	/**
+	 * Route the message, where the routing rules are supplied as part of
+	 * the message itself. We don't support this yet, as I don't see
+	 * the need right now. However when the need arises, this is were it
+	 * goes.
+	 * @param message - Message that needs routing.
+	 */
+	public List<String> route(Message message){
+		logger.log(Priority.ERROR, "Do not use, this is not implemented");
+			//Route to /dev/null?
+		return null;
+	}
+	/**
+	 * Route the message, using the given ruleSet (drl).
+	 * 
+	 * @param ruleSet - Filename of the drl that will be used.
+	 * @param message - Message that needs routing.
+	 */
+    public List<String> route(String ruleSet, Message message) {
+    	return route(ruleSet, null, message);
+    }
+	/**
+	 * Route the message, where the routing rules are supplied as part of
+	 * the message itself. We don't support this yet, as I don't see
+	 * the need right now. However when the need arises, this is were it
+	 * goes.
+	 * 
+	 * @param ruleSet      - Filename of the drl that will be used.
+	 * @param ruleLanguage - Filename of the dsl that will be used.
+	 * @param message      - Message that needs routing.
+	 */
+	@SuppressWarnings("unchecked")
+	public List<String> route(String ruleSet, String ruleLanguage, Message message) 
+	{
+		List<String> destinationServices = new ArrayList<String>();
+		try {
+			WorkingMemory workingMemory = workingMemories.get(ruleSet);
+			if (workingMemory==null) {
+			    logger.log(Priority.INFO, "Reading ruleSet from file=" + ruleSet);
+				RuleBase ruleBase = readRuleBase(ruleSet, ruleLanguage);
+				workingMemory = ruleBase.newWorkingMemory();
+				workingMemories.put(ruleSet, workingMemory);
+			}
+			logger.log(Priority.DEBUG, "Obtained message=" + message + " with ruleSet=" + ruleSet);
+			synchronized(workingMemory) {
+				workingMemory.setGlobal("destinationServices", destinationServices);
+				FactHandle factHandle = workingMemory.assertObject(message);
+				logger.log(Priority.INFO, "Fire the JBossRules Engine");
+				workingMemory.fireAllRules();
+				workingMemory.retractObject(factHandle);
+			}
+			destinationServices = (List) workingMemory.getGlobal("destinationServices");
+			logger.log(Priority.DEBUG, "Destination Services List: " + destinationServices);
+			Boolean isDeliverMessages = (Boolean) message.getProperties().getProperty(MessageRouter.DELIVER_MESSAGES);
+			//Deliver the message to their desitinations unless told not to.
+			if (!Boolean.FALSE.equals(isDeliverMessages)) {
+				deliverMessages(destinationServices, message);
+			}
+		} catch (Exception e) {
+			logger.log(Priority.ERROR, e.getMessage() + ". Message is not routed.", e);
+			//Route to /dev/null?
+		}
+		return destinationServices;
+	}
+	
+    /**
+     * Reading the rules and dsl from files. Note that we may want to allow other ways to 
+     * set the rule, but for now it's just files.
+     */
+	private static RuleBase readRuleBase(String rulesFile, String ruleLanguage) throws Exception
+	{
+		//read in the rules
+		logger.info("Going to read the rule: " + rulesFile);
+		InputStream inputStreamDrl = JBossRulesRouter.class.getResourceAsStream( "/" + rulesFile );
+		Reader rules = new InputStreamReader(inputStreamDrl);
+		PackageBuilder builder = new PackageBuilder();
+		//this wil parse and compile in one step
+		if (ruleLanguage==null) {
+			builder.addPackageFromDrl(rules);
+		} else {
+			logger.info("Going to read the language: " + ruleLanguage);
+			InputStream inputStreamDsl = JBossRulesRouter.class.getResourceAsStream( "/" + ruleLanguage );
+			Reader dsl = new InputStreamReader(inputStreamDsl);
+			builder.addPackageFromDrl(rules, dsl);
+		}
+		//get the compiled package (which is serializable)
+		Package pkg = builder.getPackage();
+		//add the package to a rulebase (deploy the rule package).
+		RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+		ruleBase.addPackage(pkg);
+		return ruleBase;
+	}
+}

Added: labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRouter.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRouter.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRouter.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,54 @@
+/*
+ * 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.services.routing.cbr;
+
+import java.util.List;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.routing.MessageRouter;
+
+/**
+ * Content Based Router Interface.
+ * 
+ * @author kurt.stam at redhat.com
+ *
+ */
+public abstract class ContentBasedRouter extends MessageRouter {
+	/**
+	 * Route a message using a certain ruleSet wich and reference a custom
+	 * Domain Specific Language (DSL).
+	 * 
+	 * @param ruleSet      - String reference to a file which contains a ruleSet.
+	 * @param ruleLanguage - String reference to a file which contais a custom rule language definition
+	 * @param message      - Message that needs routing.
+	 * @return
+	 */
+	public abstract List<String> route(String ruleSet, String ruleLanguage, Message message);
+	/**
+	 * Route a message using a certain ruleSet.
+	 * 
+	 * @param ruleSet      - String reference to a file which contains a ruleSet.
+	 * @param message      - Message that needs routing.
+	 * @return
+	 */
+	public abstract List<String> route(String ruleSet, Message message);
+}

Added: labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRouterFactory.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRouterFactory.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/services/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRouterFactory.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,56 @@
+/*
+* 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.services.routing.cbr;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.common.Factory;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+/**
+ * Returns an instance of the Registry.
+ * 
+ * @author kurt.stam at redhat.com
+ *
+ */
+public class ContentBasedRouterFactory extends Factory 
+{
+	private static Logger logger = Logger.getLogger(ContentBasedRouterFactory.class);
+	
+	public static ContentBasedRouter getRouter() throws MessageRouterException
+	{
+		ContentBasedRouter cbr = null;
+		String className = Configuration.getContentBasedRouterImplementationClass();
+		logger.log(Priority.INFO, "Going to load " + className);
+		try {
+			// instruct class loader to load the Content Based  Router Implementation
+			Class cbrClass = getClassForName(className);
+			// Try to get an instance of the CBR
+			cbr = (ContentBasedRouter) cbrClass.newInstance();
+		} catch (ClassNotFoundException cnfex) {
+			throw new MessageRouterException("Content Based Router Implementation=" + className + " not found", cnfex);
+		} catch (Exception e) {
+			throw new MessageRouterException(className + " invokation problem. " + e.getLocalizedMessage(), e);
+		}
+		return cbr;
+	}
+}

Added: labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryUnitTest.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryUnitTest.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryUnitTest.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,282 @@
+/*
+* 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.internal.soa.esb.services.registry;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URLDecoder;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+
+import javax.xml.registry.BulkResponse;
+import javax.xml.registry.BusinessLifeCycleManager;
+import javax.xml.registry.BusinessQueryManager;
+import javax.xml.registry.Connection;
+import javax.xml.registry.JAXRException;
+import javax.xml.registry.RegistryService;
+import javax.xml.registry.infomodel.Classification;
+import javax.xml.registry.infomodel.ClassificationScheme;
+import javax.xml.registry.infomodel.Organization;
+import javax.xml.registry.infomodel.Service;
+import javax.xml.registry.infomodel.ServiceBinding;
+import javax.xml.registry.infomodel.User;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.testutils.FileUtil;
+import org.jboss.soa.esb.testutils.HsqldbUtil;
+import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Testing the registry.
+ * 
+ * @author kstam
+ *
+ */
+public class JAXRRegistryUnitTest
+{
+	private static Logger logger = Logger.getLogger(JAXRRegistryUnitTest.class);
+    private static String mDbDriver;
+	private static String mDbUrl;
+	private static String mDbUsername;
+	private static String mDbPassword;
+	/**
+	 * Tests the successful creation of the RED HAT/JBossESB Organization.
+	 */
+	@Test
+	public void publishOrganization() 
+	{
+		try {
+			Organization org = JAXRRegistryImpl.createJBossESBOrganization();
+			logger.log(Priority.INFO, "Succesfully created organization: " + org.getName().getValue());
+			assertEquals("Red Hat/JBossESB", org.getName().getValue());
+		} catch (JAXRException je) {
+			logger.log(Priority.ERROR, je.getLocalizedMessage(), je);
+			assertTrue(false);
+		}
+	}
+	@Test
+	public void findOrganization() 
+	{
+		try {
+			Organization org = JAXRRegistryImpl.findOrganization("Red Hat/JBossESB");
+			logger.log(Priority.INFO, "Succesfully created organization: " + org.getName().getValue());
+			assertEquals("Red Hat/JBossESB", org.getName().getValue());
+		} catch (JAXRException je) {
+			logger.log(Priority.ERROR, je.getLocalizedMessage(), je);
+			assertTrue(false);
+		}
+		try {
+			Organization org = JAXRRegistryImpl.findOrganization("Not Existing Org");
+			logger.log(Priority.INFO, "Could not find non-existing organization.");
+			assertEquals(null, org);
+		} catch (JAXRException je) {
+			logger.log(Priority.ERROR, je.getLocalizedMessage(), je);
+			assertTrue(false);
+		}
+	}
+	/**
+	 * Tests the successful registration of a Service.
+	 *
+	 */
+	@Test
+	public void publishService()
+	{
+		try {
+			JAXRRegistryImpl registry = new JAXRRegistryImpl();
+			registry.registerService("registry", "Registry Test ServiceName", "Registry Test Service Description");
+		} catch (JAXRException je) {
+			logger.log(Priority.ERROR, je.getLocalizedMessage(), je);
+			assertTrue(false);
+		}
+	}
+	@Test
+	public void publishServiceBinding()
+	{
+		try {
+			EPR epr = new EPR();
+			JAXRRegistryImpl registry = new JAXRRegistryImpl();
+			registry.registerEPR("registry", "Registry Test ServiceName", "Registry Test Service Description",
+					epr, "EPR description");
+		} catch (RegistryException re) {
+			logger.log(Priority.ERROR, re.getLocalizedMessage(), re);
+			assertTrue(false);
+		}
+	}
+	/**
+	 * Queries the newly added information
+	 * @throws Exception
+	 */
+	@Test
+	public void findServicesForAnOrganization()
+    {
+		try {
+			Organization org = JAXRRegistryImpl.findOrganization("Red Hat/JBossESB");
+			//Listing out the services and their Bindings
+			logger.log(Priority.INFO, "-------------------------------------------------");
+			logger.log(Priority.INFO, "Organization name: " + org.getName().getValue());
+			logger.log(Priority.INFO, "Description: " + org.getDescription().getValue());
+			logger.log(Priority.INFO, "Key id: " + org.getKey().getId());
+			User primaryContact = org.getPrimaryContact();
+			logger.log(Priority.INFO, "Primary Contact: " + primaryContact.getPersonName().getFullName());
+			Collection services = org.getServices();
+			for (Iterator serviceIter = services.iterator();serviceIter.hasNext();) {
+				Service service = (Service) serviceIter.next();
+				logger.log(Priority.INFO, "- Service Name: " + service.getName().getValue());
+				logger.log(Priority.INFO, "  Service Key : " + service.getKey().getId());
+				Collection serviceBindings = service.getServiceBindings();
+				for (Iterator serviceBindingIter = serviceBindings.iterator();serviceBindingIter.hasNext();){
+					ServiceBinding serviceBinding = (ServiceBinding) serviceBindingIter.next();
+					logger.log(Priority.INFO, "  ServiceBinding Description: " + serviceBinding.getDescription().getValue());
+					String xml = URLDecoder.decode(serviceBinding.getAccessURI(),"UTF-8");
+					logger.log(Priority.INFO, "  ServiceBinding URI: " + xml);
+					assertEquals(EPRHelper.toXMLString(new EPR()),xml);
+				}
+			}
+			logger.log(Priority.INFO, "-------------------------------------------------");
+	    } catch (Exception je) {
+			je.printStackTrace();
+			assertTrue(false);
+		}
+    }
+	/**
+	 * This doesn't work because scout drops the classifications on the floor.
+	 * We're ignoring this test until I come up with a patch.
+	 *
+	 */
+	public void findServicesByClassification()
+	{
+		Connection connection = JAXRRegistryImpl.getConnection();
+		try {
+			// Get registry service and business query manager
+			RegistryService rs = connection.getRegistryService();
+			BusinessQueryManager bqm = rs.getBusinessQueryManager();
+			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+			ClassificationScheme classificationScheme = bqm.findClassificationSchemeByName(null, "uddi-org:general_keywords");
+			Classification classification = blm.createClassification(classificationScheme,
+					"Test transformation service", "transformation");
+			Collection<Classification> classifications = new ArrayList<Classification>();
+			classifications.add(classification);
+			//Here I'd like to test filtering by this classification, but scout ignored the classification
+			String name=classificationScheme.getName().getValue();
+			System.out.println("Name=" + name);
+			Collection<String> nameParams = new ArrayList<String>();
+			//The name of the service is wild
+			nameParams.add("%");
+			BulkResponse bs = bqm.findServices(null, null,nameParams,classifications, null);
+			int status = bs.getStatus();
+			System.out.println("status=" + status);
+		} catch (JAXRException je) {
+			je.printStackTrace();
+		}
+		finally{}
+	}
+	/**
+	 * Setup the database.
+	 * @throws Exception
+	 */
+	@BeforeClass
+	public static void runBeforeAllTests() throws Exception {
+		try {
+			DOMConfigurator.configure(TestEnvironmentUtil.getUserDir() + "etc/test/resources/log4j.xml");
+			TestEnvironmentUtil.setESBPropertiesFileToUse();
+			//Set the juddi properties file in System so juddi will pick it up later and use the test values.
+			String juddiPropertiesFile = "/org/jboss/soa/esb/services/registry/juddi-unittest.properties";
+			System.setProperty("juddi.propertiesFile", juddiPropertiesFile);
+			//Read this properties file to get the db connection string
+			Properties props = new Properties();
+			InputStream inStream = Class.class.getResourceAsStream(juddiPropertiesFile);
+			props.load(inStream);
+			mDbDriver    = props.getProperty("juddi.jdbcDriver");
+			mDbUrl       = props.getProperty("juddi.jdbcUrl");
+			mDbUsername  = props.getProperty("juddi.jdbcUsername");
+			mDbPassword  = props.getProperty("juddi.jdbcPassword");
+			
+			String database="not tested yet";
+			if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
+				database = "hsqldb";
+				//Bring up hsql on default port 9001
+				HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir() + "build/hsqltestdb", "juddi");
+			} else if ("com.mysql.jdbc.Driver".equals(mDbDriver)) {
+				database = "mysql";
+			} //add and test your own database..
+			
+			//Get the registry-schema create scripts
+			String sqlDir = TestEnvironmentUtil.getUserDir() + "install/jUDDI-registry/sql/" + database + "/";
+			//Drop what is there now, if exists. We want to start fresh.
+			String sqlDropCmd      = FileUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
+			String sqlCreateCmd    = FileUtil.readTextFile(new File(sqlDir + "create_database.sql"));
+			String sqlInsertPubCmd = FileUtil.readTextFile(new File(sqlDir + "insert_publishers.sql"));
+			
+			try {
+				Class.forName(mDbDriver);
+			} catch (Exception e) {
+				System.out.println("ERROR: failed to load " + database + " JDBC driver.");
+				e.printStackTrace();
+				return;
+			}
+			java.sql.Connection con = DriverManager.getConnection(mDbUrl, mDbUsername, mDbPassword);
+			Statement stmnt = con.createStatement();
+			System.out.println("Dropping the schema if exist");
+			stmnt.execute(sqlDropCmd);
+			System.out.println("Creating the juddi-schema");
+			stmnt.execute(sqlCreateCmd);
+			System.out.println("Adding the jbossesb publisher");
+			stmnt.execute(sqlInsertPubCmd);
+		} catch (Exception e) {
+			e.printStackTrace();
+			System.out.println("We should stop testing, since we don't have a db.");
+			assertTrue(false);
+		}
+	}
+	/**
+	 * Shutdown the database
+	 * @throws Exception
+	 */
+	@AfterClass
+	public static void runAfterAllTests() throws Exception {
+		if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
+			HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
+		}
+	}
+
+	public static junit.framework.Test suite() {
+		return new JUnit4TestAdapter(JAXRRegistryUnitTest.class);
+	}
+
+}

Added: labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/internal/soa/esb/services/routing/cbr/JBossRulesRouterUnitTest.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,93 @@
+/*
+ * 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.internal.soa.esb.services.routing.cbr;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.xml.DOMConfigurator;
+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.jboss.soa.esb.testutils.TestEnvironmentUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * 
+ * @author kurt.stam at redhat.com
+ *
+ */
+public class JBossRulesRouterUnitTest
+{
+	@Test
+	public void routeSerializedMessage()
+	{
+        //new messages
+		Message message = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+		//set some properties inside the Message
+		message.getProperties().setProperty("prop1", "val1");
+		message.getProperties().setProperty("prop2", "val2");
+		//set the body inside the Message
+		message.getBody().setContents(("TEST BODY").getBytes());
+		//set some object attachments inside the Message
+		message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
+		message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
+		
+		JBossRulesRouter jbossRulesRouter = new JBossRulesRouter();
+		List<String> destinationServices = jbossRulesRouter.route("JBossESBRules.drl", message);
+		assertEquals(destinationServices.iterator().next(),"test_category:Serialized_ServiceDestination");
+	}
+	
+	@Test
+	public void routeXMLMessage()
+	{
+		//add new messages
+		Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+		//set some properties inside the Message
+		message.getProperties().setProperty("prop1", "val1");
+		message.getProperties().setProperty("prop2", "val2");
+		//set the body inside the Message
+		message.getBody().setContents(("TEST BODY").getBytes());
+		//set some object attachments inside the Message
+		message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
+		message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
+	
+		JBossRulesRouter jbossRulesRouter = new JBossRulesRouter();
+		List<String> destinationServices = jbossRulesRouter.route("JBossESBRules.drl", message);
+		assertEquals(destinationServices.iterator().next(),"test_category:JBOSS_XMLDestination");
+	}
+	
+	@BeforeClass
+	public static void runBeforeAllTests() throws Exception 
+	{
+		DOMConfigurator.configure(TestEnvironmentUtil.getUserDir() + "etc/test/resources/log4j.xml");
+	}
+	
+	public static junit.framework.Test suite() {
+		return new JUnit4TestAdapter(JBossRulesRouterUnitTest.class);
+	}
+
+}

Added: labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRoutingUnitTest.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRoutingUnitTest.java	2006-11-16 10:31:58 UTC (rev 7637)
+++ labs/jbossesb/workspace/b_georges/product/core/services/tests/src/org/jboss/soa/esb/services/routing/cbr/ContentBasedRoutingUnitTest.java	2006-11-16 11:00:17 UTC (rev 7638)
@@ -0,0 +1,155 @@
+/*
+ * 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.services.routing.cbr;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.xml.DOMConfigurator;
+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.jboss.soa.esb.services.routing.MessageRouter;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+/**
+ * 
+ * @author kurt.stam at redhat.com
+ *
+ */
+public class ContentBasedRoutingUnitTest
+{
+	@Test
+	public void routeSerializedMessage()
+	{
+		try {
+            //new messages
+			Message message = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+			//set some properties inside the Message
+			message.getProperties().setProperty("prop1", "val1");
+			message.getProperties().setProperty("prop2", "val2");
+			//set the body inside the Message
+			message.getBody().setContents(("TEST BODY").getBytes());
+			//set some object attachments inside the Message
+			message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
+			message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
+			message.getProperties().setProperty(MessageRouter.DELIVER_MESSAGES, Boolean.FALSE);
+			
+			ContentBasedRouter cbr = ContentBasedRouterFactory.getRouter();
+			List<String> destinationServices = cbr.route("JBossESBRules.drl",message);
+			assertEquals(destinationServices.iterator().next(),"test_category:Serialized_ServiceDestination");
+		} catch (MessageRouterException e) {
+			e.printStackTrace();
+			assertTrue(false);
+		}
+	}
+	
+	@Test
+	public void routeXMLMessage()
+	{
+		try {
+			//add new messages
+			Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+			//set some properties inside the Message
+			message.getProperties().setProperty("prop1", "val1");
+			message.getProperties().setProperty("prop2", "val2");
+			//set the body inside the Message
+			message.getBody().setContents(("TEST BODY").getBytes());
+			//set some object attachments inside the Message
+			message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
+			message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
+			message.getProperties().setProperty(MessageRouter.DELIVER_MESSAGES, Boolean.FALSE);
+		
+			ContentBasedRouter cbr = ContentBasedRouterFactory.getRouter();
+			List<String> destinationServices = cbr.route("JBossESBRules.drl",message);
+			assertEquals(destinationServices.iterator().next(),"test_category:JBOSS_XMLDestination");
+		} catch (MessageRouterException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	@Test
+	public void routeXMLMessageUsingXPathMatch()
+	{
+		try {
+			//add new messages
+			Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+			//set some properties inside the Message
+			message.getProperties().setProperty("prop1", "val1");
+			message.getProperties().setProperty("prop2", "val2");
+			//set the body inside the Message
+			message.getBody().setContents(("<jbossesb>TEST BODY</jbossesb>").getBytes());
+			//set some object attachments inside the Message
+			message.getAttachment().addItem(new String("TEST ATTACHMENT1"));
+			message.getAttachment().addItem(new String("TEST ATTACHMENT2"));
+			message.getProperties().setProperty(MessageRouter.DELIVER_MESSAGES, Boolean.FALSE);
+		
+			ContentBasedRouter cbr = ContentBasedRouterFactory.getRouter();
+			List<String> destinationServices = cbr.route("JBossESBRules-XPath.drl","XPathLanguage.dsl",message);
+			assertEquals(destinationServices.iterator().next(),"test_category:JBOSS_XML_XPath_Destination");
+		} catch (MessageRouterException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	@Test
+	public void routeXMLMessageUsingXPathEquals()
+	{
+		try {
+			//add new messages
+			Message message = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+			//set the body inside the Message
+			message.getBody().setContents(("<Dave>rocks</Dave>").getBytes());
+			message.getProperties().setProperty(MessageRouter.DELIVER_MESSAGES, Boolean.FALSE);
+		
+			ContentBasedRouter cbr = ContentBasedRouterFactory.getRouter();
+			List<String> destinationServices = cbr.route("JBossESBRules-XPath.drl","XPathLanguage.dsl",message);
+			assertEquals(destinationServices.iterator().next(),"test_category:JBOSS_XML_XPath_Dave_Destination");
+		} catch (MessageRouterException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	@BeforeClass
+	public static void runBeforeAllTests() throws Exception 
+	{
+		try {
+			DOMConfigurator.configure(TestEnvironmentUtil.getUserDir() + "etc/test/resources/log4j.xml");
+			TestEnvironmentUtil.setESBPropertiesFileToUse();
+		} catch (Exception e) {
+			e.printStackTrace();
+			System.out.println("We should stop testing, since we don't any config properties");
+			assertTrue(false);
+		}
+	}
+	
+	public static junit.framework.Test suite() {
+		return new JUnit4TestAdapter(ContentBasedRoutingUnitTest.class);
+	}
+	
+}




More information about the jboss-svn-commits mailing list