[jboss-svn-commits] JBL Code SVN: r22542 - in labs/jbossesb/workspace/skeagh: commons/src/test/java/org/jboss/esb/jms and 13 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Sep 9 07:36:44 EDT 2008


Author: tfennelly
Date: 2008-09-09 07:36:44 -0400 (Tue, 09 Sep 2008)
New Revision: 22542

Added:
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentUndeployNotification.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/DeploymentDetailsNotificationTest.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/DeploymentHeartbeatNotificationTest.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/DeploymentUndeployNotificationTest.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/jbossesb-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/jbossesb/busconfig/
   labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/jbossesb/busconfig/jms/
   labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties
Modified:
   labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/MessageSender.java
   labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/jms/MessageSendAndListenTest.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-inbound-router_01.xml
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/resources/log4j.xml
   labs/jbossesb/workspace/skeagh/runtime/pom.xml
   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/federate/DeploymentCoordinator.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentDetailsNotification.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentHeartbeatNotification.java
   labs/jbossesb/workspace/skeagh/testutil/src/main/java/org/jboss/esb/jms/JMSTestRunner.java
Log:
some deployment coordination code

Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/MessageSender.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/MessageSender.java	2008-09-09 10:50:16 UTC (rev 22541)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/MessageSender.java	2008-09-09 11:36:44 UTC (rev 22542)
@@ -50,7 +50,7 @@
      * @param destinationName The destination name.
      * @param jndiProperties  The JNDI properties.
      */
