[jboss-svn-commits] JBL Code SVN: r24041 - in labs/jbossesb/workspace/skeagh/runtime/src: main/java/org/jboss/esb/federate/bus and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Nov 21 15:58:11 EST 2008


Author: tfennelly
Date: 2008-11-21 15:58:11 -0500 (Fri, 21 Nov 2008)
New Revision: 24041

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/DeploymentCoordinator.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusOutboundRouter.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/invm/InVMBus.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceInvoker.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/DeploymentCoordinatorTest.java
Log:
https://jira.jboss.org/jira/browse/JBESB-2182

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-21 19:52:11 UTC (rev 24040)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/BusMediator.java	2008-11-21 20:58:11 UTC (rev 24041)
@@ -86,15 +86,19 @@
      */
     private DeploymentDetailsNotification onlineNotification;
     /**
+     * Offline notification object to be sent out on the bus.
+     */
+    private DeploymentUndeployNotification offlineNotification;
+    /**
      * Coordinator monitor timeout.  The number of milliseconds before an un responsive deployment
      * (being monitored via this Bus interface) is marked as offline.
      */
     private long monitorTimeout;
+
     /**
      * Heartbeat frequency config key.
      */
     public static final String COORDINATOR_HEARTBEAT_FREQUENCY_KEY = "coordinator.heartbeat.frequency";
-
     /**
      * Default heartbeat frequency.
      */
@@ -118,6 +122,7 @@
         // Initialize the notification objects...
         heartbeatNotification = DeploymentHeartbeatNotification.toNotification(runtime);
         onlineNotification = DeploymentDetailsNotification.toNotification(runtime);
+        offlineNotification = DeploymentUndeployNotification.toNotification(runtime);
 
         // Set the deploymnt monitor timeout - 3 missed heartbeats...
         monitorTimeout = (runtime.getDeploymentProperties().getLongProperty(COORDINATOR_HEARTBEAT_FREQUENCY_KEY, COORDINATOR_HEARTBEAT_DEFAULT_FREQUENCY) * 3);
@@ -153,6 +158,15 @@
     }
 
     /**
+     * Send the offline notification.
+     * @throws RoutingException Failed to send notification.
+     */
+    public final void sendOfflineNotification() throws RoutingException
+    {
+        bus.sendNotification(offlineNotification);
+    }
+
+    /**
      * Send the heartbeat notification.
      * @throws RoutingException Failed to send notification.
      */
