[jboss-svn-commits] JBL Code SVN: r7612 - in labs/jbossesb/trunk/product/core: listeners/src/org/jboss/soa/esb/actions rosetta/src/org/jboss/internal/soa/esb/couriers rosetta/src/org/jboss/soa/esb/couriers

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Nov 15 05:57:42 EST 2006


Author: estebanschifman
Date: 2006-11-15 05:57:33 -0500 (Wed, 15 Nov 2006)
New Revision: 7612

Added:
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverOnlyCourier.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpOnlyCourier.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/TwoWayCourier.java
Removed:
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverCourier.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpCourier.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourier.java
Modified:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/CbrProxyAction.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java
Log:
Rename courier interfaces and re shuffle methods around

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/CbrProxyAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/CbrProxyAction.java	2006-11-15 09:59:15 UTC (rev 7611)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/CbrProxyAction.java	2006-11-15 10:57:33 UTC (rev 7612)
@@ -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();

Deleted: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverCourier.java	2006-11-15 09:59:15 UTC (rev 7611)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverCourier.java	2006-11-15 10:57:33 UTC (rev 7612)
@@ -1,32 +0,0 @@
-/*
- * 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 DeliverCourier 
-{
-	public boolean	deliver(Message message) throws CourierException;
-	public void		stopDurableDelivery();
-}

Copied: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverOnlyCourier.java (from rev 7611, labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverCourier.java)
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverCourier.java	2006-11-15 09:59:15 UTC (rev 7611)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverOnlyCourier.java	2006-11-15 10:57:33 UTC (rev 7612)
@@ -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;
+}

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2006-11-15 09:59:15 UTC (rev 7611)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2006-11-15 10:57:33 UTC (rev 7612)
@@ -52,7 +52,7 @@
 import org.jboss.soa.esb.util.Util;
 import org.xml.sax.SAXException;
 
-public class JmsCourier implements PickUpCourier, DeliverCourier 
+public class JmsCourier implements PickUpOnlyCourier, DeliverOnlyCourier 
 {
 	/**
 	 * disable default constructor
@@ -81,7 +81,7 @@
 		
     } //________________________________
 
-	private void cleanup() 
+	void cleanup() 
 	{
 		if (null != _messageProducer)
 			try { _messageProducer.close(); }
@@ -334,11 +334,4 @@
     protected MessageConsumer	_messageConsumer;
     protected List<KeyValuePair> _messageProperties;
 
-	public void stopDurablePickup() {
-		cleanup();
-	}
-
-	public void stopDurableDelivery() {
-		cleanup();
-	}
 }

Deleted: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpCourier.java	2006-11-15 09:59:15 UTC (rev 7611)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpCourier.java	2006-11-15 10:57:33 UTC (rev 7612)
@@ -1,37 +0,0 @@
-/*
- * 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 PickUpCourier 
-{
-	public Message	pickup(long millis) throws CourierException, CourierTimeoutException;
-	public void		stopDurablePickup();
-}

Copied: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpOnlyCourier.java (from rev 7611, labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpCourier.java)
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpCourier.java	2006-11-15 09:59:15 UTC (rev 7611)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpOnlyCourier.java	2006-11-15 10:57:33 UTC (rev 7612)
@@ -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;
+}

Deleted: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourier.java	2006-11-15 09:59:15 UTC (rev 7611)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourier.java	2006-11-15 10:57:33 UTC (rev 7612)
@@ -1,163 +0,0 @@
-/*
- * 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.addressing.EPR;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
-import org.jboss.soa.esb.couriers.Courier;
-import org.jboss.soa.esb.couriers.CourierException;
-import org.jboss.soa.esb.couriers.CourierTimeoutException;
-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 TwoWayCourier implements Courier
-{
-	private DeliverCourier	_deliverCourier;
-	private PickUpCourier	_pickupCourier;
-	/**
-	 * Constructor. 
-	 * @param toEpr             - to address
-	 * @param replyToEpr        - reply to address
-	 * @throws CourierException
-	 */
-	public TwoWayCourier(EPR toEpr, EPR replyToEpr) throws CourierException
-	{
-		setToEpr		(toEpr);
-		setReplyToEpr	(replyToEpr);
-	}
-	/**
-	 * @see  org.jboss.soa.esb.couriers.Courier#setToEpr(toEPR).
-	 */
-	public void setToEpr(EPR toEPR) throws CourierException
-	{
-		DeliverCourier old = _deliverCourier;
-		_deliverCourier	= getDeliverCourier(toEPR);
-		if (null!=old)
-			old.stopDurableDelivery();
-	}
-	/**
-	 * @see  org.jboss.soa.esb.couriers.Courier#setReplyEpr(toReplyEPR).
-	 */
-	public void setReplyToEpr(EPR replyToEPR) throws CourierException
-	{
-		PickUpCourier old = _pickupCourier;
-		_pickupCourier	= getPickupCourier(replyToEPR);
-		if (null!=old)
-			old.stopDurablePickup();
-	}
-	/**
-	 * @see  org.jboss.soa.esb.couriers.Courier#getDeliverCourier(EPR toEPR).
-	 */
-	private DeliverCourier getDeliverCourier(EPR toEPR) throws CourierException
-	{
-		if (null==toEPR)
-			return null;
-		if (toEPR instanceof JMSEpr)
-			return new JmsCourier((JMSEpr)toEPR);
-		throw new CourierException ("Couriers for "+toEPR.getClass().getSimpleName()+" not supported yet");
-	}
-	/**
-	 * @see  org.jboss.soa.esb.couriers.Courier#getPickupCourier(EPR replyToEPR).
-	 */
-	private PickUpCourier 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 {
-			bRet = deliverNext(message);
-		} finally {
-			stopDurableDelivery();
-		}
-		return bRet;
-	}
-	/**
-	 * @see  org.jboss.soa.esb.couriers.Courier#deliverAndWaitForPickup(Message message, long waitTime).
-	 */
-	public Message deliverAndWaitForPickup(Message message, long waitTime) throws CourierException, CourierTimeoutException 
-	{
-		if (!deliver(message))
-			throw new CourierException("Unable to deliver Message");
-		return pickup(waitTime);
-	}
-	/**
-	 * @see  org.jboss.soa.esb.couriers.Courier#deliverNext(Message message).
-	 */
-	public boolean deliverNext(Message message) throws CourierException 
-	{
-		if (null==_deliverCourier)
-			throw new CourierException("No outgoing EPR was provided at construction time");
-		return _deliverCourier.deliver(message);
-	}
-	/**
-	 * @see  org.jboss.soa.esb.couriers.Courier#pickup(long waitTime).
-	 */
-	public Message pickup(long waitTime) throws CourierException, CourierTimeoutException 
-	{	
-		Message replyMessage = null;
-		try {
-			replyMessage = pickupNext(waitTime);
-		} finally {
-			_pickupCourier.stopDurablePickup();
-		}
-		return replyMessage;
-	}
-	/**
-	 * @see  org.jboss.soa.esb.couriers.Courier#pickupNext(long waitTime).
-	 */
-	public Message pickupNext(long waitTime) throws CourierException, CourierTimeoutException 
-	{
-		if (null==_pickupCourier)
-			throw new CourierException("No replyToEPR was provided at construction time");
-		return _pickupCourier.pickup(waitTime);
-	}
-	/**
-	 * @see  org.jboss.soa.esb.couriers.Courier#stopDurableDelivery().
-	 */
-	public void stopDurableDelivery() 
-	{
-		if (null!=_deliverCourier)
-			_deliverCourier.stopDurableDelivery();
-	}
-	/**
-	 * @see  org.jboss.soa.esb.couriers.Courier#stopDurablePickup().
-	 */
-	public void stopDurablePickup() 
-	{
-		if (null!=_pickupCourier)
-			_pickupCourier.stopDurablePickup();
-	}
-}