-    protected MessageSender(final String destinationName, final Properties jndiProperties)
+    public MessageSender(final String destinationName, final Properties jndiProperties)
     {
         super(destinationName, jndiProperties);
         logger = Logger.getLogger(getClass());

Modified: labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/jms/MessageSendAndListenTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/jms/MessageSendAndListenTest.java	2008-09-09 10:50:16 UTC (rev 22541)
+++ labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/jms/MessageSendAndListenTest.java	2008-09-09 11:36:44 UTC (rev 22542)
@@ -33,8 +33,6 @@
  */
 public class MessageSendAndListenTest extends TestCase
 {
-    private static final String TEST_PROVIDER_URL = "tcp://localhost:61717";    
-
     public void test_Topic_noselector() throws Exception
     {
         test_Destination_noselector(Topic.class, "jbossesb.testTopic");
@@ -57,7 +55,7 @@
 
     private void test_Destination_noselector(final Class<? extends Destination> destType, final String destName) throws Exception
     {
-        new JMSTestRunner(TEST_PROVIDER_URL) {
+        new JMSTestRunner() {
             public void test() throws Exception
             {
                 Properties jndiProperties = getJndiProperties();
@@ -101,7 +99,7 @@
 
     private void test_Destination_withselector(final Class<? extends Destination> destType, final String destName) throws Exception
     {
-        new JMSTestRunner(TEST_PROVIDER_URL) {
+        new JMSTestRunner() {
             public void test() throws Exception
             {
                 Properties jndiProperties = getJndiProperties();

Modified: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java	2008-09-09 10:50:16 UTC (rev 22541)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java	2008-09-09 11:36:44 UTC (rev 22542)
@@ -20,21 +20,12 @@
  */
 package org.jboss.esb.jms;
 
-import org.jboss.esb.deploy.DeploymentException;
 import org.jboss.esb.deploy.DeploymentRuntime;
 import org.jboss.esb.deploy.config.digest.DigestUtil;
-import org.jboss.esb.routing.InboundRouter;
-import org.jboss.esb.service.ServiceName;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import org.junit.Ignore;
 import org.junit.Test;
 
-import javax.jms.JMSException;
 import javax.jms.Session;
 import javax.jms.TextMessage;
-import javax.naming.Context;
-import java.io.IOException;
 import java.util.Properties;
 
 /**
@@ -45,13 +36,12 @@
  */
 public class JmsInboundRouterTest
 {
-    private static final String TEST_PROVIDER_URL = "tcp://localhost:61616";
     private static final String DESTINATION_NAME = "jbossesb.TestQueue";
 
     @Test
     public final void initializeConfOverride() throws Exception
     {
-        new JMSTestRunner(TEST_PROVIDER_URL) {
+        new JMSTestRunner() {
             @Override
             public void test() throws Exception
             {

Modified: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-inbound-router_01.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-inbound-router_01.xml	2008-09-09 10:50:16 UTC (rev 22541)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-inbound-router_01.xml	2008-09-09 11:36:44 UTC (rev 22542)
@@ -4,7 +4,7 @@
         <inRouters serviceCategory="service-cat" serviceName="service-a">
         
             <inRouter name="inrouter1" class="org.jboss.esb.jms.JmsInboundRouter">
-                <property name="java.naming.provider.url">tcp://localhost:61616</property>
+                <property name="java.naming.provider.url">tcp://localhost:61717</property>
                 <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
                 <property name="jmsDestination">jbossesb.TestQueue</property>
                 <property name="queue.jbossesb.TestQueue">jbossesb.TestQueue</property>

Modified: labs/jbossesb/workspace/skeagh/routing/jms/src/test/resources/log4j.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/resources/log4j.xml	2008-09-09 10:50:16 UTC (rev 22541)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/resources/log4j.xml	2008-09-09 11:36:44 UTC (rev 22542)
@@ -7,8 +7,6 @@
 <!--                                                                       -->
 <!-- ===================================================================== -->
 
-<!-- $Id: log4j.xml,v 1.26.2.5 2005/09/15 09:31:02 dimitris Exp $ -->
-
 <!--
    | For more configuration infromation and examples see the Jakarta Log4j
    | owebsite: http://jakarta.apache.org/log4j
@@ -44,7 +42,7 @@
       <priority value="error"/>
    </category>
 
-   <category name="org.jboss.esb.jms">
+   <category name="org.jboss.esb">
       <priority value="info"/>
    </category>
    

Modified: labs/jbossesb/workspace/skeagh/runtime/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/pom.xml	2008-09-09 10:50:16 UTC (rev 22541)
+++ labs/jbossesb/workspace/skeagh/runtime/pom.xml	2008-09-09 11:36:44 UTC (rev 22542)
@@ -30,6 +30,12 @@
             <version>${jboss.esb.version}</version>
         </dependency>
         <dependency>
+            <groupId>jboss</groupId>
+            <artifactId>jboss-j2ee</artifactId>
+            <version>${jboss.eap.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.milyn</groupId>
             <artifactId>milyn-smooks-javabean</artifactId>
             <version>1.1-SNAPSHOT</version>

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-09-09 10:50:16 UTC (rev 22541)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java	2008-09-09 11:36:44 UTC (rev 22542)
@@ -30,8 +30,10 @@
 import org.jboss.esb.deploy.config.ServiceConfig;
 import org.jboss.esb.dispatch.DispatcherProxy;
 import org.jboss.esb.dispatch.LocalDispatcher;
+import org.jboss.esb.federate.DeploymentCoordinator;
 import org.jboss.esb.message.MessageTransformer;
 import org.jboss.esb.schedule.JobScheduler;
+import org.jboss.esb.schedule.SimpleSchedule;
 import org.jboss.esb.service.Service;
 import org.jboss.esb.service.ServiceName;
 import org.jboss.esb.util.AssertArgument;
@@ -70,7 +72,7 @@
     /**
      * Unique deployment ID.
      */
-    private String deploymentID = UUID.randomUUID().toString();
+    private String deploymentID = UUID.randomUUID().toString().replace('-', 'x');
     /**
      * The list of configurations associated with this deployment instance.
      */
@@ -90,6 +92,10 @@
         }
     };
     /**
+     * Deployed resources list.
+     */
+    private Map<String, Object> deployedResources = new LinkedHashMap<String, Object>();
+    /**
      * Undeployed Objects List.
      */
     private List<Object> undeployedObjects = new ArrayList<Object>();
@@ -199,6 +205,7 @@
             deployOutboundRouters();
             deployServices();
             deployInboundRouters();
+            deployDeploymentCoordinator();
         }
         catch (DeploymentException e)
         {
@@ -287,8 +294,6 @@
      */
     private void deployResources() throws DeploymentException
     {
-        Map<String, Object> deployedResources = new LinkedHashMap<String, Object>();
-
         // Expose the deployed resources via the DeploymentContext...
         context.setResources(deployedResources);
 
@@ -330,7 +335,6 @@
             {
                 deployObject(resource, key, null);
                 logger.debug("Deployed resource '" + key + "' (" + resource.getClass().getName() + ").");
-                deployedObjects.put(key, resource);
                 deployedResources.put(key, resource);
             }
             catch (InvocationTargetException e)
@@ -362,7 +366,6 @@
                 {
                     deployObject(service.getValue().getService(), null, service.getKey());
                     logger.debug("Deployed service '" + service.getKey() + "' (" + service.getValue().getClass().getName() + ").");
-                    deployedObjects.put(service.getKey(), service.getValue().getService());
                 }
                 catch (InvocationTargetException e)
                 {
@@ -419,7 +422,6 @@
                         // Now deploy the router...
                         deployObject(routerConfig.getRouter(), routerConfig.getName(), serviceName);
                         logger.debug("Deployed InboundRouter '" + routerConfig.getName() + "' (" + routerConfig.getRouter().getClass().getName() + ").");
-                        deployedObjects.put(routerConfig.getName(), routerConfig.getRouter());
                     }
                     catch (InvocationTargetException e)
                     {
@@ -435,6 +437,29 @@
     }
 
     /**
+     * Deploy the deployment coordinator.
+     * @throws DeploymentException Unable to deploy DeploymentCoordinator.
+     */
+    private void deployDeploymentCoordinator() throws DeploymentException
+    {
+        DeploymentCoordinator coordinator = new DeploymentCoordinator(this);
+        try
+        {
+            SimpleSchedule schedule = new SimpleSchedule();
+
+            schedule.setFrequency(1000);
+            schedule.setExecCount(-1);
+            deployResource(DeploymentCoordinator.DEPLOYMENT_COORDINTATION_SCHEDULE_KEY, schedule, deployedResources);
+            coordinator.setScheduleResourceId(DeploymentCoordinator.DEPLOYMENT_COORDINTATION_SCHEDULE_KEY);
+            deployObject(coordinator, "DeploymentCoordinator", null);
+        }
+        catch (Throwable t)
+        {
+            throw new DeploymentException("Unable to deploy DeploymentCoordinator.", t.getCause());
+        }
+    }
+
+    /**
      * Get the named Service instance from the specified {@link org.jboss.esb.deploy.config.DeploymentUnit}.
      *
      * @param deploymentUnit The configuration unit.
@@ -476,7 +501,6 @@
                         // Now deploy the router...
                         deployObject(routerConfig.getRouter(), routerConfig.getName(), routerConfigMap.getKey());
                         logger.debug("Deployed OutboundRouter '" + routerConfig.getName() + "' (" + routerConfig.getRouter().getClass().getName() + ").");
-                        deployedObjects.put(routerConfig.getName(), routerConfig.getRouter());
                     }
                     catch (InvocationTargetException e)
                     {
@@ -509,7 +533,6 @@
                 {
                     deployObject(transformer, null, serviceName);
                     logger.debug("Deployed transformer for router '" + routerConfigName + "' (" + transformer.getClass().getName() + ").");
-                    deployedObjects.put(transformer, transformer);
                 }
                 catch (InvocationTargetException e)
                 {
@@ -548,6 +571,7 @@
             ClassUtil.setFieldValue(object, "serviceName", serviceName);
         }
         ClassUtil.execAnnotatedMethod(object, Initialize.class);
+        deployedObjects.put((objectName != null?objectName:object), object);
     }
 
     /**

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-09-09 10:50:16 UTC (rev 22541)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java	2008-09-09 11:36:44 UTC (rev 22542)
@@ -19,12 +19,29 @@
  */
 package org.jboss.esb.federate;
 
+import org.apache.log4j.Logger;
 import org.jboss.esb.annotations.Initialize;
+import org.jboss.esb.annotations.Uninitialize;
+import org.jboss.esb.classpath.ClassUtil;
+import org.jboss.esb.deploy.DeploymentException;
 import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.federate.notify.DeploymentDetailsNotification;
+import org.jboss.esb.federate.notify.DeploymentHeartbeatNotification;
+import org.jboss.esb.jms.AbstractMessageListener;
+import org.jboss.esb.jms.MessageSender;
+import org.jboss.esb.properties.ApplicationProperties;
 import org.jboss.esb.schedule.AbstractScheduleListener;
 import org.jboss.esb.schedule.SchedulingException;
 import org.jboss.esb.util.AssertArgument;
 
+import javax.jms.JMSException;
+import javax.jms.Message;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
 /**
  * Deployment Coordinator.
  * <p/>
@@ -36,31 +53,260 @@
 public class DeploymentCoordinator extends AbstractScheduleListener
 {
     /**
+     * Deployment coordination schedule key name.
+     */
+    public static final String DEPLOYMENT_COORDINTATION_SCHEDULE_KEY = "deployment.coordintation.schedule";
+    /**
+     * Deployment coordination topic property key name.
+     */
+    public static final String DEPLOYMENT_COORDINTATION_TOPIC_KEY = "deployment.coordintation.topic";
+    /**
+     * Default deployment coordination topic name.
+     */
+    public static final String DEFAULT_DEPLOYMENT_COORDINTATION_TOPIC_NAME = "jbossesb.deployment.coordintation.topic";
+
+    /**
+     * Logger.
+     */
+    private static Logger logger = Logger.getLogger(DeploymentCoordinator.class);
+    /**
      * Deployment Units.
      */
     private DeploymentRuntime runtime;
+    /**
+     * Heartbeat notification object.
+     */
+    private DeploymentHeartbeatNotification heartbeatNotification;
+    /**
+     * Service details notification object.
+     */
+    private DeploymentDetailsNotification detailsNotification;
+    /**
+     * Deployment coordination listener.
+     */
+    private CoordinationListener coordinationListener;
+    /**
+     * Deployment coordination broadcaster.
+     */
+    private MessageSender coordinationBroadcaster;
 
     /**
      * Public constructor.
+     *
      * @param runtime The Deployment runtime with which the coordinator is associated.
      */
     public DeploymentCoordinator(final DeploymentRuntime runtime)
     {
         AssertArgument.isNotNull(runtime, "runtime");
         this.runtime = runtime;
+
+        // Initialize the notification objects...
+        heartbeatNotification = DeploymentHeartbeatNotification.toNotification(runtime);
+        detailsNotification = DeploymentDetailsNotification.toNotification(runtime);
     }
 
+    /**
+     * Initialize the coordinator.
+     */
     @Initialize
-    public void initialize()
+    public void initialize() throws DeploymentException
     {
+        Properties localBusProperties = null;
+        try
+        {
+            localBusProperties = DeploymentCoordinator.getBusConfig("jms", runtime.getDeploymentName());
+        }
+        catch (IOException e)
+        {
+            throw new DeploymentException("Failed to read local bus deployment configuration", e);
+        }
 
+        if(localBusProperties != null)
+        {
+            connectCoordinationListener(localBusProperties);
+            if (coordinationListener != null && coordinationListener.isConnected())
+            {
+                try
+                {
+                    connectCoordinationBroadcaster(localBusProperties);
+                }
+                catch (Throwable t)
+                {
+                    throw new DeploymentException("Unable to initialize Deployment Coordinator.", t);
+                }
+            }
+        }
     }
 
     /**
+     * Uninitialize the coordinator.
+     */
+    @Uninitialize
+    public void uninitialize()
+    {
+        if (coordinationListener != null && coordinationListener.isConnected())
+        {
+            try
+            {
+                coordinationListener.close();
+            }
+            catch (Throwable t)
+            {
+                logger.warn("Error closing deployment coordination listener for deployment '" + runtime.getDeploymentName() + "'.", t);
+            }
+        }
+        if (coordinationBroadcaster != null && coordinationBroadcaster.isConnected())
+        {
+            try
+            {
+                coordinationBroadcaster.close();
+            }
+            catch (Throwable t)
+            {
+                logger.warn("Error closing deployment coordination broadcaster for deployment '" + runtime.getDeploymentName() + "'.", t);
+            }
+        }
+    }
+
+    /**
      * Deployment management schedule handler.
+     *
      * @throws SchedulingException Exception processing schedule event.
      */
     public final void onSchedule() throws SchedulingException
     {
     }
+
+    /**
+     * Coordination Event Listener.
+     */
+    private class CoordinationListener extends AbstractMessageListener
+    {
+        protected CoordinationListener(final String destinationName, final Properties jndiProperties)
+        {
+            super(destinationName, jndiProperties);
+        }
+
+        public void onMessage(Message message)
+        {
+        }
+    }
+
+    /**
+     * Get the bus configuration for the specified protocol and deployment name combination.
+     * <p/>
+     * Checks in the following order:
+     * <ol>
+     * <li>File: "busconfig/&lt;protpcol&gt;/&lt;deploymentName&gt;.properties"</li>
+     * <li>Classpath: "/META-INF/busconfig/&lt;protpcol&gt;/&lt;deploymentName&gt;.properties"</li>
+     * <li>Classpath: "/META-INF/busconfig/&lt;protpcol&gt;/default.properties"</li>
+     * </ol>
+     * <p/>
+     * <b><u>NOTE:</u></b> The protocol string is lowercased and the deployment name is URL encoded
+     * (application/x-www-form-urlencoded).
+     *
+     * @param protocol       The protocol name e.g. "jms".
+     * @param deploymentName The deployment name e.g. "Order_Service".
+     * @return The bus configuration as a {@link Properties} instance.
+     * @throws IOException Unable to read configuration.
+     */
+    public static Properties getBusConfig(final String protocol, final String deploymentName) throws IOException
+    {
+        String firstCheckPath = "busconfig/" + protocol + "/" + deploymentName + ".properties";
+        String secondCheckPath = "/META-INF/jbossesb/" + firstCheckPath;
+        String thirdCheckPath = "/META-INF/jbossesb/busconfig/" + protocol + "/" + "default.properties";
+        InputStream configStream;
+
+        // 1st: Check for a deployment specific config on the local file system...
+        File firstCheckFile = new File(firstCheckPath);
+        if (firstCheckFile.exists() && !firstCheckFile.isDirectory())
+        {
+            return readConfig(new FileInputStream(firstCheckFile));
+        }
+
+        // 2nd: Check for a deployment specific config on the classpath...
+        configStream = ClassUtil.getResourceAsStream(secondCheckPath, DeploymentCoordinator.class);
+        if (configStream != null)
+        {
+            return readConfig(configStream);
+        }
+
+        // 3rd: Check for a the default config on the classpath...
+        configStream = ClassUtil.getResourceAsStream(thirdCheckPath, DeploymentCoordinator.class);
+        if (configStream != null)
+        {
+            return readConfig(configStream);
+        }
+
+        logger.debug("Unable to find JBoss ESB Bus configuration for protocol '" + protocol + "', deployment '" + deploymentName + "'. Tried:\n" +
+                "\t1. File: " + firstCheckPath + "\n" +
+                "\t2. Classpath: " + secondCheckPath + "\n" +
+                "\t3. Classpath: " + thirdCheckPath);
+
+        return null;
+    }
+
+    /**
+     * Read the stream to a {@link Properties} instance.
+     *
+     * @param configStream The configuration stream.
+     * @return The {@link Properties} instance.
+     * @throws IOException Unable to read the configuration.
+     */
+    private static Properties readConfig(InputStream configStream) throws IOException
+    {
+        ApplicationProperties properties = new ApplicationProperties();
+        properties.load(configStream);
+        return properties;
+    }
+
+    /**
+     * Connect the deployment coordination listener.
+     *
+     * @param localBusProperties Bus configuration properties.
+     */
+    private void connectCoordinationListener(Properties localBusProperties)
+    {
+        String coordinationTopicName = localBusProperties.getProperty(DEPLOYMENT_COORDINTATION_TOPIC_KEY, DEFAULT_DEPLOYMENT_COORDINTATION_TOPIC_NAME);
+
+        coordinationListener = new CoordinationListener(coordinationTopicName, localBusProperties);
+        try
+        {
+            coordinationListener.connect();
+        }
+        catch (JMSException e)
+        {
+            coordinationListener = null;
+            logger.info("Deployment '" + runtime.getDeploymentName() + "' is not being coordinated with any other local deployment.  Turn on deug logging for more details.");
+            if (logger.isDebugEnabled())
+            {
+                logger.debug("Deployment '" + runtime.getDeploymentName() + "' is not being coordinated with any other local deployment.  A JMSException occured while trying " +
+                        "to connect to the deployment coordination Topic '" + coordinationTopicName + "'. The JMS Server must be running and this Topic must be deployed. " +
+                        "JNDI properties used: " + localBusProperties);
+            }
+        }
+    }
+
+    /**
+     * Connect the deployment coordination broadcaster.
+     *
+     * @param localBusProperties Bus configuration properties.
+     */
+    private void connectCoordinationBroadcaster(Properties localBusProperties) throws DeploymentException
+    {
+        String coordinationTopicName = localBusProperties.getProperty(DEPLOYMENT_COORDINTATION_TOPIC_KEY, DEFAULT_DEPLOYMENT_COORDINTATION_TOPIC_NAME);
+
+        coordinationBroadcaster = new MessageSender(coordinationTopicName, localBusProperties);
+        try
+        {
+            coordinationBroadcaster.connect();
+        }
+        catch (JMSException e)
+        {
+            coordinationBroadcaster = null;
+            throw new DeploymentException("Deployment '" + runtime.getDeploymentName() + "' is not being coordinated with any other local deployment.  A JMSException occured while trying " +
+                    "to connect to the deployment coordination Topic '" + coordinationTopicName + "'. The JMS Server must be running and this Topic must be deployed. " +
+                    "JNDI properties used: " + localBusProperties, e);
+        }
+    }
 }

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentDetailsNotification.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentDetailsNotification.java	2008-09-09 10:50:16 UTC (rev 22541)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentDetailsNotification.java	2008-09-09 11:36:44 UTC (rev 22542)
@@ -23,7 +23,7 @@
 import org.jboss.esb.deploy.config.DeploymentUnit;
 import org.jboss.esb.service.ServiceName;
 
-import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -87,14 +87,14 @@
      * @param runtime The DeploymentRuntime instance.
      * @return The DeploymentDetailsNotification instance.
      */
-    public final DeploymentDetailsNotification toNotification(final DeploymentRuntime runtime)
+    public static DeploymentDetailsNotification toNotification(final DeploymentRuntime runtime)
     {
         DeploymentDetailsNotification notification = new DeploymentDetailsNotification();
 
         notification.setName(runtime.getDeploymentName());
         notification.setId(runtime.getDeploymentID());
-        notification.services = new HashSet<ServiceName>();
-        notification.outboundRoutedServices = new HashSet<ServiceName>();
+        notification.services = new LinkedHashSet<ServiceName>();
+        notification.outboundRoutedServices = new LinkedHashSet<ServiceName>();
 
         List<DeploymentUnit> deploymentUnits = runtime.getDeploymentUnits();
         for (DeploymentUnit deploymentUnit : deploymentUnits)

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentHeartbeatNotification.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentHeartbeatNotification.java	2008-09-09 10:50:16 UTC (rev 22541)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentHeartbeatNotification.java	2008-09-09 11:36:44 UTC (rev 22542)
@@ -37,7 +37,7 @@
      * @param runtime The DeploymentRuntime instance.
      * @return The DeploymentHeartbeatNotification instance.
      */
-    public final DeploymentHeartbeatNotification toNotification(final DeploymentRuntime runtime)
+    public static DeploymentHeartbeatNotification toNotification(final DeploymentRuntime runtime)
     {
         DeploymentHeartbeatNotification notification = new DeploymentHeartbeatNotification();
 

Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentUndeployNotification.java (from rev 22524, labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentHeartbeatNotification.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentUndeployNotification.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/DeploymentUndeployNotification.java	2008-09-09 11:36:44 UTC (rev 22542)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, 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.notify;
+
+import org.jboss.esb.deploy.DeploymentRuntime;
+
+/**
+ * Deployment undeploy notification.
+ * <p/>
+ * Used to signal to other deployments that a particular deployment has
+ * undeployed.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class DeploymentUndeployNotification extends AbstractDeploymentNotification
+{
+
+    /**
+     * DeploymentRuntime to DeploymentUndeployNotification helper method.
+     * @param runtime The DeploymentRuntime instance.
+     * @return The DeploymentUndeployNotification instance.
+     */
+    public static DeploymentUndeployNotification toNotification(final DeploymentRuntime runtime)
+    {
+        DeploymentUndeployNotification notification = new DeploymentUndeployNotification();
+
+        notification.setName(runtime.getDeploymentName());
+        notification.setId(runtime.getDeploymentID());
+
+        return notification;
+    }
+}
\ No newline at end of file


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

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/DeploymentDetailsNotificationTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/DeploymentDetailsNotificationTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/DeploymentDetailsNotificationTest.java	2008-09-09 11:36:44 UTC (rev 22542)
@@ -0,0 +1,28 @@
+
+package org.jboss.esb.federate.notify;
+
+import junit.framework.TestCase;
+import org.jboss.esb.deploy.config.digest.DigestUtil;
+import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.deploy.DeploymentRuntime;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class DeploymentDetailsNotificationTest extends TestCase
+{
+
+    public void test() throws DeploymentException, IOException
+    {
+        DeploymentRuntime rt = DigestUtil.digestConfig(getClass().getResourceAsStream("jbossesb-config.xml"));
+        DeploymentDetailsNotification notification = DeploymentDetailsNotification.toNotification(rt);
+
+        assertEquals("$UNKNOWN$", notification.getName());
+        assertNotNull(notification.getId());
+        assertEquals(36, notification.getId().length());
+        assertEquals("[a:a, c:c]", notification.getServices().toString());
+        assertEquals("[a:a, b:b]", notification.getOutboundRoutedServices().toString());
+    }
+}


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

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/DeploymentHeartbeatNotificationTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/DeploymentHeartbeatNotificationTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/DeploymentHeartbeatNotificationTest.java	2008-09-09 11:36:44 UTC (rev 22542)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, 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.notify;
+
+import junit.framework.TestCase;
+import org.jboss.esb.deploy.DeploymentRuntime;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class DeploymentHeartbeatNotificationTest extends TestCase
+{
+    public void test()
+    {
+        DeploymentRuntime rt = new DeploymentRuntime();
+
+        rt.setDeploymentName("name");
+        rt.setDeploymentID("XXX");
+
+        DeploymentHeartbeatNotification notification = DeploymentHeartbeatNotification.toNotification(rt);
+
+        assertEquals("name", notification.getName());
+        assertEquals("XXX", notification.getId());
+    }
+}


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

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/DeploymentUndeployNotificationTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/DeploymentUndeployNotificationTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/DeploymentUndeployNotificationTest.java	2008-09-09 11:36:44 UTC (rev 22542)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, 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.notify;
+
+import junit.framework.TestCase;
+import org.jboss.esb.deploy.DeploymentRuntime;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class DeploymentUndeployNotificationTest extends TestCase
+{
+    public void test()
+    {
+        DeploymentRuntime rt = new DeploymentRuntime();
+
+        rt.setDeploymentName("name");
+        rt.setDeploymentID("XXX");
+
+        DeploymentUndeployNotification notification = DeploymentUndeployNotification.toNotification(rt);
+
+        assertEquals("name", notification.getName());
+        assertEquals("XXX", notification.getId());
+    }
+}
\ No newline at end of file


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

Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/jbossesb-config.xml (from rev 22518, labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/jbossesb-outrouters_01.xml)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/jbossesb-config.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/jbossesb-config.xml	2008-09-09 11:36:44 UTC (rev 22542)
@@ -0,0 +1,21 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd" xmlns:xprot="http://www.jboss.org/jbossesb/xsd/xprot/xprot.xsd">
+
+    <services>
+        <service serviceCategory="a" serviceName="a" serviceDescription="a" class="org.jboss.esb.deploy.config.MyTestService" />
+        <service serviceCategory="c" serviceName="c" serviceDescription="a" class="org.jboss.esb.deploy.config.MyTestService" />
+    </services>
+
+    <routing>
+        <outRouters serviceCategory="a" serviceName="a">
+            <outRouter name="outrouter1" class="org.jboss.esb.deploy.config.MyOutRouter">
+                <property name="myparam">1</property>
+            </outRouter>
+        </outRouters>
+        <outRouters serviceCategory="b" serviceName="b">
+            <outRouter name="outrouter3" class="org.jboss.esb.deploy.config.MyOutRouter">
+                <property name="myparam">4</property>
+            </outRouter>
+        </outRouters>
+    </routing>
+
+</jbossesb>
\ No newline at end of file


Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/notify/jbossesb-config.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + native

Added: labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties	2008-09-09 11:36:44 UTC (rev 22542)
@@ -0,0 +1,15 @@
+###########################################################################################
+# Default JMS config bus config for testing.
+#
+# Using ActiveMQ because it's so easy to embed.  Apparently JBM v2.0 will also be
+# easy to embed.  We might be able to switch to that then!! 
+##########################################################################################
+
+# JNDI Settings...
+# NOTE: The JNDI settings in this config file must be the same as those
+# set in the JMSTestRunner class!!
+java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
+java.naming.provider.url=tcp://localhost:61717
+
+# Bus Queues and Topics...
+topic.jbossesb.deployment.coordintation.topic=jbossesb.deployment.coordintation.topic
\ No newline at end of file


Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: labs/jbossesb/workspace/skeagh/testutil/src/main/java/org/jboss/esb/jms/JMSTestRunner.java
===================================================================
--- labs/jbossesb/workspace/skeagh/testutil/src/main/java/org/jboss/esb/jms/JMSTestRunner.java	2008-09-09 10:50:16 UTC (rev 22541)
+++ labs/jbossesb/workspace/skeagh/testutil/src/main/java/org/jboss/esb/jms/JMSTestRunner.java	2008-09-09 11:36:44 UTC (rev 22542)
@@ -35,13 +35,21 @@
  */
 public abstract class JMSTestRunner
 {
+    public static final String DEFAULT_PROVIDER_URL = "tcp://localhost:61717";
+
     private Properties jndiProperties;
-    private String providerUrl;
+    private String providerUrl = DEFAULT_PROVIDER_URL;
 
-    public JMSTestRunner(String providerUrl)
+    public JMSTestRunner()
     {
         jndiProperties = new Properties();
         jndiProperties.setProperty(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getName());
+        jndiProperties.setProperty(Context.PROVIDER_URL, DEFAULT_PROVIDER_URL);
+    }
+
+    public JMSTestRunner(String providerUrl)
+    {
+        this();
         jndiProperties.setProperty(Context.PROVIDER_URL, providerUrl);
         this.providerUrl = providerUrl;
     }




More information about the jboss-svn-commits mailing list