@@ -201,6 +215,7 @@
         {
             Set<Map.Entry<ServiceName, BusOutboundRouter>> serviceOutRouterSet = routingContext.getBusOutRouters().entrySet();
 
+            monitor.setOnline(false);
             for (Map.Entry<ServiceName, BusOutboundRouter> serviceOutRouter : serviceOutRouterSet)
             {
                 BusOutboundRouter router = serviceOutRouter.getValue();
@@ -210,6 +225,62 @@
     }
 
     /**
+     * Detach all DeploymentMonitor instances from any
+     * BusOutboundRouter instances that hold a reference to it.
+     *
+     * @see #attachDeploymentMonitor(DeploymentMonitor)
+     */
+    public void detachDeploymentMonitors()
+    {
+        synchronized (routingContext)
+        {
+            for (DeploymentMonitor monitor : deploymentMonitors.values())
+            {
+                detachDeploymentMonitor(monitor);
+            }
+        }
+    }
+
+    /**
+     * Disconnect the deployment from the bus associated with the mediator.
+     */
+    public void disconnectBus()
+    {
+        try
+        {
+            bus.stopListening();
+        }
+        catch (Throwable t)
+        {
+            logger.error("Failed to stop listening on Bus '" + bus.getClass().getName() + "'.", t);
+        }
+        try
+        {
+            sendOfflineNotification();
+        }
+        catch (Throwable t)
+        {
+            logger.error("Error sending undeploy notification on Bus '" + bus.getClass().getName() + "'.", t);
+        }
+        try
+        {
+            detachDeploymentMonitors();
+        }
+        catch (Throwable t)
+        {
+            logger.error("Error detaching all deployment monitors on bus '" + bus.getClass().getName() + "'.", t);
+        }
+        try
+        {
+            bus.disconnect();
+        }
+        catch (Throwable t)
+        {
+            logger.error("Error disconnecting Bus '" + bus.getClass().getName() + "'.", t);
+        }
+    }
+
+    /**
      * Bus notification listener.
      */
     private class BusNotificationListener implements org.jboss.esb.api.bus.BusNotificationListener

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-21 19:52:11 UTC (rev 24040)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java	2008-11-21 20:58:11 UTC (rev 24041)
@@ -22,22 +22,22 @@
 import org.apache.log4j.Logger;
 import org.jboss.esb.api.annotations.Initialize;
 import org.jboss.esb.api.annotations.Uninitialize;
+import org.jboss.esb.api.bus.Bus;
 import org.jboss.esb.api.routing.RoutingException;
-import org.jboss.esb.api.bus.Bus;
 import org.jboss.esb.deploy.DeploymentException;
 import org.jboss.esb.deploy.DeploymentRuntime;
 import org.jboss.esb.deploy.config.PropertiesUtil;
 import org.jboss.esb.federate.bus.BusFactory;
 import org.jboss.esb.federate.bus.BusRoutingContext;
-import org.jboss.esb.federate.notify.DeploymentUndeployNotification;
 import org.jboss.esb.properties.ApplicationProperties;
 import org.jboss.esb.properties.PropertiesIterator;
 import org.jboss.esb.schedule.AbstractScheduleListener;
 import org.jboss.esb.schedule.SchedulingException;
 import org.jboss.esb.util.AssertArgument;
 
-import java.util.ArrayList;
 import java.util.List;
+import java.util.Iterator;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * Deployment Coordinator.
@@ -69,7 +69,7 @@
     /**
      * Bus listener list.
      */
-    private List<BusMediator> busMediators = new ArrayList<BusMediator>();
+    private List<BusMediator> busMediators = new CopyOnWriteArrayList<BusMediator>();
     /**
      * The Routing Context for the local deployment.
      */
@@ -133,7 +133,7 @@
                         }
                     }
                 }
-            } .iterate("bus.");
+            }.iterate("bus.");
         }
         catch (DeploymentException e)
         {
@@ -149,6 +149,7 @@
 
     /**
      * Get the {@link BusRoutingContext} associated with this deployment.
+     *
      * @return The routing context.
      */
     public final BusRoutingContext getBusRoutingContext()
@@ -157,10 +158,11 @@
     }
 
     /**
-     * Add the supplied {@link BusMediator} instance
+     * Add the supplied {@link BusMediator} instance.
+     *
      * @param busMediator Bus mediator.
      * @throws DeploymentException The Bus is not connected.
-     * @throws RoutingException Failed to send the online notification.
+     * @throws RoutingException    Failed to send the online notification.
      */
     public final void addBusMediator(final BusMediator busMediator) throws DeploymentException, RoutingException
     {
@@ -173,11 +175,26 @@
 
         busMediators.add(busMediator);
 
-        // Tell the other deployments using this bus that this deployment is online...
+        // Tell the other deployments using this bus that this deployment is online.
+        // This bus interface can then receive messages on behalf of the deployment
+        // (i.e. it will not, receive them before this message is sent)...
         busMediator.sendOnlineNotification();
     }
 
     /**
+     * Remove the supplied {@link BusMediator} instance.
+     *
+     * @param busMediator Bus mediator.
+     * @throws DeploymentException The Bus is not connected.
+     * @throws RoutingException    Failed to send the online notification.
+     */
+    public final void removeBusMediator(final BusMediator busMediator) throws DeploymentException, RoutingException
+    {
+        busMediator.disconnectBus();
+        busMediators.remove(busMediator);
+    }
+
+    /**
      * Uninitialize the coordinator.
      */
     @Uninitialize
@@ -187,23 +204,9 @@
         {
             for (BusMediator busMediator : busMediators)
             {
-                try
-                {
-                    busMediator.getBus().sendNotification(DeploymentUndeployNotification.toNotification(runtime));
-                }
-                catch (Throwable t)
-                {
-                    logger.error("Error sending undeploy notification on Bus '" + busMediator.getBus().getClass().getName() + "'.", t);
-                }
-                try
-                {
-                    busMediator.getBus().disconnect();
-                }
-                catch (Throwable t)
-                {
-                    logger.error("Error closing Bus '" + busMediator.getBus().getClass().getName() + "'.", t);
-                }
+                busMediator.disconnectBus();
             }
+            busMediators.clear();
         }
     }
 
