[jboss-svn-commits] JBL Code SVN: r24050 - in labs/jbossesb/workspace/skeagh: api/src/main/java/org/jboss/esb/api/context and 11 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Nov 22 10:38:23 EST 2008


Author: tfennelly
Date: 2008-11-22 10:38:23 -0500 (Sat, 22 Nov 2008)
New Revision: 24050

Added:
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/01-deployment.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/02-deployment.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/03-deployment.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/BusInjectionTest.java
Removed:
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/BusInjectionTest.java
Modified:
   labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/bus/BusMessage.java
   labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/context/AddressingContext.java
   labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/context/InvocationContext.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/failure/DeadLetterPersistanceService.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/failure/MockDeadLetterService.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/BusMediator.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceInvoker.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceRouter.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/ESBTestComponent.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_012/RoutingTest.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_013/RoutingTest.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_014/RoutingTest.java
Log:
https://jira.jboss.org/jira/browse/JBESB-2182

Modified: labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/bus/BusMessage.java
===================================================================
--- labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/bus/BusMessage.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/bus/BusMessage.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -178,13 +178,14 @@
      * Create a {@link BusMessage} instance from the supplied message and the existing thread context.
      *
      * @param theMessage Th message.
+     * @param addressingContext The {@link AddressingContext} for delivery.
      * @return The bundled {@link BusMessage} instance.
      */
