[jboss-svn-commits] JBL Code SVN: r7501 - labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Nov 9 12:33:33 EST 2006
Author: estebanschifman
Date: 2006-11-09 12:33:30 -0500 (Thu, 09 Nov 2006)
New Revision: 7501
Added:
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
Log:
Two way courier concept and implementation
Added: 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-09 17:33:02 UTC (rev 7500)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverCourier.java 2006-11-09 17:33:30 UTC (rev 7501)
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+interface DeliverCourier
+{
+ public boolean deliver(Message message) throws CourierException;
+ public void cleanup();
+}
Added: 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-09 17:33:02 UTC (rev 7500)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpCourier.java 2006-11-09 17:33:30 UTC (rev 7501)
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+interface PickUpCourier
+{
+ public Message pickUp(long millis) throws CourierException;
+ public void cleanup();
+}
Added: 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 17:33:02 UTC (rev 7500)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourier.java 2006-11-09 17:33:30 UTC (rev 7501)
@@ -0,0 +1,106 @@
+/*
+ * 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;
+
+public class TwoWayCourier implements Courier
+{
+ public TwoWayCourier(EPR output, EPR input) throws CourierException
+ {
+ if (null!=output)
+ _outgoing = getDeliverCourier(output);
+ if (null!=input)
+ _incoming = getPickupCourier(input);
+ } //________________________________
+
+ protected DeliverCourier getDeliverCourier(EPR epr) throws CourierException
+ {
+ 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 (epr instanceof JMSEpr)
+ return new JmsCourier((JMSEpr)epr,true);
+ throw new CourierException ("Couriers for "+epr.getClass().getSimpleName()+" not supported yet");
+ } //________________________________
+
+ public boolean deliver(Message message) throws CourierException
+ {
+ boolean bRet = deliverNext(message);
+ stopDurableDelivery();
+ return bRet;
+ } //________________________________
+
+ public Message deliverAndWaitForPickup(Message message, long waitTime) throws CourierException, CourierTimeoutException
+ {
+ if (!deliver(message))
+ throw new CourierException("Unable to deliver Message");
+ return pickup(waitTime);
+ } //________________________________
+
+ public boolean deliverNext(Message message) throws CourierException
+ {
+ if (null==_outgoing)
+ throw new CourierException("No outgoing EPR was provided at construction time");
+ return _outgoing.deliver(message);
+ } //________________________________
+
+ public Message pickup(long waitTime) throws CourierException, CourierTimeoutException
+ {
+ Message mess = pickupNext(waitTime);
+ _incoming.cleanup();
+ return mess;
+ } //________________________________
+
+ 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);
+ } //________________________________
+
+ public void stopDurableDelivery()
+ {
+ if (null!=_outgoing)
+ _outgoing.cleanup();
+ } //________________________________
+
+ public void stopDurablePickup()
+ {
+ if (null!=_incoming)
+ _incoming.cleanup();
+ } //________________________________
+
+ protected DeliverCourier _outgoing;
+ protected PickUpCourier _incoming;
+
+}
More information about the jboss-svn-commits
mailing list