Copied: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java (from rev 7599, labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourier.java)
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourier.java	2006-11-14 20:30:34 UTC (rev 7599)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java	2006-11-15 10:57:33 UTC (rev 7612)
@@ -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  */ }
+	}
+}

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java	2006-11-15 09:59:15 UTC (rev 7611)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java	2006-11-15 10:57:33 UTC (rev 7612)
@@ -22,9 +22,6 @@
 
 package org.jboss.soa.esb.couriers;
 
-import org.jboss.internal.soa.esb.couriers.DeliverCourier;
-import org.jboss.internal.soa.esb.couriers.PickUpCourier;
-import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.message.Message;
 /**
  * Courier interface. Deals relatively low level Message transport options.
@@ -33,7 +30,7 @@
  * @author kstam at redhat.com
  *
  */
-public interface Courier extends DeliverCourier, PickUpCourier
+public interface Courier
 {
 	/**
 	 * Try to deliver an ESB message. This is a one shot delivery.
@@ -43,72 +40,4 @@
 	 * @throws CourierException - if problems were encountered
 	 */
 	public boolean deliver(Message message) throws CourierException;
-	/**
-	 * Engage in a durable delivery contract if it isn't in place already and try to deliver 
-	 * an ESB message.
-	 * 
-	 * @param message Message - the message to deliver 
-	 * @return boolean - the result of the delivery
-	 * @throws CourierException - if problems were encountered
-	 */
-	public boolean deliverNext(Message message) throws CourierException;
-	/**
-	 * Waits for a certain amount of time (waitTime) at an address (EPR) to pick up a message.
-	 * 
-	 * @param message Message - the message to deliver.
-	 * @param waitTime        - Timeout for before giving up in millis.
-	 * @return                - the (reply)Message.
-	 * @throws CourierException if the courier fails (i.e. gets a flat tire).
-	 * @throws CourierTimeoutException if the pickup timed out (nobody home).
-	 */
-	public Message deliverAndWaitForPickup(Message message,long waitTime) 
-		throws CourierException, CourierTimeoutException;
-	/**
-	 * This will be replaced by stopPickup().
-	 */	
-	/**
-     * Instruct the courier to go to a certain address (EPR) and wait for a pickup. This
-     * is a one shot pickup.
-     * 
-     * @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;
-    /**
-     * Creates a durable pickup contract if one does not exist and tries to obtain the next message.
-     * 
-     * @param waitTime         - Pickup timeout 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 pickupNext(long waitTime) throws CourierException, CourierTimeoutException;
-	/**
-	 * When you were engaged in a durable pickup, you need to notify the Courier you want to break
-	 * that contract. The courier will no longer stand by to go out for pickup.
-	 */
-	public void stopDurablePickup();
-	/**
-	 * When you were engaged in a durable delivary, you need to notify the Courier you want to break
-	 * that contract. The courier will no longer stand by for delivery.
-	 */
-	public void stopDurableDelivery();
-	/**
-	 * Sets the toEPR. This can be used it 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;
-	
 }

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java	2006-11-15 09:59:15 UTC (rev 7611)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java	2006-11-15 10:57:33 UTC (rev 7612)
@@ -26,7 +26,7 @@
  * @author - kstam at redhat.com
  *
  */
-import org.jboss.internal.soa.esb.couriers.TwoWayCourier;
+import org.jboss.internal.soa.esb.couriers.TwoWayCourierImpl;
 import org.jboss.soa.esb.addressing.EPR;
 
 public class CourierFactory 
@@ -60,7 +60,7 @@
 	 * @return
 	 * @throws CourierException if the specific courier implementation cannot be created.
 	 */
-	public static Courier getPickupCourier(EPR replyToEPR) throws CourierException
+	public static TwoWayCourier getPickupCourier(EPR replyToEPR) throws CourierException
 	{
 		return getCourier(null, replyToEPR);
 	}
@@ -73,8 +73,8 @@
 	 * @return
 	 * @throws CourierException if the specific courier implementation cannot be created.
 	 */
-	public static Courier getCourier(EPR toEPR, EPR replyToEPR) throws CourierException
+	public static TwoWayCourier getCourier(EPR toEPR, EPR replyToEPR) throws CourierException
 	{
-		return new TwoWayCourier(toEPR, replyToEPR);
+		return new TwoWayCourierImpl(toEPR, replyToEPR);
 	}
 }

Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/TwoWayCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/TwoWayCourier.java	2006-11-15 09:59:15 UTC (rev 7611)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/TwoWayCourier.java	2006-11-15 10:57:33 UTC (rev 7612)
@@ -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;
+}




More information about the jboss-svn-commits mailing list