-    public static BusMessage create(final Message theMessage)
+    public static BusMessage create(final Message theMessage, final AddressingContext addressingContext)
     {
         BusMessage busMessage = new BusMessage();
 
-        busMessage.setAddressingContext(AddressingContext.getContext());
+        busMessage.setAddressingContext(addressingContext);
         busMessage.setInvocationParameters(InvocationContext.getContext().getInvocationParameters());
         busMessage.setMessage(theMessage);
 

Modified: labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/context/AddressingContext.java
===================================================================
--- labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/context/AddressingContext.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/context/AddressingContext.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -55,6 +55,23 @@
     private static ThreadLocal<AddressingContext> contextTL = new ThreadLocal<AddressingContext>();
 
     /**
+     * Public constructor.
+     */
+    public AddressingContext()
+    {
+    }
+
+    /**
+     * Public constructor.
+     *
+     * @param to The "To" address.
+     */
+    public AddressingContext(final ServiceName to)
+    {
+        this.to = to;
+    }
+
+    /**
      * Set the {@link AddressingContext} associated with the current thread.
      *
      * @param context The {@link AddressingContext} associated with the current thread.
@@ -64,7 +81,8 @@
         if (context != null)
         {
             contextTL.set(context);
-        } else
+        }
+        else
         {
             contextTL.remove();
         }
@@ -113,9 +131,9 @@
     }
 
     /**
-     * Set the "To" address.
+     * Set the "From" address.
      *
-     * @param from The "To" address.
+     * @param from The "From" address.
      */
     public final void setFrom(final ServiceName from)
     {
@@ -161,4 +179,13 @@
     {
         this.faultTo = faultTo;
     }
+
+    /**
+     * Addressing toString.
+     * @return String representation of the addressing context.
+     */
+    public final String toString()
+    {
+        return "To: " + to + ", From: " + from + ", ReplyTo: " + replyTo + ", FaultTo: " + faultTo;
+    }
 }

Modified: labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/context/InvocationContext.java
===================================================================
--- labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/context/InvocationContext.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/context/InvocationContext.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -26,7 +26,7 @@
 /**
  * InvocationContext Context.
  * <p/>
- * Mutable context scoped around a ServiceInvocation.
+ * Mutable context scoped around a Service Invocation.
  *
  * @author <a href="mailto:Kevin.Conner at jboss.com">Kevin Conner</a>
  * @author <a href="mailto:tcunning at redhat.com">Tom Cunningham</a>

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -281,8 +281,7 @@
      * <p/>
      * Auto-deploys all configured {@link org.jboss.esb.api.bus.Bus} interfaces for the deployment.
      *
-     * @throws org.jboss.esb.deploy.DeploymentException
-     *          Error deploying ESB Runtime.
+     * @throws org.jboss.esb.deploy.DeploymentException Error deploying ESB Runtime.
      */
     public final void deploy() throws DeploymentException
     {

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -226,12 +226,13 @@
             }
             catch (ServiceException e)
             {
-                ServiceName faultTo = AddressingContext.getContext().getFaultTo();
+                AddressingContext addressingContext = AddressingContext.getContext();
+                ServiceName faultTo = addressingContext.getFaultTo();
 
                 if (faultTo != null)
                 {
                     FaultContext faultContext = InvocationContext.getContext().getFaultContext();
-                    BusMessage busMessage = BusMessage.create(theMessage);
+                    BusMessage busMessage = BusMessage.create(theMessage, addressingContext);
 
                     faultContext.setFaultMessage(theMessage);
                     faultContext.setFault(e);
@@ -454,7 +455,19 @@
      */
     protected final void routeToDeadLetterService(final Message theMessage, final Throwable theFault)
     {
-        if (!routeToDeadLetterService(theMessage, theFault, serviceInvoker))
+        routeToDeadLetterService(theMessage, theFault, AddressingContext.getContext(), serviceInvoker);
+    }
+
+    /**
+     * Route the supplied message to the Dead Letter Service.
+     *
+     * @param theMessage The message.
+     * @param theFault   The fault that triggered the routing of the message to the Dead Letter Service.
+     * @param addressingContext The {@link org.jboss.esb.api.context.AddressingContext} for the failed delivery.
+     */
+    protected final void routeToDeadLetterService(final Message theMessage, final Throwable theFault, final AddressingContext addressingContext)
+    {
+        if (!routeToDeadLetterService(theMessage, theFault, addressingContext, serviceInvoker))
         {
             logger.fatal("Unable to route message to Dead Letter Service.");
         }
@@ -465,20 +478,19 @@
      *
      * @param theMessage     The message.
      * @param theFault       The fault that triggered the routing of the message to the Dead Letter Service.
+     * @param addressingContext The {@link org.jboss.esb.api.context.AddressingContext} for the failed delivery.
      * @param serviceInvoker The ServiceInvoker instance to use for the delivery.
      * @return True if the message was delivered to the Dead Letter Service.
      */
-    public static boolean routeToDeadLetterService(final Message theMessage, final Throwable theFault, final ServiceInvoker serviceInvoker)
+    public static boolean routeToDeadLetterService(final Message theMessage, final Throwable theFault, final AddressingContext addressingContext, final ServiceInvoker serviceInvoker)
     {
-        AddressingContext addressingContext = AddressingContext.getContext();
-
         if (addressingContext.getTo().equals(DeadLetterPersistanceService.SERVICE_NAME))
         {
             return false;
         }
 
         FaultContext faultContext = InvocationContext.getContext().getFaultContext();
-        BusMessage busMessage = BusMessage.create(theMessage);
+        BusMessage busMessage = BusMessage.create(theMessage, addressingContext);
 
         faultContext.setFaultMessage(theMessage);
         faultContext.setFault(theFault);

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/failure/DeadLetterPersistanceService.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/failure/DeadLetterPersistanceService.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/failure/DeadLetterPersistanceService.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -44,6 +44,7 @@
     public final Message process(final Message message) throws ServiceException
     {
         // TODO
+        System.out.println("Message delivered to DeadLetterPersistanceService");
         return message;
     }
 }

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/failure/MockDeadLetterService.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/failure/MockDeadLetterService.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/failure/MockDeadLetterService.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -19,11 +19,18 @@
  */
 package org.jboss.esb.failure;
 
+import org.apache.log4j.Logger;
+import org.jboss.esb.api.annotations.Initialize;
+import org.jboss.esb.api.bus.BusMessage;
+import org.jboss.esb.api.context.DeploymentContext;
+import org.jboss.esb.api.context.InvocationContext;
 import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.service.Service;
+import org.jboss.esb.api.service.ServiceException;
+import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.invoke.ServiceInvoker;
 import org.jboss.esb.schedule.AbstractScheduleListener;
 import org.jboss.esb.schedule.SchedulingException;
-import org.jboss.esb.api.service.Service;
-import org.jboss.esb.api.service.ServiceException;
 
 import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
@@ -37,6 +44,11 @@
 {
 
     /**
+     * Logger.
+     */
+    private static Logger logger = Logger.getLogger(MockDeadLetterService.class);
+
+    /**
      * Flag to indicate whether or not the Service is expecting delivery of dead messages.
      */
     private boolean expectingMessages = false;
@@ -47,9 +59,27 @@
     /**
      * Messages.
      */
-    private Queue<Message> messages = new ConcurrentLinkedQueue<Message>();
+    private Queue<BusMessage> messages = new ConcurrentLinkedQueue<BusMessage>();
+    /**
+     * Deployment context.
+     */
+    private DeploymentContext deploymentContext;
+    /**
+     * ServiceInvoker.
+     */
+    private ServiceInvoker serviceInvoker;
 
     /**
+     * Initialize the router.
+     * @throws DeploymentException If an error occurs during initialization.
+     */
+    @Initialize
+    public final void initialize() throws DeploymentException
+    {
+        serviceInvoker = new ServiceInvoker(deploymentContext);
+    }
+    
+    /**
      * Service process method.
      *
      * @param message The message to be processed.
@@ -69,10 +99,17 @@
 
         if (!expectingMessages)
         {
-            throw new RuntimeException("No expecting Dead Letter message deliveries. Call setExpectingMessages(true) to turn off this error.");
+            throw new RuntimeException("Not expecting Dead Letter message deliveries. Call MockDeadLetterService.setExpectingMessages(true) to turn off this error.");
         }
 
-        messages.add(message);
+        BusMessage busMessage = (BusMessage) message.getPayload();
+        synchronized (messages)
+        {
+            messages.add(busMessage);
+        }
+
+        logger.info("Message delivered to Mock DLQ: [" + busMessage.getAddressingContext() + "].");
+
         return message;
     }
 
@@ -84,7 +121,38 @@
     @Override
     public final void onSchedule() throws SchedulingException
     {
-        // Redliver the messages in the queue...
+        synchronized (messages)
+        {
+            if(!messages.isEmpty())
+            {
+                int messageCountAtStart = messages.size();
+                for(int i = 0; i < messageCountAtStart; i++)
+                {
+                    BusMessage message = messages.poll();
+
+                    DeploymentContext.setContext(deploymentContext);
+                    try
+                    {
+                        InvocationContext invocationContext = new InvocationContext(message.getInvocationParameters());
+
+                        InvocationContext.setContext(invocationContext);
+                        try
+                        {
+                            logger.info("Redelivering message from DLQ.  Addressing: '" + message.getAddressingContext() + "'.");
+                            serviceInvoker.send(message.getMessage(), message.getAddressingContext());
+                        }
+                        finally
+                        {
+                            InvocationContext.setContext(null);
+                        }
+                    }
+                    finally
+                    {
+                        DeploymentContext.setContext(null);
+                    }
+                }
+            }
+        }
     }
 
     /**
@@ -92,7 +160,7 @@
      *
      * @return The messages.
      */
-    public final Queue<Message> getMessages()
+    public final Queue<BusMessage> getMessages()
     {
         return messages;
     }

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/BusMediator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/BusMediator.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/BusMediator.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -114,6 +114,9 @@
     {
         this.bus = bus;
         this.runtime = runtime;
+
+        bus.setDeploymentId(runtime.getDeploymentId());
+        bus.setDeploymentName(runtime.getDeploymentName());
         bus.setNotificationListener(notificationListener);
         bus.setMessageListener(busMessageListener);
 
@@ -129,6 +132,15 @@
     }
 
     /**
+     * Get the deployment runtime.
+     * @return The deployment runtime.
+     */
+    public final DeploymentRuntime getRuntime()
+    {
+        return runtime;
+    }
+
+    /**
      * Get the Bus instance associated with the BusDeployment instance.
      *
      * @return The Bus instance associated with the BusDeployment instance.
@@ -238,6 +250,8 @@
             {
                 detachDeploymentMonitor(monitor);
             }
+            deploymentMonitors.clear();
+            onlineNotification.getMonitoredDeployments().clear();
         }
     }
 

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -192,9 +192,12 @@
      */
     public final void addBusMediator(final BusMediator busMediator) throws DeploymentException, RoutingException
     {
-        Bus bus = busMediator.getBus();
+        if(busMediator.getRuntime() != runtime)
+        {
+            throw new DeploymentException("The supplied 'busMediator' instance must be associated with the same DeploymentRuntime instance as the DeploymentCoordinator to which it is being added.");
+        }
 
-        if (!bus.isConnected())
+        if (!busMediator.getBus().isConnected())
         {
             throw new DeploymentException("Cannot add a BusMediator for a bus that is not connected.");
         }

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceInvoker.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceInvoker.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceInvoker.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -38,6 +38,7 @@
 import org.jboss.esb.serialization.SerializationException;
 import org.jboss.esb.serialization.java.JavaSerializer;
 import org.jboss.esb.util.AssertArgument;
+import org.jboss.esb.dispatch.AbstractDispatcher;
 
 import java.util.Iterator;
 import java.util.Map;
@@ -224,6 +225,9 @@
             }
         }
 
+        // Route the message to the DLQ...
+        AbstractDispatcher.routeToDeadLetterService(message, null, invokeAddressingContext, this);
+
         return false;
     }
 }

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceRouter.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceRouter.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -23,11 +23,11 @@
 import org.jboss.esb.api.annotations.Property;
 import org.jboss.esb.api.context.AddressingContext;
 import org.jboss.esb.api.context.DeploymentContext;
-import org.jboss.esb.deploy.DeploymentException;
 import org.jboss.esb.api.message.Message;
-import org.jboss.esb.api.service.ServiceName;
 import org.jboss.esb.api.routing.OutboundRouter;
 import org.jboss.esb.api.routing.RoutingException;
+import org.jboss.esb.api.service.ServiceName;
+import org.jboss.esb.deploy.DeploymentException;
 
 /**
  * Service Message {@link org.jboss.esb.api.routing.OutboundRouter}.

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/ESBTestComponent.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/ESBTestComponent.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/ESBTestComponent.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -144,4 +144,13 @@
             TestCase.fail("Thread interrupted while waiting on message.");
         }
     }
+
+    public void reset()
+    {
+        this.message = null;
+        invocationContext = null;
+        addressingContext = null;
+        deploymentContext = null;
+        eventLog = null;
+    }
 }

Deleted: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/BusInjectionTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/BusInjectionTest.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/BusInjectionTest.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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-2008, JBoss Inc.
- */
-package org.jboss.esb.federate;
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class BusInjectionTest extends TestCase
-{
-
-    public void test()
-    {
-    }
-}

Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/01-deployment.xml (from rev 24040, labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_006/01-deployment.xml)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/01-deployment.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/01-deployment.xml	2008-11-22 15:38:23 UTC (rev 24050)
@@ -0,0 +1,16 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+    
+    <services>
+        <service serviceCategory="Service" serviceName="A" serviceDescription="A Service" class="org.jboss.esb.TestService">
+            <inRouter name="inrouter" class="org.jboss.esb.TestInboundRouter" />
+            <!--
+                Route the message from A to B....
+            -->
+            <outRouter name="A_to_B_router" class="org.jboss.esb.invoke.ServiceRouter">
+                <property name="toCategory">Service</property>
+                <property name="toService">B</property>
+            </outRouter>
+        </service>
+    </services>    
+
+</jbossesb>
\ No newline at end of file

Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/02-deployment.xml (from rev 24040, labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_006/02-deployment.xml)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/02-deployment.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/02-deployment.xml	2008-11-22 15:38:23 UTC (rev 24050)
@@ -0,0 +1,19 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+    <routing>
+        <!--
+            Route the message from B to C....
+        -->
+        <outRouters serviceCategory="Service" serviceName="B">
+            <outRouter name="B_to_C_router" class="org.jboss.esb.invoke.ServiceRouter">
+                <property name="toCategory">Service</property>
+                <property name="toService">C</property>
+            </outRouter>
+        </outRouters>
+    </routing>
+
+    <services>
+        <service serviceCategory="Service" serviceName="B" serviceDescription="B Service" class="org.jboss.esb.TestService" />
+    </services>
+
+</jbossesb>
\ No newline at end of file

Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/03-deployment.xml (from rev 24040, labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_006/03-deployment.xml)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/03-deployment.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/03-deployment.xml	2008-11-22 15:38:23 UTC (rev 24050)
@@ -0,0 +1,9 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+    <services>
+        <service serviceCategory="Service" serviceName="C" serviceDescription="B Service" class="org.jboss.esb.TestService">
+            <outRouter name="outrouter" class="org.jboss.esb.TestOutboundRouter" />
+        </service>
+    </services>
+
+</jbossesb>
\ No newline at end of file

Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/BusInjectionTest.java (from rev 24040, labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_006/RoutingTest.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/BusInjectionTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/BusInjectionTest.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -0,0 +1,184 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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-2008, JBoss Inc.
+ */
+package org.jboss.esb.federate.businjection;
+
+import junit.framework.TestCase;
+import org.jboss.esb.TestInboundRouter;
+import org.jboss.esb.TestOutboundRouter;
+import org.jboss.esb.TestService;
+import org.jboss.esb.api.service.ServiceName;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.DeploymentUtil;
+import org.jboss.esb.failure.DeadLetterPersistanceService;
+import org.jboss.esb.failure.MockDeadLetterService;
+import org.jboss.esb.federate.BusMediator;
+import org.jboss.esb.federate.bus.invm.InVMBus;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class BusInjectionTest extends TestCase
+{
+
+    /*
+     * The message should go (across the 3 deployments):
+     *      [inrouter_ServiceA -> ServiceA] -> [ServiceB] -> [ServiceC -> outrouter_ServiceC]
+     */
+    public void test() throws Exception
+    {
+        ServiceName serviceNameA = new ServiceName("Service", "A");
+        ServiceName serviceNameB = new ServiceName("Service", "B");
+        ServiceName serviceNameC = new ServiceName("Service", "C");
+        DeploymentRuntime deployment1 = DeploymentUtil.createRuntime(getClass().getResourceAsStream("01-deployment.xml"));
+
+        deployment1.setDeploymentName("deployment1");
+        deployment1.setDeploymentId("deployment1-Id");
+        deployment1.deploy(false);
+
+        // Don't start the bus interface for deployment1 just yet... later....
+        BusMediator mediatorD1 = new BusMediator(new InVMBus(), deployment1);
+        
+        try
+        {
+            DeploymentRuntime deployment2 = DeploymentUtil.createRuntime(getClass().getResourceAsStream("02-deployment.xml"));
+
+            deployment2.setDeploymentName("deployment2");
+            deployment2.setDeploymentId("deployment2-Id");
+            deployment2.deploy(false);
+
+            // Manually add a bus interface...
+            BusMediator mediatorD2 = new BusMediator(new InVMBus(), deployment2);
+            mediatorD2.getBus().connect();
+            deployment2.getDeploymentCoordinator().addBusMediator(mediatorD2);
+            try
+            {
+                DeploymentRuntime deployment3 = DeploymentUtil.createRuntime(getClass().getResourceAsStream("03-deployment.xml"));
+
+                deployment3.setDeploymentName("deployment3");
+                deployment3.setDeploymentId("deployment3-Id");
+                deployment3.deploy(false);
+
+                // Manually add a bus interface...
+                BusMediator mediatorD3 = new BusMediator(new InVMBus(), deployment3);
+                mediatorD3.getBus().connect();
+                deployment3.getDeploymentCoordinator().addBusMediator(mediatorD3);
+
+                Thread.sleep(100);
+
+                // Deployments 2 and 3 should be able to see each other...
+                assertEquals("{deployment3-Id:deployment3={online=true} deployment3:deployment3-Id:deployment3[Services: [Service:C, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [Service:C]]}", mediatorD2.getDeploymentMonitors().toString());
+                assertEquals("{deployment2-Id:deployment2={online=true} deployment2:deployment2-Id:deployment2[Services: [Service:B, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [Service:B]]}", mediatorD3.getDeploymentMonitors().toString());
+
+                try
+                {
+                    TestInboundRouter inrouter = (TestInboundRouter) DeploymentUtil.getInboundRouter("inrouter", deployment1).getRouter();
+                    TestService serviceA = (TestService) DeploymentUtil.getService(serviceNameA, deployment1).getService();
+                    TestService serviceB = (TestService) DeploymentUtil.getService(serviceNameB, deployment2).getService();
+                    TestService serviceC = (TestService) DeploymentUtil.getService(serviceNameC, deployment3).getService();
+                    TestOutboundRouter outrouter = (TestOutboundRouter) DeploymentUtil.getOutboundRouter(serviceNameC, "outrouter", deployment3).getRouter();
+                    MockDeadLetterService dlDLQ = (MockDeadLetterService) DeploymentUtil.getService(DeadLetterPersistanceService.SERVICE_NAME, deployment1).getService();
+
+                    dlDLQ.setExpectingMessages(true);
+                    
+                    inrouter.sendMessage("Hi there!!");
+
+                    serviceA.waitForMessage(10000);
+
+                    // Service B should not get it because there's no bus in place to deliver it...
+                    Thread.sleep(500);
+                    assertNull(serviceB.getMessage());
+
+                    // Now attach an InVM Bus interface to deployment1 ...
+                    mediatorD1.getBus().connect();
+                    deployment1.getDeploymentCoordinator().addBusMediator(mediatorD1);
+
+                    Thread.sleep(200);
+
+                    assertEquals(2, mediatorD1.getDeploymentMonitors().size());
+
+                    // Service B should get it now...
+                    serviceB.waitForMessage(10000);
+                    serviceC.waitForMessage(10000);
+                    outrouter.waitForMessage(10000);
+
+                    Thread.sleep(200);
+
+                    // All deployments should see each other again ...
+                    assertEquals("{deployment3-Id:deployment3={online=true} deployment3:deployment3-Id:deployment3[Services: [Service:C, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [Service:C]], deployment2-Id:deployment2={online=true} deployment2:deployment2-Id:deployment2[Services: [Service:B, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [Service:B]]}", mediatorD1.getDeploymentMonitors().toString());
+                    assertEquals("{deployment3-Id:deployment3={online=true} deployment3:deployment3-Id:deployment3[Services: [Service:C, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [Service:C]], deployment1-Id:deployment1={online=true} deployment1:deployment1-Id:deployment1[Services: [Service:A, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [Service:A]]}", mediatorD2.getDeploymentMonitors().toString());
+                    assertEquals("{deployment1-Id:deployment1={online=true} deployment1:deployment1-Id:deployment1[Services: [Service:A, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [Service:A]], deployment2-Id:deployment2={online=true} deployment2:deployment2-Id:deployment2[Services: [Service:B, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [Service:B]]}", mediatorD3.getDeploymentMonitors().toString());
+
+                    // Now remove the bus from deployment 1....
+                    deployment1.getDeploymentCoordinator().removeBusMediator(mediatorD1);
+
+                    assertFalse(mediatorD1.getBus().isConnected());
+
+                    // Deployments 2 and 3 should only see each other again (i.e. not deployment1)...
+                    assertEquals("{}", mediatorD1.getDeploymentMonitors().toString());
+                    assertEquals("{deployment3-Id:deployment3={online=true} deployment3:deployment3-Id:deployment3[Services: [Service:C, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [Service:C]]}", mediatorD2.getDeploymentMonitors().toString());
+                    assertEquals("{deployment2-Id:deployment2={online=true} deployment2:deployment2-Id:deployment2[Services: [Service:B, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [Service:B]]}", mediatorD3.getDeploymentMonitors().toString());
+
+                    serviceA.reset();
+                    serviceB.reset();
+                    serviceC.reset();
+
+                    inrouter.sendMessage("Hi there!!");
+
+                    serviceA.waitForMessage(10000);
+
+                    // Service B should not get it because there's no bus in place to deliver it (was removed)...
+                    Thread.sleep(500);
+                    assertNull(serviceB.getMessage());
+
+                    // Attach an InVM Bus interface again ...
+                    mediatorD1 = new BusMediator(new InVMBus(), deployment1);
+                    mediatorD1.getBus().connect();
+                    deployment1.getDeploymentCoordinator().addBusMediator(mediatorD1);
+
+                    Thread.sleep(200);
+
+                    // Service B should get it now...
+                    serviceB.waitForMessage(10000);
+                    serviceC.waitForMessage(10000);
+                    outrouter.waitForMessage(10000);
+
+                }
+                finally
+                {
+                    deployment3.undeploy();
+                    assertEquals("{}", mediatorD3.getDeploymentMonitors().toString());
+                    assertFalse(mediatorD3.getBus().isConnected());
+                }
+            }
+            finally
+            {
+                deployment2.undeploy();
+                assertFalse(mediatorD2.getBus().isConnected());
+                assertEquals("{}", mediatorD2.getDeploymentMonitors().toString());
+            }
+        }
+        finally
+        {
+            deployment1.undeploy();
+            assertFalse(mediatorD1.getBus().isConnected());
+            assertEquals("{}", mediatorD1.getDeploymentMonitors().toString());
+        }
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/businjection/BusInjectionTest.java
___________________________________________________________________
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + native

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_012/RoutingTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_012/RoutingTest.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_012/RoutingTest.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -65,7 +65,7 @@
             // Check that the message has been routed across deployments, from the inrouter
             // to the service instance and then to the outrouter...
             assertEquals("Hi there!!", serviceA.getMessage());
-            BusMessage dlsMessage = (BusMessage) dlService.getMessages().peek().getPayload();
+            BusMessage dlsMessage = (BusMessage) dlService.getMessages().peek();
             assertEquals("Hi there!!", dlsMessage.getMessage().getPayload());
             assertEquals("Service:A", dlsMessage.getAddressingContext().getTo().toString());
             assertTrue(dlsMessage.getFault() instanceof RuntimeException);

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_013/RoutingTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_013/RoutingTest.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_013/RoutingTest.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -69,7 +69,7 @@
             // Check that the message has been routed across deployments, from the inrouter
             // to the service instance and then to the outrouter...
             assertEquals("Hi there!!", serviceA.getMessage());
-            BusMessage dlsMessage = (BusMessage) dlService.getMessages().peek().getPayload();
+            BusMessage dlsMessage = (BusMessage) dlService.getMessages().peek();
             assertEquals("Hi there!!", dlsMessage.getMessage().getPayload());
             assertEquals("Service:A", dlsMessage.getAddressingContext().getTo().toString());
             assertTrue(dlsMessage.getFault() instanceof ServiceException);

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_014/RoutingTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_014/RoutingTest.java	2008-11-22 09:16:04 UTC (rev 24049)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_014/RoutingTest.java	2008-11-22 15:38:23 UTC (rev 24050)
@@ -70,7 +70,7 @@
             // Check that the message has been routed across deployments, from the inrouter
             // to the service instance and then to the outrouter...
             assertEquals("Hi there!!", serviceA.getMessage());
-            BusMessage dlsMessage = (BusMessage) dlService.getMessages().peek().getPayload();
+            BusMessage dlsMessage = (BusMessage) dlService.getMessages().peek();
             assertEquals("Hi there!!", dlsMessage.getMessage().getPayload());
             assertEquals("Service:A", dlsMessage.getAddressingContext().getFrom().toString()); // The service was applied, so the from address should reflect this.
             assertEquals("Service:A", dlsMessage.getAddressingContext().getTo().toString());




More information about the jboss-svn-commits mailing list