[jboss-svn-commits] JBL Code SVN: r7513 - in labs/jbossesb/trunk/product/core/rosetta/src/org/jboss: internal/soa/esb/couriers soa/esb/couriers
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Nov 9 13:41:34 EST 2006
Author: kurt.stam at jboss.com
Date: 2006-11-09 13:41:32 -0500 (Thu, 09 Nov 2006)
New Revision: 7513
Modified:
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourier.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java
Log:
adding javadoc
Modified: 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-09 18:22:37 UTC (rev 7512)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourier.java 2006-11-09 18:41:32 UTC (rev 7513)
@@ -28,97 +28,136 @@
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);
- } //________________________________
-
- public void setToEpr(EPR epr) throws CourierException
+ }
+ /**
+ * @see org.jboss.soa.esb.couriers.Courier#setToEpr(toEPR).
+ */
+ public void setToEpr(EPR toEPR) throws CourierException
{
- DeliverCourier old = _outgoing;
- _outgoing = getDeliverCourier(epr);
+ DeliverCourier old = _deliverCourier;
+ _deliverCourier = getDeliverCourier(toEPR);
if (null!=old)
old.cleanup();
- } //________________________________
-
- public void setReplyToEpr(EPR epr) throws CourierException
+ }
+ /**
+ * @see org.jboss.soa.esb.couriers.Courier#setReplyEpr(toReplyEPR).
+ */
+ public void setReplyToEpr(EPR replyToEPR) throws CourierException
{
- PickUpCourier old = _incoming;
- _incoming = getPickupCourier(epr);
+ PickUpCourier old = _pickupCourier;
+ _pickupCourier = getPickupCourier(replyToEPR);
if (null!=old)
old.cleanup();
- } //________________________________
-
- protected DeliverCourier getDeliverCourier(EPR epr) throws CourierException
+ }
+ /**
+ * @see org.jboss.soa.esb.couriers.Courier#getDeliverCourier(EPR toEPR).
+ */
+ private DeliverCourier getDeliverCourier(EPR toEPR) throws CourierException
{
- if (null==epr)
+ if (null==toEPR)
return null;
- if (epr instanceof JMSEpr)
- return new JmsCourier((JMSEpr)epr);
- throw new CourierException ("Couriers for "+epr.getClass().getSimpleName()+" not supported yet");
- } //________________________________
-
- protected PickUpCourier getPickupCourier(EPR epr) throws CourierException
+ 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==epr)
+ if (null==replyToEPR)
return null;
- if (epr instanceof JMSEpr)
- return new JmsCourier((JMSEpr)epr,true);
- throw new CourierException ("Couriers for "+epr.getClass().getSimpleName()+" not supported yet");
- } //________________________________
-
+ 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 = deliverNext(message);
- stopDurableDelivery();
+ 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==_outgoing)
+ if (null==_deliverCourier)
throw new CourierException("No outgoing EPR was provided at construction time");
- return _outgoing.deliver(message);
- } //________________________________
-
+ return _deliverCourier.deliver(message);
+ }
+ /**
+ * @see org.jboss.soa.esb.couriers.Courier#pickup(long waitTime).
+ */
public Message pickup(long waitTime) throws CourierException, CourierTimeoutException
- {
- Message mess = pickupNext(waitTime);
- _incoming.cleanup();
- return mess;
- } //________________________________
-
+ {
+ Message replyMessage = null;
+ try {
+ replyMessage = pickupNext(waitTime);
+ } finally {
+ _pickupCourier.cleanup();
+ }
+ return replyMessage;
+ }
+ /**
+ * @see org.jboss.soa.esb.couriers.Courier#pickupNext(long waitTime).
+ */
public Message pickupNext(long waitTime) throws CourierException, CourierTimeoutException
{
- if (null==_incoming)
- throw new CourierException("No imcoming EPR was provided at construction time");
- return _incoming.pickUp(waitTime);
- } //________________________________
-
+ 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!=_outgoing)
- _outgoing.cleanup();
- } //________________________________
-
+ if (null!=_deliverCourier)
+ _deliverCourier.cleanup();
+ }
+ /**
+ * @see org.jboss.soa.esb.couriers.Courier#stopDurablePickup().
+ */
public void stopDurablePickup()
{
- if (null!=_incoming)
- _incoming.cleanup();
- } //________________________________
-
- protected DeliverCourier _outgoing;
- protected PickUpCourier _incoming;
-
+ if (null!=_pickupCourier)
+ _pickupCourier.cleanup();
+ }
}
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-09 18:22:37 UTC (rev 7512)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java 2006-11-09 18:41:32 UTC (rev 7513)
@@ -22,6 +22,7 @@
package org.jboss.soa.esb.couriers;
+import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.message.Message;
/**
* Courier interface. Deals relatively low level Message transport options.
@@ -92,4 +93,20 @@
* 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;
+
}
More information about the jboss-svn-commits
mailing list