@@ -257,9 +260,9 @@
      *
      * @return The {@link BusMediator} instances being managed by this deployment.
      */
-    public final List<BusMediator> getBusMediators()
+    public final Iterator<BusMediator> getBusMediators()
     {
-        return busMediators;
+        return busMediators.iterator();
     }
 
     /**

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusOutboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusOutboundRouter.java	2008-11-21 19:52:11 UTC (rev 24040)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusOutboundRouter.java	2008-11-21 20:58:11 UTC (rev 24041)
@@ -19,19 +19,19 @@
  */
 package org.jboss.esb.federate.bus;
 
+import org.jboss.esb.api.bus.BusMessage;
 import org.jboss.esb.api.context.AddressingContext;
 import org.jboss.esb.api.context.InvocationContext;
-import org.jboss.esb.federate.DeploymentMonitor;
 import org.jboss.esb.api.message.Message;
 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.api.bus.BusMessage;
+import org.jboss.esb.federate.DeploymentMonitor;
 
-import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
-import java.util.Iterator;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * Outbound router for a Bus.
@@ -51,7 +51,7 @@
      * via one of the connected buses.  Will be empty if no bus interfaces are
      * available that expose this Service.
      */
-    private List<DeploymentMonitor> deploymentMonitors = new ArrayList<DeploymentMonitor>();
+    private List<DeploymentMonitor> deploymentMonitors = new CopyOnWriteArrayList<DeploymentMonitor>();
 
     /**
      * Public constructor.
@@ -221,7 +221,7 @@
 
     /**
      * Does this bus router have an active monitor for a deployment
-     * that has the specifid service.
+     * that has the specified service.
      *
      * @param service The Service name.
      * @return True if this router has an active monitor for a deployment

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/invm/InVMBus.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/invm/InVMBus.java	2008-11-21 19:52:11 UTC (rev 24040)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/invm/InVMBus.java	2008-11-21 20:58:11 UTC (rev 24041)
@@ -63,7 +63,7 @@
      *
      * @throws RoutingException Connection exception.
      */
