[jboss-svn-commits] JBL Code SVN: r17118 - in labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss: soa/esb/couriers and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Dec 8 16:11:27 EST 2007


Author: mark.little at jboss.com
Date: 2007-12-08 16:11:27 -0500 (Sat, 08 Dec 2007)
New Revision: 17118

Modified:
   labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
   labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InVMCourier.java
   labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
   labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java
   labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java
Log:
minor updates and comments on some things that need checking.

Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java	2007-12-08 20:14:14 UTC (rev 17117)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java	2007-12-08 21:11:27 UTC (rev 17118)
@@ -70,24 +70,24 @@
 	}
 
 	/**
-	 * package protected constructor - Objects of this class should only be
+	 * Objects of this class should only be
 	 * instantiated by internal implementations
 	 * 
 	 * @param epr
 	 */
-	FileCourier(FileEpr epr) throws CourierException, MalformedEPRException
+	public FileCourier(FileEpr epr) throws CourierException, MalformedEPRException
 	{
 		this(epr, false);
 	}
 
 	/**
-	 * package protected constructor - Objects of this class should only be
+	 * Objects of this class should only be
 	 * instantiated by internal implementations
 	 * 
 	 * @param epr
 	 * @param receiverOnly
 	 */
-	FileCourier(FileEpr epr, boolean receiverOnly) throws CourierException, MalformedEPRException
+	public FileCourier(FileEpr epr, boolean receiverOnly) throws CourierException, MalformedEPRException
 	{
 		_receiverOnly = receiverOnly;
 		_epr = epr;

Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InVMCourier.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InVMCourier.java	2007-12-08 20:14:14 UTC (rev 17117)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InVMCourier.java	2007-12-08 21:11:27 UTC (rev 17118)
@@ -32,6 +32,14 @@
 import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
+/*
+ * These need to be treated differently to other couriers or we'll end up with
+ * garbage collection issues. We need to enforce a rule that a sender cannot
+ * send (gets an error) if the server isn't listening. That's straightforward to
+ * do here, but we need to check the impact on the rest of the codebase, since the
+ * other couriers can be used asynchronously of the service lifecycle.
+ */
+
 public class InVMCourier implements PickUpOnlyCourier, DeliverOnlyCourier
 {
 

Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java	2007-12-08 20:14:14 UTC (rev 17117)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java	2007-12-08 21:11:27 UTC (rev 17118)
@@ -54,23 +54,23 @@
 	}
 
 	/**
-	 * package protected constructor - Objects of Courier should only be
+	 * Objects of Courier should only be
 	 * instantiated by the Factory
 	 * 
 	 * @param epr
 	 */
-	SqlTableCourier(JDBCEpr epr) throws CourierException
+	public SqlTableCourier(JDBCEpr epr) throws CourierException
 	{
 		this(epr, false);
 	}
 
 	/**
-	 * package protected constructor - Objects of Courier should only be
+	 * Objects of Courier should only be
 	 * instantiated by the Factory
 	 * 
 	 * @param epr
 	 */
-	SqlTableCourier(JDBCEpr epr, boolean isReceiver) throws CourierException
+	public SqlTableCourier(JDBCEpr epr, boolean isReceiver) throws CourierException
 	{
 		_isReceiver = isReceiver;
 		_epr = epr;

Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java	2007-12-08 20:14:14 UTC (rev 17117)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java	2007-12-08 21:11:27 UTC (rev 17118)
@@ -28,9 +28,6 @@
 
 import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.addressing.MalformedEPRException;
-import org.jboss.soa.esb.addressing.eprs.FileEpr;
-import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
 import org.jboss.soa.esb.couriers.CourierException;
 import org.jboss.soa.esb.couriers.CourierFactory;
 import org.jboss.soa.esb.couriers.CourierTimeoutException;
@@ -43,12 +40,19 @@
 /**
  * A two-way-courier can perform message deliveries and pickups.
  * 
+ * Note, in the past this played some of a factory role as well. However, that
+ * didn't make sense in the presence of the CourierFactory, which should be the
+ * place where these kinds of patterns reside. Therefore, courierFromEpr and friends
+ * have moved. Since these were private methods anyway, this should not affect any
+ * existing users.
+ * 
  * @author esteban
  * @author kstam at redhat.com
  */
 public class TwoWayCourierImpl implements TwoWayCourier
 {
     private EPR _toEPR ;
+    private EPR _replyToEPR;
     private DeliverOnlyCourier deliverCourier;
     private PickUpOnlyCourier pickupCourier;
 
@@ -83,6 +87,16 @@
         return pickupCourier;
     }
 
+    public final EPR getToEPR ()
+    {
+	return _toEPR;
+    }
+    
+    public final EPR getReplyToEPR ()
+    {
+	return _replyToEPR;
+    }
+    
     /**
 	 */
 	public void setToEpr(EPR toEPR) throws CourierException,
@@ -109,6 +123,7 @@
                 try
                 {
                     pickupCourier = getPickupCourier(replyToEPR);
+                    _replyToEPR = replyToEPR;
                 }
                 finally
                 {
@@ -119,7 +134,7 @@
 	public static DeliverOnlyCourier getDeliverCourier(EPR toEPR)
 			throws CourierException, MalformedEPRException
 	{
-		return (null == toEPR) ? null : (DeliverOnlyCourier) courierFromEpr(
+		return (null == toEPR) ? null : (DeliverOnlyCourier) CourierFactory.courierFromEpr(
 				toEPR, false);
 	}
 
@@ -127,46 +142,9 @@
 			throws CourierException, MalformedEPRException
 	{
 		return (null == replyToEPR) ? null
-				: (PickUpOnlyCourier) courierFromEpr(replyToEPR, true);
+				: (PickUpOnlyCourier) CourierFactory.courierFromEpr(replyToEPR, true);
 	}
 
-	private static Object courierFromEpr(EPR epr, boolean pickUpOnly)
-			throws CourierException, MalformedEPRException
-	{
-		if (null == epr)
-			return null;
-		if (epr instanceof JMSEpr)
-			return new JmsCourier((JMSEpr) epr, pickUpOnly);
-		if (epr instanceof FileEpr)
-			return new FileCourier((FileEpr) epr, pickUpOnly);
-		if (epr instanceof JDBCEpr)
-			return new SqlTableCourier((JDBCEpr) epr, pickUpOnly);
-
-		// TODO the following is necessary because EPR
-		// serialization/deserialization loses type
-
-		return courierFromGenericEPR(epr, pickUpOnly);
-	}
-
-	private static Object courierFromGenericEPR(EPR epr, boolean pickUpOnly)
-			throws CourierException, MalformedEPRException
-	{
-		String addr = null;
-
-		addr = epr.getAddr().getAddress();
-		if (addr.startsWith(JMSEpr.JMS_PROTOCOL))
-			return new JmsCourier(new JMSEpr(epr), pickUpOnly);
-		if (addr.startsWith(JDBCEpr.JDBC_PROTOCOL))
-			return new SqlTableCourier(new JDBCEpr(epr), pickUpOnly);
-		// TODO magic strings
-		if (addr.startsWith("file://") || addr.startsWith("ftp://")
-				|| addr.startsWith("sftp://") || addr.startsWith("ftps://"))
-			return new FileCourier(new FileEpr(epr), pickUpOnly);
-
-		throw new CourierException("Courier for "
-				+ epr.getClass().getSimpleName() + " not supported yet");
-	}
-
 	/**
 	 * @see org.jboss.soa.esb.couriers.Courier#deliver(Message message).
 	 */

Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java	2007-12-08 20:14:14 UTC (rev 17117)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java	2007-12-08 21:11:27 UTC (rev 17118)
@@ -19,6 +19,7 @@
  * 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;
 /**
  * 
@@ -26,20 +27,27 @@
  * @author - kstam at redhat.com
  *
  */
+
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.Map.Entry;
 
 import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.couriers.FileCourier;
+import org.jboss.internal.soa.esb.couriers.JmsCourier;
+import org.jboss.internal.soa.esb.couriers.SqlTableCourier;
 import org.jboss.internal.soa.esb.couriers.TwoWayCourierImpl;
 import org.jboss.internal.soa.esb.couriers.InVMCourier;
 import org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier;
 import org.jboss.internal.soa.esb.couriers.PickUpOnlyCourier;
 import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.addressing.MalformedEPRException;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
 import org.jboss.soa.esb.addressing.eprs.InVMEpr;
+import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
 import org.jboss.soa.esb.lifecycle.LifecyclePriorities;
 import org.jboss.soa.esb.lifecycle.LifecycleResource;
 import org.jboss.soa.esb.lifecycle.LifecycleResourceException;
@@ -65,10 +73,15 @@
     /**
      * InVM Couiers.  No real resources or lifecycle associated with these, so no need for the
      * LifecycleResource stuff.
+     * 
+     * Not quite: the queue can grow arbitrarily and if a service decides to remove its InVMCourier
+     * then we should scrap the queue contents. Especially if all clients do so as well. Otherwise
+     * these instances will just keep being accumulated.
+     * 
      * TODO: Check this with Kev!
      */
+
     private final Map<String, InVMCourier> inVMCouriers = new ConcurrentHashMap<String, InVMCourier>();
-
     /**
      * Factory singleton instance.
      */
@@ -175,7 +188,44 @@
 
         return courier;
     }
+    
+    public static Object courierFromEpr (EPR epr, boolean pickUpOnly)
+	    throws CourierException, MalformedEPRException
+    {
+	if (null == epr)
+	    return null;
+	if (epr instanceof JMSEpr)
+	    return new JmsCourier((JMSEpr) epr, pickUpOnly);
+	if (epr instanceof FileEpr)
+	    return new FileCourier((FileEpr) epr, pickUpOnly);
+	if (epr instanceof JDBCEpr)
+	    return new SqlTableCourier((JDBCEpr) epr, pickUpOnly);
 
+	// TODO the following is necessary because EPR
+	// serialization/deserialization loses type
+
+	return courierFromGenericEPR(epr, pickUpOnly);
+    }
+
+    private static Object courierFromGenericEPR (EPR epr, boolean pickUpOnly)
+	    throws CourierException, MalformedEPRException
+    {
+	String addr = null;
+
+	addr = epr.getAddr().getAddress();
+	if (addr.startsWith(JMSEpr.JMS_PROTOCOL))
+	    return new JmsCourier(new JMSEpr(epr), pickUpOnly);
+	if (addr.startsWith(JDBCEpr.JDBC_PROTOCOL))
+	    return new SqlTableCourier(new JDBCEpr(epr), pickUpOnly);
+	// TODO magic strings
+	if (addr.startsWith("file://") || addr.startsWith("ftp://")
+		|| addr.startsWith("sftp://") || addr.startsWith("ftps://"))
+	    return new FileCourier(new FileEpr(epr), pickUpOnly);
+
+	throw new CourierException("Courier for "
+		+ epr.getClass().getSimpleName() + " not supported yet");
+    }
+
     /**
          * Register the courier as part of the current set.
          * @param courier The current courier.
@@ -198,7 +248,7 @@
             }
             catch (final LifecycleResourceException lre)
             {
-                throw new CourierException("Unexpected lifecycle resource exception whiel registering courier", lre) ;
+                throw new CourierException("Unexpected lifecycle resource exception while registering courier", lre) ;
             }
         }
         




More information about the jboss-svn-commits mailing list