[jboss-svn-commits] JBL Code SVN: r17493 - in labs/jbossesb/workspace/bramley/product: rosetta/src/org/jboss/internal/soa/esb/services/registry and 12 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jan 2 09:33:17 EST 2008
Author: tfennelly
Date: 2008-01-02 09:33:16 -0500 (Wed, 02 Jan 2008)
New Revision: 17493
Added:
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/AbstractCourier.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InternalCourierFactory.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/Cleanable.java
Modified:
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverOnlyCourier.java
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/HibernateCourier.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/JmsCourier.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpOnlyCourier.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/internal/soa/esb/services/registry/InVMRegistry.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/MockRegistryImpl.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/Configurable.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/actions/Aggregator.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/Courier.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierCollection.java
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/CourierUtil.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/TwoWayCourier.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HibernateInterceptor.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/message/Invoker.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/message/MessageAwareListener.java
labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/services/registry/Registry.java
labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java
labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourierFactory.java
labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/CourierIntegrationTest.java
labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/InVMCourierUnitTest.java
labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/MockRegistry.java
labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/soa/esb/testutils/JMSUtil.java
labs/jbossesb/workspace/bramley/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollectorAction.java
Log:
Setting the foundation for a Courier/CourierFactory cleanup. Need to add 1 or more Couriers.
Added: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/AbstractCourier.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/AbstractCourier.java (rev 0)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/AbstractCourier.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -0,0 +1,32 @@
+/*
+ * 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, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.couriers;
+
+import org.jboss.soa.esb.Cleanable;
+
+/**
+ * Abstract courier interface.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public interface AbstractCourier extends Cleanable {
+ // Might be an idea to rename this to "Courier" (and deprecate) once the existing
+ // deprecated "Courier" type is removed.
+}
Property changes on: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/AbstractCourier.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverOnlyCourier.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverOnlyCourier.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/DeliverOnlyCourier.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -26,8 +26,7 @@
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.message.Message;
-public interface DeliverOnlyCourier
+public interface DeliverOnlyCourier extends AbstractCourier
{
public boolean deliver(Message message) throws CourierException, MalformedEPRException;
- public void cleanup() ;
}
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 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -450,7 +450,7 @@
_pollLatency = millis;
} // ________________________________
- public void cleanup()
+ public void clean()
{
}
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/HibernateCourier.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/HibernateCourier.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/HibernateCourier.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -73,7 +73,7 @@
m_epr = epr;
}
- public void cleanup() {
+ public void clean() {
}
/**
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 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InVMCourier.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -23,10 +23,8 @@
package org.jboss.internal.soa.esb.couriers;
import org.apache.log4j.Logger;
-import org.jboss.soa.esb.addressing.MalformedEPRException;
import org.jboss.soa.esb.addressing.eprs.InVMEpr;
import org.jboss.soa.esb.couriers.CourierException;
-import org.jboss.soa.esb.couriers.CourierTimeoutException;
import org.jboss.soa.esb.message.Message;
import java.util.Queue;
@@ -41,7 +39,7 @@
* instance should be purges when the service is finished with it.
*
* An alternative would be to use a WeakHashMap for maintaining the InVMCouriers in
- * the CourierFactory. But I'd prefer to have explicit control over the courier
+ * the InternalCourierFactory. But I'd prefer to have explicit control over the courier
* lifecycle rather than leaving to the vagueries of the gc. Plus, it could introduce
* some interesting race conditions.
*/
@@ -56,19 +54,9 @@
* @param epr
*/
- public InVMCourier(InVMEpr epr) throws CourierException,
- MalformedEPRException
- {
- this(epr, false);
- }
+ public InVMCourier(InVMEpr epr) {
+ this.epr = epr;
- public InVMCourier(InVMEpr epr, boolean receiverOnly) throws CourierException,
- MalformedEPRException
- {
- this.epr = epr;
-
- _receiverOnly = receiverOnly;
-
/*
* Normally we keep the link between sender and receiver threads. This
* makes the model simpler and allows services to be transplanted
@@ -99,13 +87,13 @@
* @throws CourierException -
* if problems were encountered
*/
- public boolean deliver(Message message) throws CourierException,
- MalformedEPRException
+ public boolean deliver(Message message)
{
- if (_receiverOnly)
- throw new CourierException("This is a pickUp-only Courier");
-
- if (message == null)
+ if (!assertCourierActive()) {
+ return false;
+ }
+
+ if (message == null)
{
return false;
}
@@ -136,12 +124,15 @@
return true;
}
- public Message pickup(long millis) throws CourierException,
- CourierTimeoutException
+ public Message pickup(long millis)
{
+ if (!assertCourierActive()) {
+ return null;
+ }
+
Message message = null;
- millis = Math.max(millis, 100); // TODO magic number
+ millis = Math.max(millis, 100);
synchronized (messageQueue)
{
if (messageQueue.isEmpty())
@@ -172,7 +163,19 @@
return message;
}
- public void cleanup()
+ private boolean assertCourierActive() {
+ if(!isActive) {
+ _logger.error("InVMCourier for EPR '" + epr.getAddr().getAddress() + "' is not active. Cannot pickup/deliver on this courier.");
+ return false;
+ }
+ return true;
+ }
+
+ public void setActive(boolean active) {
+ isActive = active;
+ }
+
+ public void clean()
{
}
@@ -184,5 +187,5 @@
private long deliveryTimeout = 0;
- private boolean _receiverOnly;
+ private boolean isActive = true;
}
Copied: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InternalCourierFactory.java (from rev 17488, labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java)
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InternalCourierFactory.java (rev 0)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InternalCourierFactory.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -0,0 +1,273 @@
+/*
+ * 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.apache.log4j.Logger;
+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.couriers.CourierException;
+import org.jboss.soa.esb.lifecycle.LifecyclePriorities;
+import org.jboss.soa.esb.lifecycle.LifecycleResource;
+import org.jboss.soa.esb.lifecycle.LifecycleResourceException;
+import org.jboss.soa.esb.lifecycle.LifecycleResourceFactory;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @author - esteban
+ * @author - kstam at redhat.com
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class InternalCourierFactory {
+ /**
+ * The logger for this instance.
+ */
+ private static final Logger LOGGER = Logger.getLogger(InternalCourierFactory.class);
+
+ /**
+ * The lifecycle resource factory.
+ */
+ private final LifecycleResourceFactory<Map<AbstractCourier, Exception>> lifecycleCourierFactory = new LifecycleCourierFactory();
+ /**
+ * Lifecycle couriers.
+ */
+ private final LifecycleResource<Map<AbstractCourier, Exception>> lifecycleCouriers =
+ new LifecycleResource<Map<AbstractCourier, Exception>>(lifecycleCourierFactory,
+ LifecyclePriorities.COURIER_PRIORITY);
+ /**
+ * InVM Couiers.
+ */
+ private final Map<String, InVMCourier> inVMCouriers = new ConcurrentHashMap<String, InVMCourier>();
+
+ /**
+ * Factory singleton instance.
+ */
+ private static InternalCourierFactory instance = new InternalCourierFactory();
+
+ // protected default constructor
+ protected InternalCourierFactory() {
+ }
+
+ /**
+ * Get the InternalCourierFactory method.
+ *
+ * @return The Courier factory instance.
+ */
+ public static InternalCourierFactory getInstance() {
+ return InternalCourierFactory.instance;
+ }
+
+ /**
+ * Set the InternalCourierFactory method.
+ * <p/>
+ * Supports unit testing.
+ *
+ * @param instance New factory instance.
+ */
+ protected static void setInstance(InternalCourierFactory instance) {
+ InternalCourierFactory.instance = instance;
+ }
+
+ public PickUpOnlyCourier getPickUpOnlyCourier(EPR epr) throws MalformedEPRException, CourierException {
+ try {
+ return (PickUpOnlyCourier) createCourier(epr, true);
+ } catch (ClassCastException e) {
+ throw new CourierException("Cannot create a PickUpOnlyCourier for EPR '" + epr + "'.", e);
+ }
+ }
+
+ public DeliverOnlyCourier getDeliverOnlyCourier(EPR epr) throws MalformedEPRException, CourierException {
+ try {
+ return (DeliverOnlyCourier) createCourier(epr, false);
+ } catch (ClassCastException e) {
+ throw new CourierException("Cannot create a DeliverOnlyCourier for EPR '" + epr + "'.", e);
+ }
+ }
+
+ public synchronized InVMCourier getInVMCourier(InVMEpr epr) {
+ String address = epr.getAddr().getAddress();
+ InVMCourier courier = inVMCouriers.get(address);
+
+ if (courier == null) {
+ courier = new InVMCourier(epr);
+ inVMCouriers.put(address, courier);
+ }
+
+ courier.setActive(true);
+
+ return courier;
+ }
+
+ private AbstractCourier createCourier(EPR epr, boolean pickUpOnly) throws CourierException, MalformedEPRException {
+ AbstractCourier courier = null;
+
+ if (null == epr) {
+ return null;
+ }
+ if (epr instanceof InVMEpr) {
+ courier = getInVMCourier((InVMEpr) epr);
+ }
+ if (epr instanceof JMSEpr) {
+ courier = new JmsCourier((JMSEpr) epr, pickUpOnly);
+ }
+ if (epr instanceof FileEpr) {
+ courier = new FileCourier((FileEpr) epr, pickUpOnly);
+ }
+ if (epr instanceof JDBCEpr) {
+ courier = new SqlTableCourier((JDBCEpr) epr, pickUpOnly);
+ }
+
+ if (courier == null) {
+ // TODO the following is necessary because EPR
+ // serialization/deserialization loses type
+ courier = courierFromGenericEPR(epr, pickUpOnly);
+ }
+
+ // Register it so as it's cleanup can be tied to its lifecycle...
+ registerCourier(courier);
+
+ return courier;
+ }
+
+ private static AbstractCourier courierFromGenericEPR(EPR epr, boolean pickUpOnly)
+ throws CourierException, MalformedEPRException {
+ String addr = null;
+
+ addr = epr.getAddr().getAddress();
+ if (addr == null) {
+ throw new CourierException("No address set on EPR. EPR type '" + epr.getClass().getName() + "'.");
+ }
+
+ 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().getName() + " not supported yet");
+ }
+
+ /**
+ * Register the courier as part of the current set.
+ *
+ * @param courier The current courier.
+ */
+ private synchronized void registerCourier(final AbstractCourier courier)
+ throws CourierException {
+ final Exception ex;
+ if (LOGGER.isDebugEnabled()) {
+ ex = new Exception("Courier Assignment stacktrace");
+ } else {
+ ex = null;
+ }
+ try {
+ lifecycleCouriers.getLifecycleResource().put(courier, ex);
+ }
+ catch (final LifecycleResourceException lre) {
+ throw new CourierException("Unexpected lifecycle resource exception while registering courier", lre);
+ }
+ }
+
+ /**
+ * Deregister the courier from the current set.
+ *
+ * @param courier The current courier.
+ */
+ public synchronized void deregisterCourier(final AbstractCourier courier) {
+ try {
+ lifecycleCouriers.getLifecycleResource().remove(courier);
+ }
+ catch (final LifecycleResourceException lre) {
+ LOGGER.warn("Unexpected error removing courier: " + lre.getMessage());
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Unexpected error removing courier", lre);
+ }
+ }
+ }
+
+ /**
+ * The lifecycle resource factory
+ *
+ * @author kevin
+ */
+ private static class LifecycleCourierFactory implements LifecycleResourceFactory<Map<AbstractCourier, Exception>> {
+
+ /**
+ * Create a resource object which will be associated with the specified lifecycle identity.
+ *
+ * @param lifecycleIdentity The associated lifecycle identity.
+ * @return The lifecycle resource
+ * @throws org.jboss.soa.esb.lifecycle.LifecycleResourceException
+ * for errors during construction.
+ */
+ public Map<AbstractCourier, Exception> createLifecycleResource(final String lifecycleIdentity)
+ throws LifecycleResourceException {
+ return new HashMap<AbstractCourier, Exception>();
+ }
+
+ /**
+ * Destroy a resource object which is associated with the specified lifecycle identity.
+ *
+ * @param resource The lifecycle resource.
+ * @param lifecycleIdentity The associated lifecycle identity.
+ * @return The lifecycle resource.
+ * @throws org.jboss.soa.esb.lifecycle.LifecycleResourceException
+ * for errors during destroy.
+ */
+ public void destroyLifecycleResource(final Map<AbstractCourier, Exception> resource,
+ final String lifecycleIdentity) throws LifecycleResourceException {
+
+ if (resource != null && !resource.isEmpty()) {
+ LOGGER.warn("Calling cleanup on existing couriers for identity " + lifecycleIdentity);
+ final Iterator<Entry<AbstractCourier, Exception>> entryIter = resource.entrySet().iterator();
+ while (entryIter.hasNext()) {
+ final Entry<AbstractCourier, Exception> entry = entryIter.next();
+ entryIter.remove();
+ if (LOGGER.isDebugEnabled() && (entry.getValue() != null)) {
+ LOGGER.debug("Courier allocation stacktrace", entry.getValue());
+ }
+
+ try {
+ entry.getKey().clean();
+ }
+ catch (final Exception ex) {
+ LOGGER.warn("Unexpected exception cleaning up courier", ex);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InternalCourierFactory.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -86,7 +86,7 @@
}
} // ________________________________
- public void cleanup() {
+ public void clean() {
synchronized(this) {
if (_messageProducer != null) {
try {
@@ -192,6 +192,7 @@
return deliver(msg);
}
+
/**
* Send the JMS message.
*
@@ -234,7 +235,6 @@
return false;
} // ________________________________
-
/**
* send/publish a javax.jms.ObjectMessage (that will contain the serialized
* ESB Message)
@@ -255,7 +255,7 @@
_logger.debug("JMS error. Attempting JMS reconnect.", exc);
synchronized(this) {
- cleanup();
+ clean();
final int maxRetry = 5; // TODO Magic number here!!!
for (int i1 = 0; i1 < maxRetry; i1++) {
@@ -480,6 +480,7 @@
esbPropertiesStrategy.setPropertiesFromJMSMessage(fromJMS, toESB);
}
+
private void createMessageConsumer() throws CourierException, ConfigurationException, MalformedEPRException {
Context oJndiCtx = null;
@@ -537,7 +538,6 @@
}
} // ________________________________
-
long _sleepForRetries = 3000; // milliseconds
protected boolean _isReceiver;
@@ -568,5 +568,4 @@
* by the process method.
*/
private ESBPropertiesSetter esbPropertiesStrategy = new DefaultESBPropertiesSetter();
-
}
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpOnlyCourier.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpOnlyCourier.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/PickUpOnlyCourier.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -25,13 +25,13 @@
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 interface PickUpOnlyCourier extends AbstractCourier
{
public Message pickup(long millis) throws CourierException, CourierTimeoutException;
- public void cleanup() ;
}
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 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -82,7 +82,7 @@
.getErrorDelete()));
} // ________________________________
- public void cleanup()
+ public void clean()
{
if (null != _conn)
{
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 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -41,10 +41,14 @@
* 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
+ * didn't make sense in the presence of the InternalCourierFactory, 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.
+ *
+ * @deprecated Please do not use this Courier type directly. This was a failed
+ * concept. Courier related types should not be used directly anymore. The Courier
+ * API is now internal.
*
* @author esteban
* @author kstam at redhat.com
@@ -105,7 +109,7 @@
DeliverOnlyCourier old = deliverCourier;
try
{
- deliverCourier = getDeliverCourier(toEPR);
+ deliverCourier = (DeliverOnlyCourier) CourierFactory.courierFromEpr(toEPR, false);
_toEPR = toEPR ;
}
finally
@@ -122,7 +126,7 @@
PickUpOnlyCourier old = pickupCourier;
try
{
- pickupCourier = getPickupCourier(replyToEPR);
+ pickupCourier = (PickUpOnlyCourier) CourierFactory.courierFromEpr(replyToEPR, true);
_replyToEPR = replyToEPR;
}
finally
@@ -131,60 +135,42 @@
}
}
- public static DeliverOnlyCourier getDeliverCourier(EPR toEPR)
- throws CourierException, MalformedEPRException
- {
- return (null == toEPR) ? null : (DeliverOnlyCourier) CourierFactory.courierFromEpr(
- toEPR, false);
- }
-
- public static PickUpOnlyCourier getPickupCourier(EPR replyToEPR)
- throws CourierException, MalformedEPRException
- {
- return (null == replyToEPR) ? null
- : (PickUpOnlyCourier) CourierFactory.courierFromEpr(replyToEPR, true);
- }
-
/**
* @see org.jboss.soa.esb.couriers.Courier#deliver(Message message).
*/
public boolean deliver(Message message) throws CourierException,
MalformedEPRException
{
- if (null == deliverCourier)
- throw new CourierException("No deliverAsync courier");
- final Header call = message.getHeader();
- call.setTo(_toEPR) ;
-
- final boolean setMessageID = call.getMessageID() == null;
- if (setMessageID)
- {
- final String messageID = UUID.randomUUID().toString() ;
- try
- {
- call.setMessageID(new URI(messageID)) ;
- }
- catch (final URISyntaxException urise)
- {
- throw new MalformedEPRException("Failed to set message ID to " + messageID) ;
- }
- }
+ if (null == deliverCourier) {
+ throw new CourierException("This is a pickup only Courier");
+ }
- try
- {
- message = FilterManager.getInstance().doOutputWork(message, null);
-
- return deliverCourier.deliver(message);
- }
- finally
- {
- if (setMessageID)
- {
- call.setMessageID(null) ;
- }
- }
- }
+ final Header call = message.getHeader();
+ call.setTo(_toEPR);
+ final boolean setMessageID = call.getMessageID() == null;
+ if (setMessageID) {
+ final String messageID = UUID.randomUUID().toString();
+ try {
+ call.setMessageID(new URI(messageID));
+ }
+ catch (final URISyntaxException urise) {
+ throw new MalformedEPRException("Failed to set message ID to " + messageID);
+ }
+ }
+
+ try {
+ message = FilterManager.getInstance().doOutputWork(message, null);
+
+ return deliverCourier.deliver(message);
+ }
+ finally {
+ if (setMessageID) {
+ call.setMessageID(null);
+ }
+ }
+ }
+
/**
* @see org.jboss.soa.esb.couriers.TwoWayCourier#pickup(long waitTime).
*/
@@ -201,7 +187,7 @@
public Message pickup(long waitTime, EPR epr) throws CourierException,
CourierTimeoutException, MalformedEPRException
{
- return pickup(waitTime, getPickupCourier(epr));
+ return pickup(waitTime, (PickUpOnlyCourier) CourierFactory.courierFromEpr(epr, true));
}
private Message pickup(long waitTime, PickUpOnlyCourier courier)
@@ -214,7 +200,7 @@
return (result == null ? null : FilterManager.getInstance().doInputWork(result, null)) ;
}
- public void cleanup ()
+ public void clean ()
{
CourierUtil.cleanCourier(deliverCourier) ;
deliverCourier = null ;
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/InVMRegistry.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/InVMRegistry.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/InVMRegistry.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -19,16 +19,19 @@
*/
package org.jboss.internal.soa.esb.services.registry;
+import org.jboss.internal.soa.esb.couriers.InVMCourier;
+import org.jboss.internal.soa.esb.couriers.InternalCourierFactory;
import org.jboss.soa.esb.Service;
import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.InVMEpr;
import org.jboss.soa.esb.services.registry.Registry;
import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -40,13 +43,6 @@
private Map<Service, List<RegsitryEntry>> regEntries = new ConcurrentHashMap<Service, List<RegsitryEntry>>();
- public void unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException {
- if(category == null) {
- category = "";
- }
- regEntries.remove(new Service(category, serviceName));
- }
-
public void registerEPR(String serviceCategoryName, String serviceName, String serviceDescription, EPR epr, String eprDescription) throws RegistryException {
if(serviceCategoryName == null) {
serviceCategoryName = "";
@@ -58,7 +54,19 @@
serviceEntries.add(regEntry);
}
+ public boolean unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException {
+ if(category == null) {
+ category = "";
+ }
+ _unRegisterEPR(category, serviceName, null);
+ return (regEntries.remove(new Service(category, serviceName)) != null);
+ }
+
public void unRegisterEPR(String serviceCategoryName, String serviceName, EPR epr) throws RegistryException, ServiceNotFoundException {
+ _unRegisterEPR(serviceCategoryName, serviceName, epr);
+ }
+
+ private void _unRegisterEPR(String serviceCategoryName, String serviceName, EPR epr) {
if(serviceCategoryName == null) {
serviceCategoryName = "";
}
@@ -69,7 +77,14 @@
while (iterator.hasNext()) {
RegsitryEntry regsitryEntry = iterator.next();
- if(regsitryEntry.getEpr().getAddr().getAddress().equals(epr.getAddr().getAddress())) {
+ if(epr == null || regsitryEntry.getEpr().getAddr().getAddress().equals(epr.getAddr().getAddress())) {
+ if(regsitryEntry.getEpr() instanceof InVMEpr) {
+ InVMCourier courier = InternalCourierFactory.getInstance().getInVMCourier((InVMEpr)regsitryEntry.getEpr());
+ if(courier != null) {
+ courier.setActive(false);
+ }
+ }
+
iterator.remove();
}
}
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -63,7 +63,6 @@
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.eprs.InVMEpr;
import org.jboss.soa.esb.common.Configuration;
-import org.jboss.soa.esb.services.registry.Registry;
import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
/**
@@ -157,9 +156,9 @@
* Remove an EPR from the Registry
*/
@SuppressWarnings("unchecked")
- public void unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException{
+ public boolean unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException{
// Make sure it's unregistered from the InVMRegistry...
- super.unRegisterService(category, serviceName);
+ boolean unregisteredFromInVMReg = super.unRegisterService(category, serviceName);
// first find the ServiceBindings for this service
Connection connection = JAXRRegistryImpl.getConnection();
@@ -167,8 +166,11 @@
try {
service = findService(category, serviceName);
if (service==null) {
- throw new ServiceNotFoundException("No such EPR found for service with name = "
- + serviceName);
+ if(unregisteredFromInVMReg) {
+ return true;
+ } else {
+ throw new ServiceNotFoundException("No such EPR found for service with name = " + serviceName);
+ }
}
connection.setCredentials(JAXRRegistryImpl.creds);
RegistryService rs = connection.getRegistryService();
@@ -181,7 +183,9 @@
} finally {
closeConnection(connection);
}
- }
+
+ return true;
+ }
/**
* Publish an EPR to the Registry
*/
@@ -238,44 +242,46 @@
* Remove an EPR from the Registry
*/
public void unRegisterEPR(String category, String serviceName, EPR toBeDeletedEPR) throws RegistryException, ServiceNotFoundException{
- super.unRegisterEPR(category, serviceName, toBeDeletedEPR);
-
- //first find the ServiceBindings for this service
- Connection connection = JAXRRegistryImpl.getConnection();
- Service service = null;
- try {
- service = findService(category, serviceName);
- if (service==null) {
- throw new ServiceNotFoundException("No such Service found for service with category= "
- + category + " and name = " + serviceName);
+ if(toBeDeletedEPR instanceof InVMEpr) {
+ super.unRegisterEPR(category, serviceName, toBeDeletedEPR);
+ } else {
+ //first find the ServiceBindings for this service
+ Connection connection = JAXRRegistryImpl.getConnection();
+ Service service = null;
+ try {
+ service = findService(category, serviceName);
+ if (service==null) {
+ throw new ServiceNotFoundException("No such Service found for service with category= "
+ + category + " and name = " + serviceName);
+ }
+ connection.setCredentials(JAXRRegistryImpl.creds);
+ Collection serviceBindings = findServiceBindings(service);
+ service.addServiceBindings(serviceBindings);
+ for (Iterator i=serviceBindings.iterator();i.hasNext();){
+ ServiceBinding serviceBinding = (ServiceBinding) i.next();
+ String xml = URLDecoder.decode(serviceBinding.getAccessURI(), "UTF-8");
+ if (xml.equals(EPRHelper.toXMLString(toBeDeletedEPR))) {
+ RegistryService rs = connection.getRegistryService();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ Collection<Key> serviceBindingKeys = new ArrayList<Key>();
+ serviceBindingKeys.add(serviceBinding.getKey());
+ blm.deleteServiceBindings(serviceBindingKeys);
+ return;
+ }
+ }
+ throw new RegistryException("No such EPR found for service with name = "
+ + serviceName + " and EPR=" + toBeDeletedEPR);
+ } catch (JAXRException je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ } catch (UnsupportedEncodingException uee) {
+ throw new RegistryException(uee.getLocalizedMessage(), uee);
+ } catch (MarshalException me) {
+ throw new RegistryException(me.getLocalizedMessage(), me);
+ } finally {
+ closeConnection(connection);
}
- connection.setCredentials(JAXRRegistryImpl.creds);
- Collection serviceBindings = findServiceBindings(service);
- service.addServiceBindings(serviceBindings);
- for (Iterator i=serviceBindings.iterator();i.hasNext();){
- ServiceBinding serviceBinding = (ServiceBinding) i.next();
- String xml = URLDecoder.decode(serviceBinding.getAccessURI(), "UTF-8");
- if (xml.equals(EPRHelper.toXMLString(toBeDeletedEPR))) {
- RegistryService rs = connection.getRegistryService();
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- Collection<Key> serviceBindingKeys = new ArrayList<Key>();
- serviceBindingKeys.add(serviceBinding.getKey());
- blm.deleteServiceBindings(serviceBindingKeys);
- return;
- }
- }
- throw new RegistryException("No such EPR found for service with name = "
- + serviceName + " and EPR=" + toBeDeletedEPR);
- } catch (JAXRException je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
- } catch (UnsupportedEncodingException uee) {
- throw new RegistryException(uee.getLocalizedMessage(), uee);
- } catch (MarshalException me) {
- throw new RegistryException(me.getLocalizedMessage(), me);
- } finally {
- closeConnection(connection);
}
- }
+ }
/**
* {@inheritDoc}
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/MockRegistryImpl.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/MockRegistryImpl.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/MockRegistryImpl.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -63,7 +63,7 @@
* Remove an EPR from the Registry
*/
@SuppressWarnings("unchecked")
- public void unRegisterService(String categoryName, String serviceName) throws RegistryException
+ public boolean unRegisterService(String categoryName, String serviceName) throws RegistryException
{
Category category = categories.get(categoryName);
if (category==null) {
@@ -76,7 +76,9 @@
}
}
}
- }
+
+ return true;
+ }
/**
* Publish an EPR to the Registry
*/
Added: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/Cleanable.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/Cleanable.java (rev 0)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/Cleanable.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -0,0 +1,34 @@
+/*
+ * 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, JBoss Inc.
+ */
+package org.jboss.soa.esb;
+
+/**
+ * Cleanable type.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @see Configurable
+ */
+public interface Cleanable {
+
+ /**
+ * Perform the clean operation.
+ */
+ public void clean() ;
+}
Property changes on: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/Cleanable.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/Configurable.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/Configurable.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/Configurable.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -25,6 +25,7 @@
* Configurable component.
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @see Cleanable
*/
public interface Configurable {
// This should eventually be supported through annotations.
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/actions/Aggregator.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/actions/Aggregator.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/actions/Aggregator.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -39,7 +39,6 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierFactory;
import org.jboss.soa.esb.couriers.CourierUtil;
import org.jboss.soa.esb.helpers.ConfigTree;
@@ -49,6 +48,7 @@
import org.jboss.soa.esb.services.registry.Registry;
import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.services.registry.RegistryFactory;
+import org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier;
/**
* Simple Aggregator. The aggregator relies on 'aggregatorTags'. To puzzle the individual
@@ -299,14 +299,14 @@
logger.debug("Found timeout message.");
try {
EPR epr = registry.findEPR(serviceCategoryName, serviceName);
- Courier courier = CourierFactory.getInstance().getCourier(epr);
+ DeliverOnlyCourier deliverOnlyCourier = CourierFactory.getInstance().getCourier(epr);
try
{
- courier.deliver(message);
+ deliverOnlyCourier.deliver(message);
}
finally
{
- CourierUtil.cleanCourier(courier) ;
+ CourierUtil.cleanCourier(deliverOnlyCourier) ;
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -19,25 +19,20 @@
*/
package org.jboss.soa.esb.client;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.internal.soa.esb.couriers.InternalCourierFactory;
+import org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier;
+import org.jboss.internal.soa.esb.couriers.PickUpOnlyCourier;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.Service;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.MalformedEPRException;
import org.jboss.soa.esb.addressing.util.DefaultReplyTo;
import org.jboss.soa.esb.common.Configuration;
-import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierException;
-import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.couriers.CourierUtil;
import org.jboss.soa.esb.couriers.FaultMessageException;
-import org.jboss.soa.esb.couriers.TwoWayCourier;
import org.jboss.soa.esb.listeners.RegistryUtil;
import org.jboss.soa.esb.listeners.ha.LoadBalancePolicy;
import org.jboss.soa.esb.listeners.ha.ServiceClusterInfo;
@@ -50,10 +45,14 @@
import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
import org.jboss.soa.esb.util.ClassUtil;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
/**
* Invoker class for managing {@link Message} delivery to a specified Service.
* <p/>
- * Manages loading of {@link EPR EPRs}, {@link Courier} selection and
+ * Manages loading of {@link EPR EPRs}, Courier selection and
* message delivery. Provides a unified/simplified interface for message
* delivery.
*
@@ -316,20 +315,6 @@
}
/**
- * Get a {@link org.jboss.soa.esb.couriers.Courier} for the supplied EPR.
- *
- * @param epr The EPR for which a {@link org.jboss.soa.esb.couriers.Courier}
- * is being sought.
- * @return The courier for the EPR.
- * @throws CourierException A courier implementation cannot be created.
- * @throws MalformedEPRException Bad EPR.
- */
- protected TwoWayCourier getCourier(EPR epr) throws CourierException, MalformedEPRException {
- // This method just allows us to override Courier lookup during unit testing.
- return CourierFactory.getInstance().getMessageCourier(epr);
- }
-
- /**
* Loads the EPRs fresh from the Registry. Right now we will do this every minute
* until we can expect to get updates from the registry. For now this should work
* just fine.
@@ -388,11 +373,11 @@
* without error, otherwise null.
*/
private Message attemptDelivery(Message message, EPR epr) throws FaultMessageException {
- TwoWayCourier courier = null;
+ DeliverOnlyCourier deliveryCourier = null;
// Get a courier for the EPR...
try {
- courier = getCourier(epr);
+ deliveryCourier = InternalCourierFactory.getInstance().getDeliverOnlyCourier(epr);
} catch (CourierException e) {
logger.debug("Courier lookup failed for EPR [" + epr + "] for Service [" + service + "] and Message ["+message.getHeader()+"].", e);
} catch (MalformedEPRException e) {
@@ -403,7 +388,7 @@
// Try delivering the message using the courier we just looked up....
- if (courier != null) {
+ if (deliveryCourier != null) {
// make sure the message header does not change when we exit
EPR currentEpr = message.getHeader().getTo();
@@ -423,14 +408,17 @@
}
message.getHeader().setReplyTo(replyToEPR);
}
- if (courier.deliver(message)) {
- if (synchronous) {
+ if (deliveryCourier.deliver(message)) {
+ if (synchronous && replyToEPR != null) {
// JBESB-1016 replyToEPR has to be non-null or we'd have dropped out by this point!
-
// do we need to do this for synchronous calls? Vagueries of Couriers?
- courier.setReplyToEpr(replyToEPR);
- return courier.pickup(timeout);
+ PickUpOnlyCourier pickupCourier = InternalCourierFactory.getInstance().getPickUpOnlyCourier(replyToEPR);
+ try {
+ return pickupCourier.pickup(timeout);
+ } finally {
+ InternalCourierFactory.getInstance().deregisterCourier(pickupCourier);
+ }
} else {
return message;
}
@@ -445,11 +433,9 @@
} catch (Throwable t) {
logger.warn("Unexpected exception during attempted message delivery over Courier for EPR [" + epr + "] for Service [" + service + "] and Message ["+message.getHeader()+"].", t);
} finally {
- // TODO: So does this mean that Couriers are stateful? If so, do we need to synchronize on using them??
- CourierUtil.cleanCourier(courier);
+ InternalCourierFactory.getInstance().deregisterCourier(deliveryCourier);
// put back the old To since we will have changed it.
-
if (currentEpr != null)
message.getHeader().setTo(currentEpr);
}
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/Courier.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/Courier.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/Courier.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -28,18 +28,14 @@
/**
* Courier interface. Deals relatively low level Message transport options.
*
+ * @deprecated Please do not use this Courier type directly. This was a failed
+ * concept. Courier related types should not be used directly anymore. The Courier
+ * API is now internal.
+ *
* @author esteban
* @author kstam at redhat.com
*
*/
public interface Courier extends DeliverOnlyCourier
{
- /**
- * Try to deliverAsync an ESB message. This is a one shot delivery.
- *
- * @param message Message - the message to deliverAsync
- * @return boolean - the result of the delivery
- * @throws CourierException - if problems were encountered
- */
- public boolean deliver(Message message) throws CourierException, MalformedEPRException;
}
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierCollection.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierCollection.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierCollection.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -28,6 +28,8 @@
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.MalformedEPRException;
import org.jboss.soa.esb.message.Message;
+import org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier;
+
/**
* Handle delivery of a message to a collection of Couriers.
*
@@ -38,7 +40,7 @@
/**
* The array of couriers.
*/
- private final Courier[] couriers ;
+ private final DeliverOnlyCourier[] deliverOnlyCouriers;
/**
* Construct the courier collection.
@@ -49,35 +51,35 @@
{
if ((eprs != null) && (eprs.size() > 0))
{
- final ArrayList<Courier> courierList = new ArrayList<Courier>() ;
+ final ArrayList<DeliverOnlyCourier> courierList = new ArrayList<DeliverOnlyCourier>() ;
try
{
for (EPR epr: eprs)
{
- final Courier courier = CourierFactory.getInstance().getCourier(epr) ;
+ final DeliverOnlyCourier courier = CourierFactory.getInstance().getCourier(epr) ;
if (courier == null)
{
throw new CourierException("Null courier returned for EPR: " + epr) ;
}
courierList.add(courier) ;
}
- couriers = courierList.toArray(new Courier[courierList.size()]) ;
+ deliverOnlyCouriers = courierList.toArray(new DeliverOnlyCourier[courierList.size()]) ;
courierList.clear() ;
}
finally
{
if (courierList.size() > 0)
{
- for(Courier courier: courierList)
+ for(DeliverOnlyCourier deliverOnlyCourier : courierList)
{
- CourierUtil.cleanCourier(courier) ;
+ CourierUtil.cleanCourier(deliverOnlyCourier) ;
}
}
}
}
else
{
- couriers = null ;
+ deliverOnlyCouriers = null ;
}
}
@@ -90,11 +92,11 @@
public boolean deliver(final Message message)
throws CourierException, MalformedEPRException
{
- if (couriers != null)
+ if (deliverOnlyCouriers != null)
{
- for(Courier courier: couriers)
+ for(DeliverOnlyCourier deliverOnlyCourier : deliverOnlyCouriers)
{
- courier.deliver(message) ;
+ deliverOnlyCourier.deliver(message) ;
}
return true ;
}
@@ -109,9 +111,9 @@
*/
public void cleanup()
{
- for(Courier courier: couriers)
+ for(DeliverOnlyCourier deliverOnlyCourier : deliverOnlyCouriers)
{
- CourierUtil.cleanCourier(courier) ;
+ CourierUtil.cleanCourier(deliverOnlyCourier) ;
}
}
}
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 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -28,24 +28,11 @@
*
*/
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
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.internal.soa.esb.couriers.*;
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;
@@ -53,6 +40,19 @@
import org.jboss.soa.esb.lifecycle.LifecycleResourceException;
import org.jboss.soa.esb.lifecycle.LifecycleResourceFactory;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ *
+ * @author - esteban
+ * @author - kstam at redhat.com
+ *
+ * @deprecated Courier API has been internalized. You should strongly
+ * consider using the {@link org.jboss.soa.esb.client.ServiceInvoker}.
+ */
public class CourierFactory
{
/**
@@ -70,19 +70,7 @@
private final LifecycleResource<Map<TwoWayCourier, Exception>> lifecycleCouriers =
new LifecycleResource<Map<TwoWayCourier,Exception>>(lifecycleCourierFactory,
LifecyclePriorities.COURIER_PRIORITY) ;
- /**
- * 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.
*/
@@ -92,7 +80,7 @@
protected CourierFactory() {}
/**
- * Get the CourierFactory method.
+ * Get the InternalCourierFactory method.
* @return The Courier factory instance.
*/
public static CourierFactory getInstance() {
@@ -100,7 +88,7 @@
}
/**
- * Set the CourierFactory method.
+ * Set the InternalCourierFactory method.
* <p/>
* Supports unit testing.
*
@@ -111,174 +99,115 @@
}
/**
- * 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 deliverAsync a Message.
- * @return The courier.
- * @throws CourierException if the specific courier implementation cannot be created.
- */
- public TwoWayCourier getMessageCourier(EPR toEPR) throws CourierException, MalformedEPRException {
- return getCourier(toEPR, null);
+ * Yet another way to create a pickup/deliver courier.
+ *
+ * @param epr The EPR.
+ * @param pickUpOnly True if the Courier is to be a {@link PickUpOnlyCourier}, false if it's to be
+ * a {@link org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier}.
+ *
+ * @return A {@link PickUpOnlyCourier} if pickUpOnly is true, otherwise a
+ * {@link org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier}.
+ *
+ * @deprecated Courier API has been internalized. You should strongly
+ * consider using the {@link org.jboss.soa.esb.client.ServiceInvoker}.
+ *
+ * @throws MalformedEPRException
+ * @throws CourierException
+ */
+ public static Object courierFromEpr(EPR epr, boolean pickUpOnly) throws MalformedEPRException, CourierException {
+ return instance.createCourier(epr, pickUpOnly);
}
- /**
- * 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 deliverAsync a Message.
- * @return Courier
- * @throws CourierException if the specific courier implementation cannot be created.
- */
- public Courier getCourier(EPR toEPR) throws CourierException, MalformedEPRException
- {
- return instance.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 replyToEPR - the 'replyTo address', the address where to deliverAsync the Message we pickup.
- * @return TwoWayCourier
- * @throws CourierException if the specific courier implementation cannot be created.
- */
- public TwoWayCourier getPickupCourier(EPR replyToEPR) throws CourierException, MalformedEPRException
- {
- return instance.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 deliverAsync a Message.
- * @param replyToEPR - the 'replyTo address', the address where to deliverAsync the Message we pickup.
- * @return TwoWayCourier
- * @throws CourierException if the specific courier implementation cannot be created.
- */
- public TwoWayCourier getCourier(EPR toEPR, EPR replyToEPR) throws CourierException, MalformedEPRException
- {
- DeliverOnlyCourier deliverCourier = null;
- PickUpOnlyCourier pickupCourier = null;
+ private Object createCourier(EPR epr, boolean pickUpOnly)
+ throws CourierException, MalformedEPRException {
- // Get the Delivery Courier...
- if(toEPR instanceof InVMEpr) {
- deliverCourier = getInVMCourier((InVMEpr) toEPR);
- } else if(toEPR != null) {
- deliverCourier = TwoWayCourierImpl.getDeliverCourier(toEPR);
+ if (null == epr) {
+ return null;
}
-
- // Get the Pickup Courier...
- if(replyToEPR instanceof InVMEpr) {
- pickupCourier = getInVMCourier((InVMEpr) replyToEPR);
- } else if(replyToEPR != null) {
- pickupCourier = TwoWayCourierImpl.getPickupCourier(replyToEPR);
+ 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);
+ }
- final TwoWayCourier result = new TwoWayCourierImpl(toEPR, deliverCourier, pickupCourier);
- registerCourier(result);
+ // TODO the following is necessary because EPR
+ // serialization/deserialization loses type
- return result;
+ return courierFromGenericEPR(epr, pickUpOnly);
}
- private synchronized InVMCourier getInVMCourier(InVMEpr epr) throws MalformedEPRException, CourierException {
- String address = epr.getAddr().getAddress();
- InVMCourier courier = inVMCouriers.get(address);
+ private static Object courierFromGenericEPR(EPR epr, boolean pickUpOnly)
+ throws CourierException, MalformedEPRException {
+ String addr = null;
- if(courier == null) {
- courier = new InVMCourier(epr);
- inVMCouriers.put(address, courier);
+ addr = epr.getAddr().getAddress();
+ if (addr == null) {
+ throw new CourierException("No address set on EPR. EPR type '" + epr.getClass().getName() + "'.");
}
- 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);
+ 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);
+ }
- // TODO the following is necessary because EPR
- // serialization/deserialization loses type
-
- return courierFromGenericEPR(epr, pickUpOnly);
+ throw new CourierException("Courier for " + epr.getClass().getName() + " not supported yet");
}
- 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.
+ */
+ private synchronized void registerCourier(final TwoWayCourier courier)
+ throws CourierException {
+ final Exception ex;
+ if (LOGGER.isDebugEnabled()) {
+ ex = new Exception("Courier Assignment stacktrace");
+ } else {
+ ex = null;
+ }
+ try {
+ lifecycleCouriers.getLifecycleResource().put(courier, ex);
+ }
+ catch (final LifecycleResourceException lre) {
+ throw new CourierException("Unexpected lifecycle resource exception while registering courier", lre);
+ }
}
/**
- * Register the courier as part of the current set.
- * @param courier The current courier.
- */
- private synchronized void registerCourier(final TwoWayCourier courier)
- throws CourierException
- {
- final Exception ex ;
- if (LOGGER.isDebugEnabled())
- {
- ex = new Exception("Courier Assignment stacktrace") ;
- }
- else
- {
- ex = null ;
- }
- try
- {
- lifecycleCouriers.getLifecycleResource().put(courier, ex) ;
- }
- catch (final LifecycleResourceException lre)
- {
- throw new CourierException("Unexpected lifecycle resource exception while registering courier", lre) ;
- }
+ * Deregister the courier from the current set.
+ *
+ * @param courier The current courier.
+ */
+ public synchronized void deregisterCourier(final TwoWayCourier courier) {
+ try {
+ lifecycleCouriers.getLifecycleResource().remove(courier);
}
-
- /**
- * Deregister the courier from the current set.
- * @param courier The current courier.
- */
- public synchronized void deregisterCourier(final TwoWayCourier courier)
- {
- try
- {
- lifecycleCouriers.getLifecycleResource().remove(courier) ;
+ catch (final LifecycleResourceException lre) {
+ LOGGER.warn("Unexpected error removing courier: " + lre.getMessage());
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Unexpected error removing courier", lre);
}
- catch (final LifecycleResourceException lre)
- {
- LOGGER.warn("Unexpected error removing courier: " + lre.getMessage()) ;
- if (LOGGER.isDebugEnabled())
- {
- LOGGER.debug("Unexpected error removing courier", lre) ;
- }
- }
}
-
- /**
- * The lifecycle resource factory
+ }
+
+ /**
+ * The lifecycle resource factory
* @author kevin
*/
private static class LifecycleCourierFactory implements LifecycleResourceFactory<Map<TwoWayCourier, Exception>>
{
+
/**
* Create a resource object which will be associated with the specified lifecycle identity.
* @param lifecycleIdentity The associated lifecycle identity.
@@ -314,10 +243,10 @@
{
LOGGER.debug("Courier allocation stacktrace", entry.getValue()) ;
}
-
+
try
{
- entry.getKey().cleanup() ;
+ entry.getKey().clean() ;
}
catch (final Exception ex)
{
@@ -326,5 +255,100 @@
}
}
}
+
}
+
+ /******************************************************************************************************************
+ * *
+ * The following methods are deprecated from v4.2.1. To be removed. In fact, this factory should *
+ * be made internal. *
+ * *
+ ******************************************************************************************************************/
+
+ /**
+ * 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 deliverAsync a Message.
+ * @return The courier.
+ * @throws CourierException if the specific courier implementation cannot be created.
+ * @deprecated Courier API has been internalized. You should strongly
+ * consider using the {@link org.jboss.soa.esb.client.ServiceInvoker}.
+ */
+ public TwoWayCourier getMessageCourier(EPR toEPR) throws CourierException, MalformedEPRException {
+ return getTwoWayCourier(toEPR, null);
+ }
+
+ /**
+ * 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 deliverAsync a Message.
+ * @return Courier
+ * @throws CourierException if the specific courier implementation cannot be created.
+ * @deprecated Courier API has been internalized. You should strongly
+ * consider using the {@link org.jboss.soa.esb.client.ServiceInvoker}.
+ */
+ public Courier getCourier(EPR toEPR) throws CourierException, MalformedEPRException
+ {
+ return getTwoWayCourier(toEPR, null);
+ }
+
+ /**
+ * Obtain a courier which can perform pickups only and prime it with the "to address" (toEPR)
+ * and the "replyTo address" (replyToEPR).
+ *
+ * @param replyToEPR - the 'replyTo address', the address where to deliverAsync the Message we pickup.
+ * @return TwoWayCourier
+ * @throws CourierException if the specific courier implementation cannot be created.
+ * @deprecated Courier API has been internalized. You should strongly
+ * consider using the {@link org.jboss.soa.esb.client.ServiceInvoker}.
+ */
+ public TwoWayCourier getPickupCourier(EPR replyToEPR) throws CourierException, MalformedEPRException
+ {
+ return getTwoWayCourier(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 deliverAsync a Message.
+ * @param replyToEPR - the 'replyTo address', the address where to deliverAsync the Message we pickup.
+ * @return TwoWayCourier
+ * @throws CourierException if the specific courier implementation cannot be created.
+ * @deprecated Courier API has been internalized. You should strongly
+ * consider using the {@link org.jboss.soa.esb.client.ServiceInvoker}.
+ */
+ public TwoWayCourier getCourier(EPR toEPR, EPR replyToEPR) throws CourierException, MalformedEPRException {
+ return getTwoWayCourier(toEPR, 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 deliverAsync a Message.
+ * @param replyToEPR - the 'replyTo address', the address where to deliverAsync the Message we pickup.
+ * @return TwoWayCourier
+ * @throws CourierException if the specific courier implementation cannot be created.
+ */
+ private TwoWayCourier getTwoWayCourier(EPR toEPR, EPR replyToEPR) throws CourierException, MalformedEPRException
+ {
+ if(toEPR == null && replyToEPR == null) {
+ throw new IllegalArgumentException("Must specify one of 'toEPR' or 'replyToEPR'.");
+ }
+
+ DeliverOnlyCourier deliverCourier = null;
+ PickUpOnlyCourier pickupCourier = null;
+
+ // Get the Delivery Courier...
+ deliverCourier = InternalCourierFactory.getInstance().getDeliverOnlyCourier(toEPR);
+
+ // Get the Pickup Courier...
+ pickupCourier = InternalCourierFactory.getInstance().getPickUpOnlyCourier(replyToEPR);
+
+ final TwoWayCourier result = new TwoWayCourierImpl(toEPR, deliverCourier, pickupCourier);
+ registerCourier(result);
+
+ return result;
+ }
}
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -28,7 +28,6 @@
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.io.StreamCorruptedException;
@@ -215,14 +214,14 @@
throws URISyntaxException, CourierException, MalformedEPRException
{
EPR toEpr = message.getHeader().getTo();
- Courier courier = CourierFactory.getInstance().getCourier(toEpr);
+ DeliverOnlyCourier deliverOnlyCourier = CourierFactory.getInstance().getCourier(toEpr);
try
{
- courier.deliver(message);
+ deliverOnlyCourier.deliver(message);
}
finally
{
- CourierUtil.cleanCourier(courier) ;
+ CourierUtil.cleanCourier(deliverOnlyCourier) ;
}
}
@@ -232,7 +231,7 @@
{
try
{
- courier.cleanup() ;
+ courier.clean() ;
}
catch (Exception e)
{
@@ -248,7 +247,7 @@
{
try
{
- courier.cleanup() ;
+ courier.clean() ;
}
catch (Exception e)
{
@@ -264,7 +263,7 @@
{
try
{
- courier.cleanup() ;
+ courier.clean() ;
}
catch (Exception e)
{
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/TwoWayCourier.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/TwoWayCourier.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/couriers/TwoWayCourier.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -27,6 +27,12 @@
import org.jboss.soa.esb.addressing.MalformedEPRException;
import org.jboss.soa.esb.message.Message;
+/**
+ *
+ * @deprecated Please do not use this Courier type directly. This was a failed
+ * concept. Courier related types should not be used directly anymore. The Courier
+ * API is now internal.
+ */
public interface TwoWayCourier extends Courier, PickUpOnlyCourier
{
/**
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HibernateInterceptor.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HibernateInterceptor.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HibernateInterceptor.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -37,7 +37,6 @@
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.MalformedEPRException;
-import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.couriers.CourierFactory;
import org.jboss.soa.esb.couriers.CourierUtil;
@@ -50,6 +49,7 @@
import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier;
/**
* HibernateInterceptor intercepts Hibernate events and sends the object they are
@@ -66,7 +66,7 @@
private static final long serialVersionUID = 1L;
private ArrayList<HibernateEventBean> m_events;
private final static Logger m_logger = Logger.getLogger(HibernateInterceptor.class);
- private Courier m_courier;
+ private DeliverOnlyCourier deliverOnlyCourier;
protected Class m_composerClass;
protected Method m_processMethod;
@@ -205,15 +205,15 @@
try {
boolean bSent = false;
for (EPR current : m_targetEprs) {
- m_courier = CourierFactory.getInstance().getCourier(current);
+ deliverOnlyCourier = CourierFactory.getInstance().getCourier(current);
try {
- if (m_courier.deliver(message)) {
+ if (deliverOnlyCourier.deliver(message)) {
bSent = true;
break;
}
} finally {
- CourierUtil.cleanCourier(m_courier) ;
+ CourierUtil.cleanCourier(deliverOnlyCourier) ;
}
}
@@ -226,13 +226,13 @@
text = "Action class method <" + m_processMethod.getName() + "> returned a non Message object";
} catch (CourierException e) {
thrown = e;
- text = "Courier <" + m_courier.getClass().getName() + ".deliverAsync(Message) FAILED";
+ text = "Courier <" + deliverOnlyCourier.getClass().getName() + ".deliverAsync(Message) FAILED";
} catch (MalformedEPRException ex) {
thrown = ex;
- text = "Courier <" + m_courier.getClass().getName() + ".deliverAsync(Message) FAILED with malformed EPR.";
+ text = "Courier <" + deliverOnlyCourier.getClass().getName() + ".deliverAsync(Message) FAILED with malformed EPR.";
} catch (IllegalArgumentException e) {
thrown = e;
- text = "Courier <" + m_courier.getClass().getName() + ".deliverAsync(Message) FAILED with IllegalArgumentException.";
+ text = "Courier <" + deliverOnlyCourier.getClass().getName() + ".deliverAsync(Message) FAILED with IllegalArgumentException.";
}
if (null != thrown) {
m_logger.error(text);
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -30,9 +30,6 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
import javax.jms.*;
import javax.naming.Context;
@@ -43,11 +40,11 @@
import org.jboss.internal.soa.esb.rosetta.pooling.ConnectionException;
import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool;
import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPoolContainer;
+import org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.eprs.JMSEpr;
import org.jboss.soa.esb.common.Environment;
-import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.couriers.CourierFactory;
import org.jboss.soa.esb.couriers.CourierUtil;
@@ -198,21 +195,21 @@
obj = FilterManager.getInstance().doOutputWork((Message) obj, params);
- Courier courier = null;
+ DeliverOnlyCourier deliverOnlyCourier = null;
try {
boolean bSent = false;
for (EPR current : _targetEprs) {
- courier = CourierFactory.getInstance().getCourier(current);
+ deliverOnlyCourier = CourierFactory.getInstance().getCourier(current);
try {
- if (courier.deliver((Message) obj)) {
+ if (deliverOnlyCourier.deliver((Message) obj)) {
bSent = true;
break;
}
}
finally {
- CourierUtil.cleanCourier(courier);
+ CourierUtil.cleanCourier(deliverOnlyCourier);
}
}
if (!bSent) {
@@ -230,8 +227,8 @@
return;
}
catch (CourierException e) {
- String text = (null != courier) ? "Courier <"
- + courier.getClass().getName()
+ String text = (null != deliverOnlyCourier) ? "Courier <"
+ + deliverOnlyCourier.getClass().getName()
+ ".deliverAsync(Message) FAILED"
: "NULL courier can't deliverAsync Message";
_logger.error(text, e);
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -43,12 +43,12 @@
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.listeners.gateway.Worker;
+import org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.MalformedEPRException;
import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
import org.jboss.soa.esb.common.Environment;
-import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.couriers.CourierFactory;
import org.jboss.soa.esb.couriers.CourierUtil;
@@ -213,7 +213,7 @@
Throwable thrown = null;
String text = null;
- Courier courier = null;
+ DeliverOnlyCourier deliverOnlyCourier = null;
try
{
@@ -237,10 +237,10 @@
boolean bSent = false;
for (EPR current : _targetEprs)
{
- courier = CourierFactory.getInstance().getCourier(current);
+ deliverOnlyCourier = CourierFactory.getInstance().getCourier(current);
try
{
- if (courier.deliver(message))
+ if (deliverOnlyCourier.deliver(message))
{
bSent = true;
break;
@@ -248,7 +248,7 @@
}
finally
{
- CourierUtil.cleanCourier(courier);
+ CourierUtil.cleanCourier(deliverOnlyCourier);
}
}
if (!bSent)
@@ -280,14 +280,14 @@
catch (CourierException e)
{
thrown = e;
- text = "Courier <" + courier.getClass().getName()
+ text = "Courier <" + deliverOnlyCourier.getClass().getName()
+ ".deliverAsync(Message) FAILED";
}
catch (MalformedEPRException ex)
{
thrown = ex;
text = "Courier <"
- + courier.getClass().getName()
+ + deliverOnlyCourier.getClass().getName()
+ ".deliverAsync(Message) FAILED with malformed EPR.";
}
finally
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -35,7 +35,6 @@
import org.jboss.soa.esb.addressing.MalformedEPRException;
import org.jboss.soa.esb.addressing.util.DefaultFaultTo;
import org.jboss.soa.esb.addressing.util.DefaultReplyTo;
-import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.couriers.CourierFactory;
import org.jboss.soa.esb.couriers.CourierUtil;
@@ -45,6 +44,7 @@
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.util.ClassUtil;
import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier;
/**
* Action Processing Pipeline. <p/> Runs a list of action classes on a message
@@ -351,7 +351,7 @@
private void replyTo(EPR replyToAddress, Message message)
{
- Courier courier = null;
+ DeliverOnlyCourier deliverOnlyCourier = null;
EPR replyToEPR = DefaultReplyTo.getReplyToAddress(message);
if (replyToEPR != null)
@@ -365,8 +365,8 @@
{
try
{
- courier = CourierFactory.getInstance().getCourier(replyToAddress);
- courier.deliver(message);
+ deliverOnlyCourier = CourierFactory.getInstance().getCourier(replyToAddress);
+ deliverOnlyCourier.deliver(message);
}
catch (final CourierException e)
{
@@ -385,9 +385,9 @@
}
finally
{
- if (courier != null)
+ if (deliverOnlyCourier != null)
{
- CourierUtil.cleanCourier(courier);
+ CourierUtil.cleanCourier(deliverOnlyCourier);
}
}
}
@@ -404,7 +404,7 @@
private void faultTo(EPR faultToAddress, Message message)
{
- Courier courier = null;
+ DeliverOnlyCourier deliverOnlyCourier = null;
EPR faultToEPR = DefaultFaultTo.getFaultToAddress(message);
if (faultToEPR != null)
@@ -418,8 +418,8 @@
{
try
{
- courier = CourierFactory.getInstance().getCourier(faultToAddress);
- courier.deliver(message);
+ deliverOnlyCourier = CourierFactory.getInstance().getCourier(faultToAddress);
+ deliverOnlyCourier.deliver(message);
}
catch (final CourierException e)
{
@@ -438,9 +438,9 @@
}
finally
{
- if (courier != null)
+ if (deliverOnlyCourier != null)
{
- CourierUtil.cleanCourier(courier);
+ CourierUtil.cleanCourier(deliverOnlyCourier);
}
}
}
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/message/Invoker.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/message/Invoker.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/message/Invoker.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -28,10 +28,10 @@
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.couriers.PickUpOnlyCourier;
+import org.jboss.internal.soa.esb.couriers.DeliverOnlyCourier;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.MalformedEPRException;
import org.jboss.soa.esb.addressing.util.DefaultReplyTo;
-import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.couriers.CourierFactory;
import org.jboss.soa.esb.couriers.CourierTimeoutException;
@@ -124,7 +124,7 @@
call.setMessageID(uri);
}
- Courier sender = CourierFactory.getInstance().getCourier(call.getTo());
+ DeliverOnlyCourier sender = CourierFactory.getInstance().getCourier(call.getTo());
PickUpOnlyCourier receiver = null;
try
{
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/message/MessageAwareListener.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/message/MessageAwareListener.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/listeners/message/MessageAwareListener.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -22,21 +22,14 @@
package org.jboss.soa.esb.listeners.message;
-import java.lang.reflect.Method;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.couriers.InternalCourierFactory;
import org.jboss.internal.soa.esb.couriers.PickUpOnlyCourier;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.MalformedEPRException;
import org.jboss.soa.esb.couriers.CourierException;
-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.listeners.ListenerUtil;
@@ -48,9 +41,14 @@
import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.util.Util;
+import java.lang.reflect.Method;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
/**
* Esb Message aware transport independent listener. <p/> Relies on the
- * CourierFactory to obtain an appropriate Courier for the EPR this listener
+ * InternalCourierFactory to obtain an appropriate Courier for the EPR this listener
* will be listening on <br/>Keeps a thread pool to instantiate
* ActionProcessingPipelines whenever a Message is received
*
@@ -176,14 +174,16 @@
throw new ManagedLifecycleException("Error configuring action processing pipeline", ce) ;
}
this.pipeline = pipeline ;
- final TwoWayCourier pickUpCourier ;
+ final PickUpOnlyCourier pickUpCourier ;
try
{
- pickUpCourier = CourierFactory.getInstance().getPickupCourier(_epr) ;
+ pickUpCourier = InternalCourierFactory.getInstance().getPickUpOnlyCourier(_epr);
+ if(pickUpCourier == null) {
+ throw new ManagedLifecycleException("Failed to get PickUpOnlyCourier for EPR '" + _epr.getAddr().getAddress() + "'.");
+ }
try
{
- final Method setPollLatency = pickUpCourier.getClass().getMethod(
- "setPollLatency", new Class[] { Long.class });
+ final Method setPollLatency = pickUpCourier.getClass().getMethod("setPollLatency", new Class[] { Long.class });
setPollLatency.invoke(pickUpCourier, new Long(1000 * _latencySecs));
}
catch (final NoSuchMethodException nsme)
@@ -192,7 +192,7 @@
}
catch (final Exception ex)
{
- CourierUtil.cleanCourier(pickUpCourier);
+ InternalCourierFactory.getInstance().deregisterCourier(pickUpCourier);
throw new ManagedLifecycleException("Problems invoking setPollLatency(long)", ex) ;
}
}
@@ -213,7 +213,7 @@
}
catch (final RegistryException re)
{
- CourierUtil.cleanCourier(_pickUpCourier);
+ InternalCourierFactory.getInstance().deregisterCourier(_pickUpCourier);
throw new ManagedLifecycleException("Unexpected error during registration for epr " + _epr, re);
}
}
@@ -323,7 +323,7 @@
pipeline.destroy() ;
pipeline = null ;
- CourierUtil.cleanCourier(_pickUpCourier);
+ InternalCourierFactory.getInstance().deregisterCourier(_pickUpCourier);
RegistryUtil.unregister(_eprCategoryName, _eprName, _epr) ;
}
Modified: labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/services/registry/Registry.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/services/registry/Registry.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/src/org/jboss/soa/esb/services/registry/Registry.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -38,7 +38,7 @@
* @param serviceName - name of the service, for example 'smooks'.
* @throws RegistryException
*/
- public void unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException;
+ public boolean unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException;
/**
* Registers an EPR under the specified category and service. If the specified service does
* not exist, it will be created at the same time.
Modified: labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -68,7 +68,7 @@
return deliveryResult;
}
- public void cleanup() {
+ public void clean() {
}
public void reset() {
Modified: labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourierFactory.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourierFactory.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourierFactory.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -24,43 +24,54 @@
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.MalformedEPRException;
+import org.jboss.soa.esb.addressing.eprs.InVMEpr;
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.couriers.TwoWayCourier;
/**
- * Mock CourierFactory.
+ * Mock InternalCourierFactory.
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
-public class MockCourierFactory extends CourierFactory {
+public class MockCourierFactory extends InternalCourierFactory {
public static CourierException courierException;
public static MalformedEPRException malformedEPRException;
- public static Hashtable<EPR, TwoWayCourier> couriers = new Hashtable<EPR, TwoWayCourier>();
- private static CourierFactory originalInstance;
-
- public TwoWayCourier getMessageCourier(EPR toEPR) throws CourierException, MalformedEPRException {
+ public static Hashtable<EPR, Object> couriers = new Hashtable<EPR, Object>();
+ private static InternalCourierFactory originalInstance;
+
+ public PickUpOnlyCourier getPickUpOnlyCourier(EPR epr) throws MalformedEPRException, CourierException {
+ assertThrowException();
+
+ if(epr instanceof InVMEpr) {
+ return getInVMCourier((InVMEpr) epr);
+ }
+ return (PickUpOnlyCourier) couriers.get(epr);
+ }
+
+ public DeliverOnlyCourier getDeliverOnlyCourier(EPR epr) throws MalformedEPRException, CourierException {
+ assertThrowException();
+ if(epr instanceof InVMEpr) {
+ return getInVMCourier((InVMEpr) epr);
+ }
+ return (DeliverOnlyCourier) couriers.get(epr);
+ }
+
+ private void assertThrowException() throws CourierException, MalformedEPRException {
if(courierException != null) {
throw courierException;
- } else if(malformedEPRException != null) {
+ }
+ if(malformedEPRException != null) {
throw malformedEPRException;
}
-
- TwoWayCourier courier = couriers.get(toEPR);
- if(courier == null) {
- courier = (TwoWayCourier) getCourier(toEPR);
- }
-
- return courier;
}
public static void install() {
- originalInstance = CourierFactory.getInstance();
- CourierFactory.setInstance(new MockCourierFactory());
+ originalInstance = InternalCourierFactory.getInstance();
+ InternalCourierFactory.setInstance(new MockCourierFactory());
}
public static void uninstall() {
- CourierFactory.setInstance(originalInstance);
+ InternalCourierFactory.setInstance(originalInstance);
reset();
}
@@ -71,7 +82,7 @@
}
public static void resetCouriers() {
- for (Map.Entry<EPR, TwoWayCourier> entry : couriers.entrySet()) {
+ for (Map.Entry<EPR, Object> entry : couriers.entrySet()) {
((MockCourier)entry.getValue()).reset();
}
}
Modified: labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/CourierIntegrationTest.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/CourierIntegrationTest.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/CourierIntegrationTest.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -22,11 +22,6 @@
package org.jboss.internal.soa.esb.couriers.tests;
-import java.io.File;
-import java.net.URI;
-import java.net.URL;
-import java.util.UUID;
-
import org.jboss.soa.esb.addressing.eprs.FTPEpr;
import org.jboss.soa.esb.addressing.eprs.FileEpr;
import org.jboss.soa.esb.common.tests.BaseTest;
@@ -37,6 +32,11 @@
import org.jboss.soa.esb.message.body.content.BytesBody;
import org.jboss.soa.esb.message.format.MessageFactory;
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.util.UUID;
+
/**
* Tests for internal FtpFileHandler class
*
Modified: labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/InVMCourierUnitTest.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/InVMCourierUnitTest.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/InVMCourierUnitTest.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -252,7 +252,7 @@
InVMEpr epr = new InVMEpr(new URI("invm://serviceid" + i
+ "test"));
- TwoWayCourierImpl courier = (TwoWayCourierImpl) CourierFactory.getInstance().getCourier(epr);
+ TwoWayCourierImpl courier = (TwoWayCourierImpl) InternalCourierFactory.getInstance().getCourier(epr);
Assert.assertNotNull(courier.getDeliverCourier());
Assert.assertNull(courier.getPickupCourier());
@@ -261,7 +261,7 @@
for (int j = 0; j < 10; j++)
System.gc(); // not guaranteed to work first time.
- //Assert.assertEquals(CourierFactoryHelper.getInVMCourierInstanceCount(CourierFactory.getInstance()), 0);
+ //Assert.assertEquals(CourierFactoryHelper.getInVMCourierInstanceCount(InternalCourierFactory.getInstance()), 0);
}*/
public static final int ITERATIONS = 10;
Modified: labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/MockRegistry.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/MockRegistry.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/MockRegistry.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -134,8 +134,9 @@
/* (non-Javadoc)
* @see org.jboss.soa.esb.services.registry.Registry#unRegisterService(java.lang.String, java.lang.String)
*/
- public void unRegisterService(String category, String serviceName) throws RegistryException {
+ public boolean unRegisterService(String category, String serviceName) throws RegistryException {
unRegisterEPR(category, serviceName, null);
+ return true;
}
/* (non-Javadoc)
Modified: labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/soa/esb/testutils/JMSUtil.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/soa/esb/testutils/JMSUtil.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/rosetta/tests/src/org/jboss/soa/esb/testutils/JMSUtil.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -153,7 +153,7 @@
throw new RuntimeException("Failed to deliver JMS Message to JMS " + destType + " '" + destName + "': " + e.getMessage());
}
} finally {
- courier.cleanup();
+ courier.clean();
}
}
Modified: labs/jbossesb/workspace/bramley/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollectorAction.java
===================================================================
--- labs/jbossesb/workspace/bramley/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollectorAction.java 2008-01-02 12:49:48 UTC (rev 17492)
+++ labs/jbossesb/workspace/bramley/product/tools/console/management/src/main/java/org/jboss/soa/esb/monitoring/client/DataCollectorAction.java 2008-01-02 14:33:16 UTC (rev 17493)
@@ -95,7 +95,7 @@
} catch (Exception e) {
logger.error("", e);
} finally {
- sender.cleanup();
+ sender.clean();
}
}
} else {
More information about the jboss-svn-commits
mailing list