-    public void connect() throws RoutingException
+    public final void connect() throws RoutingException
     {
         assertIsConfigured();
 
@@ -76,7 +76,7 @@
      *
      * @return True if the bus is connected, otherwise false.
      */
-    public boolean isConnected()
+    public final boolean isConnected()
     {
         return (executor != null);
     }
@@ -84,7 +84,7 @@
     /**
      * Stop listening for ESB messages on the bus.
      */
-    public void stopListening()
+    public final void stopListening()
     {
         inVMInterfaces.remove(getDeploymentId());
     }
@@ -92,7 +92,7 @@
     /**
      * Disconnect from the Bus.
      */
-    public synchronized void disconnect()
+    public final synchronized void disconnect()
     {
         inVMInterfaces.remove(getDeploymentId());
         if(executor != null)
@@ -123,7 +123,7 @@
      * @param targetDeploymentId The target deployment ID.
      * @throws RoutingException Error sending message onto the Bus.
      */
-    public void sendMessage(final BusMessage message, final String targetDeploymentId) throws RoutingException
+    public final void sendMessage(final BusMessage message, final String targetDeploymentId) throws RoutingException
     {
         InVMBus targetInterface = getTargetInterface(targetDeploymentId);
 
@@ -143,7 +143,7 @@
      * @param notification The notification message to be sent onto the Bus.
      * @throws RoutingException Error sending notification onto the Bus.
      */
-    public void sendNotification(final AbstractNotification notification) throws RoutingException
+    public final void sendNotification(final AbstractNotification notification) throws RoutingException
     {
         Collection<InVMBus> interfaces = inVMInterfaces.values();
 
@@ -195,7 +195,7 @@
         }
         catch(NumberFormatException e)
         {
-            logger.error("Invalid " + INVM_THREADPOOL_SIZE + " configuration value '" + poolSizeParam + "'.  Must be a valid integer.");
+            logger.error("Invalid " + INVM_THREADPOOL_SIZE + " configuration value '" + poolSizeParam + "'.  Must be a valid integer. Defaulting to 3.");
             poolSize = 3;
         }
 
@@ -230,7 +230,7 @@
         /**
          * Run the delivery Job.
          */
-        public void run()
+        public final void run()
         {
             try
             {
@@ -272,7 +272,7 @@
         /**
          * Run the delivery Job.
          */
-        public void run()
+        public final void run()
         {
             try
             {

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-21 19:52:11 UTC (rev 24040)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceInvoker.java	2008-11-21 20:58:11 UTC (rev 24041)
@@ -20,27 +20,26 @@
 package org.jboss.esb.invoke;
 
 import org.apache.log4j.Logger;
+import org.jboss.esb.api.bus.BusMessage;
 import org.jboss.esb.api.context.AddressingContext;
 import org.jboss.esb.api.context.DeploymentContext;
 import org.jboss.esb.api.context.InvocationContext;
+import org.jboss.esb.api.history.ProcessingEventLog;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.service.ServiceName;
 import org.jboss.esb.deploy.DeploymentRuntime;
 import org.jboss.esb.deploy.DeploymentUtil;
 import org.jboss.esb.deploy.config.ServiceConfig;
+import org.jboss.esb.federate.BusMediator;
 import org.jboss.esb.federate.DeploymentMonitor;
-import org.jboss.esb.federate.BusMediator;
 import org.jboss.esb.federate.bus.BusInboundRouter;
-import org.jboss.esb.api.bus.BusMessage;
 import org.jboss.esb.federate.bus.BusRoutingContext;
-import org.jboss.esb.api.message.Message;
-import org.jboss.esb.api.service.ServiceName;
-import org.jboss.esb.api.history.ProcessingEventLog;
-import org.jboss.esb.util.AssertArgument;
 import org.jboss.esb.history.ProcessingEventLogAccessor;
+import org.jboss.esb.serialization.SerializationException;
 import org.jboss.esb.serialization.java.JavaSerializer;
-import org.jboss.esb.serialization.SerializationException;
+import org.jboss.esb.util.AssertArgument;
 
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -196,7 +195,8 @@
     private boolean routeByBus(final Message message, final AddressingContext invokeAddressingContext)
     {
         InvocationContext thisInvocationContext = InvocationContext.getContext();
-        List<BusMediator> busMediators = deploymentRuntime.getDeploymentCoordinator().getBusMediators();
+        Iterator<BusMediator> busMediators = deploymentRuntime.getDeploymentCoordinator().getBusMediators();
+
         BusMessage busMessage = new BusMessage();
 
         busMessage.setMessage(message);
@@ -205,8 +205,9 @@
 
         // Iterate over all the Bus deployments looking for a deployment that
         // is online and is hosting the target service...
-        for (BusMediator busMediator : busMediators)
+        while (busMediators.hasNext())
         {
+            BusMediator busMediator = busMediators.next();
             Iterator<Map.Entry<String,DeploymentMonitor>> monitors = busMediator.getDeploymentMonitors().entrySet().iterator();
 
             while (monitors.hasNext())

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/DeploymentCoordinatorTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/DeploymentCoordinatorTest.java	2008-11-21 19:52:11 UTC (rev 24040)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/DeploymentCoordinatorTest.java	2008-11-21 20:58:11 UTC (rev 24041)
@@ -44,16 +44,16 @@
                 DeploymentCoordinator coordinator2 = deployment2.getDeploymentCoordinator();
                 DeploymentMonitor monitor;
 
-                assertEquals(1, coordinator1.getBusMediators().get(0).getDeploymentMonitors().size());
-                assertEquals(1, coordinator2.getBusMediators().get(0).getDeploymentMonitors().size());
+                assertEquals(1, coordinator1.getBusMediators().next().getDeploymentMonitors().size());
+                assertEquals(1, coordinator2.getBusMediators().next().getDeploymentMonitors().size());
 
                 // So deployment1 should be monitoring deployment2...
-                monitor = (DeploymentMonitor) coordinator1.getBusMediators().get(0).getDeploymentMonitors().values().toArray()[0];
+                monitor = (DeploymentMonitor) coordinator1.getBusMediators().next().getDeploymentMonitors().values().toArray()[0];
                 monitor.getServiceSets().setDeploymentId("x");
                 assertEquals("{online=true} deployment2:x[Services: [hello:goodbye, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [hello:hello]]", monitor.toString());
 
                 // And deployment2 should be monitoring deployment1...
-                monitor = (DeploymentMonitor) coordinator2.getBusMediators().get(0).getDeploymentMonitors().values().toArray()[0];
+                monitor = (DeploymentMonitor) coordinator2.getBusMediators().next().getDeploymentMonitors().values().toArray()[0];
                 monitor.getServiceSets().setDeploymentId("x");
                 assertEquals("{online=true} deployment1:x[Services: [hello:hello, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [hello:hello, hello:goodbye]]", monitor.toString());
 
@@ -66,25 +66,25 @@
                     DeploymentCoordinator coordinator3 = deployment3.getDeploymentCoordinator();
 
                     // Each of the 3 deployments should be monitoring the other 2 deployments...
-                    assertEquals(2, coordinator1.getBusMediators().get(0).getDeploymentMonitors().size());
-                    assertEquals(2, coordinator2.getBusMediators().get(0).getDeploymentMonitors().size());
-                    assertEquals(2, coordinator3.getBusMediators().get(0).getDeploymentMonitors().size());
+                    assertEquals(2, coordinator1.getBusMediators().next().getDeploymentMonitors().size());
+                    assertEquals(2, coordinator2.getBusMediators().next().getDeploymentMonitors().size());
+                    assertEquals(2, coordinator3.getBusMediators().next().getDeploymentMonitors().size());
 
                     // This part of the test will just use toStrings because the monitor maps are not linked i.e. not ordered...
                     String monitorsTOString;
 
                     // deployment1 should be monitoring deployment2 and deployment3...
-                    monitorsTOString = coordinator1.getBusMediators().get(0).getDeploymentMonitors().values().toString();
+                    monitorsTOString = coordinator1.getBusMediators().next().getDeploymentMonitors().values().toString();
                     assertTrue(monitorsTOString.indexOf("{online=true} deployment2") != -1);
                     assertTrue(monitorsTOString.indexOf("{online=true} deployment3") != -1);
 
                     // deployment2 should be monitoring deployment1 and deployment3...
-                    monitorsTOString = coordinator2.getBusMediators().get(0).getDeploymentMonitors().values().toString();
+                    monitorsTOString = coordinator2.getBusMediators().next().getDeploymentMonitors().values().toString();
                     assertTrue(monitorsTOString.indexOf("{online=true} deployment1") != -1);
                     assertTrue(monitorsTOString.indexOf("{online=true} deployment3") != -1);
 
                     // deployment3 should be monitoring deployment1 and deployment2...
-                    monitorsTOString = coordinator3.getBusMediators().get(0).getDeploymentMonitors().values().toString();
+                    monitorsTOString = coordinator3.getBusMediators().next().getDeploymentMonitors().values().toString();
                     assertTrue(monitorsTOString.indexOf("{online=true} deployment1") != -1);
                     assertTrue(monitorsTOString.indexOf("{online=true} deployment2") != -1);
                 } finally {
@@ -92,16 +92,16 @@
                 }
                 Thread.sleep(500);
 
-                assertEquals(1, coordinator1.getBusMediators().get(0).getDeploymentMonitors().size());
-                assertEquals(1, coordinator2.getBusMediators().get(0).getDeploymentMonitors().size());
+                assertEquals(1, coordinator1.getBusMediators().next().getDeploymentMonitors().size());
+                assertEquals(1, coordinator2.getBusMediators().next().getDeploymentMonitors().size());
 
                 // So deployment1 should be monitoring deployment2...
-                monitor = (DeploymentMonitor) coordinator1.getBusMediators().get(0).getDeploymentMonitors().values().toArray()[0];
+                monitor = (DeploymentMonitor) coordinator1.getBusMediators().next().getDeploymentMonitors().values().toArray()[0];
                 monitor.getServiceSets().setDeploymentId("x");
                 assertEquals("{online=true} deployment2:x[Services: [hello:goodbye, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [hello:hello]]", monitor.toString());
 
                 // And deployment2 should be monitoring deployment1...
-                monitor = (DeploymentMonitor) coordinator2.getBusMediators().get(0).getDeploymentMonitors().values().toArray()[0];
+                monitor = (DeploymentMonitor) coordinator2.getBusMediators().next().getDeploymentMonitors().values().toArray()[0];
                 monitor.getServiceSets().setDeploymentId("x");
                 assertEquals("{online=true} deployment1:x[Services: [hello:hello, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [hello:hello, hello:goodbye]]", monitor.toString());
             } finally {
@@ -110,7 +110,7 @@
             Thread.sleep(500);
 
             // deployment1 should no longer be be monitoring deployment2...
-            assertEquals(0, coordinator1.getBusMediators().get(0).getDeploymentMonitors().size());
+            assertEquals(0, coordinator1.getBusMediators().next().getDeploymentMonitors().size());
         } finally {
             deployment1.undeploy();
         }
@@ -132,16 +132,16 @@
                 DeploymentCoordinator coordinator2 = deployment2.getDeploymentCoordinator();
                 DeploymentMonitor monitor;
 
-                assertEquals(1, coordinator1.getBusMediators().get(0).getDeploymentMonitors().size());
-                assertEquals(1, coordinator2.getBusMediators().get(0).getDeploymentMonitors().size());
+                assertEquals(1, coordinator1.getBusMediators().next().getDeploymentMonitors().size());
+                assertEquals(1, coordinator2.getBusMediators().next().getDeploymentMonitors().size());
 
                 // So deployment1 should be monitoring deployment2...
-                monitor = (DeploymentMonitor) coordinator1.getBusMediators().get(0).getDeploymentMonitors().values().toArray()[0];
+                monitor = (DeploymentMonitor) coordinator1.getBusMediators().next().getDeploymentMonitors().values().toArray()[0];
                 monitor.getServiceSets().setDeploymentId("x");
                 assertEquals("{online=true} deployment2:x[Services: [hello:goodbye, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [hello:hello]]", monitor.toString());
 
                 // And deployment2 should be monitoring deployment1...
-                monitor = (DeploymentMonitor) coordinator2.getBusMediators().get(0).getDeploymentMonitors().values().toArray()[0];
+                monitor = (DeploymentMonitor) coordinator2.getBusMediators().next().getDeploymentMonitors().values().toArray()[0];
                 monitor.getServiceSets().setDeploymentId("x");
                 assertEquals("{online=true} deployment1:x[Services: [hello:hello, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [hello:hello, hello:goodbye]]", monitor.toString());
 
@@ -150,7 +150,7 @@
                 Thread.sleep(6000);
 
                 // deployment2 should see deployment1 as being offline now...
-                monitor = (DeploymentMonitor) coordinator2.getBusMediators().get(0).getDeploymentMonitors().values().toArray()[0];
+                monitor = (DeploymentMonitor) coordinator2.getBusMediators().next().getDeploymentMonitors().values().toArray()[0];
                 monitor.getServiceSets().setDeploymentId("x");
                 assertEquals("{online=false} deployment1:x[Services: [hello:hello, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [hello:hello, hello:goodbye]]", monitor.toString());
 
@@ -159,7 +159,7 @@
                 Thread.sleep(6000);
 
                 // deployment2 should see deployment1 as being online again...
-                monitor = (DeploymentMonitor) coordinator2.getBusMediators().get(0).getDeploymentMonitors().values().toArray()[0];
+                monitor = (DeploymentMonitor) coordinator2.getBusMediators().next().getDeploymentMonitors().values().toArray()[0];
                 monitor.getServiceSets().setDeploymentId("x");
                 assertEquals("{online=true} deployment1:x[Services: [hello:hello, JBossESB:DeadLetterPersistanceService]][OutboundRoutedServices: [hello:hello, hello:goodbye]]", monitor.toString());
 
@@ -169,7 +169,7 @@
             Thread.sleep(100);
 
             // deployment1 should no longer be be monitoring deployment2...
-            assertEquals(0, coordinator1.getBusMediators().get(0).getDeploymentMonitors().size());
+            assertEquals(0, coordinator1.getBusMediators().next().getDeploymentMonitors().size());
         } finally {
             deployment1.undeploy();
         }




More information about the jboss-svn-commits mailing list