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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Nov 22 04:16:05 EST 2008


Author: tfennelly
Date: 2008-11-22 04:16:04 -0500 (Sat, 22 Nov 2008)
New Revision: 24049

Added:
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/BusInjectionTest.java
Removed:
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/bus/
Modified:
   labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/bus/Bus.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/deploy/DeploymentUtil.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/federate/bus/invm/InVMBus.java
Log:
https://jira.jboss.org/jira/browse/JBESB-2182

Modified: labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/bus/Bus.java
===================================================================
--- labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/bus/Bus.java	2008-11-22 01:14:42 UTC (rev 24048)
+++ labs/jbossesb/workspace/skeagh/api/src/main/java/org/jboss/esb/api/bus/Bus.java	2008-11-22 09:16:04 UTC (rev 24049)
@@ -26,8 +26,13 @@
 /**
  * JBoss ESB Bus definition.
  * <p/>
- * Implementations of this interface act as the interface to a specfic
+ * Implementations of this interface act as the interface to a specific
  * message aware Bus implementation, for the local deployment.
+ * <p/>
+ * Note the use of the word "interface".  A {@link Bus} instance is <u>not</u> an instance of the physical Bus,
+ * but just an "interface" to a Bus.  There would typically be just a single instance of
+ * a physical Bus (e.g. a JMS Queue), shared between multiple deployments, but each deployment would have their
+ * own individual instance of an "interface" to that Bus, through an instance of the {@link Bus} interface. 
  *
  * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</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 01:14:42 UTC (rev 24048)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java	2008-11-22 09:16:04 UTC (rev 24049)
@@ -33,8 +33,8 @@
 import org.jboss.esb.deploy.config.InboundRouterConfig;
 import org.jboss.esb.deploy.config.InboundRouterFilterConfig;
 import org.jboss.esb.deploy.config.OutboundRouterConfig;
+import org.jboss.esb.deploy.config.PropertiesUtil;
 import org.jboss.esb.deploy.config.ServiceConfig;
-import org.jboss.esb.deploy.config.PropertiesUtil;
 import org.jboss.esb.deploy.config.digest.DefaultConfigurationDigester;
 import org.jboss.esb.dispatch.DispatchChain;
 import org.jboss.esb.dispatch.FilteredDispatchChain;
@@ -278,12 +278,26 @@
 
     /**
      * Deploy the Runtime.
+     * <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.
      */
     public final void deploy() throws DeploymentException
     {
+        deploy(true);
+    }
+
+    /**
+     * Deploy the Runtime.
+     *
+     * @param autoDeployBusInterfaces Flag to indicate whether or not the {@link org.jboss.esb.federate.DeploymentCoordinator}
+     * should auto-deploy the configured {@link org.jboss.esb.api.bus.Bus} interfaces for the deployment.
+     * @throws org.jboss.esb.deploy.DeploymentException Error deploying ESB Runtime.
+     */
+    public final void deploy(final boolean autoDeployBusInterfaces) throws DeploymentException
+    {
         assertConfigurationsAdded();
 
         if (context != null)
@@ -317,7 +331,7 @@
                 deployServices();
                 assembleDispatchChainMap();
                 deployInboundRouters();
-                deployDeploymentCoordinator();
+                deployDeploymentCoordinator(autoDeployBusInterfaces);
             }
             catch (DeploymentException e)
             {
@@ -784,10 +798,12 @@
      * Deploy the deployment coordinator.
      *
      * @throws DeploymentException Unable to deploy DeploymentCoordinator.
+     * @param autoDeployBusInterfaces Flag to indicate whether or not the {@link org.jboss.esb.federate.DeploymentCoordinator}
+     * should auto-deploy the configured {@link org.jboss.esb.api.bus.Bus} interfaces for the deployment.
      */
-    private void deployDeploymentCoordinator() throws DeploymentException
+    private void deployDeploymentCoordinator(final boolean autoDeployBusInterfaces) throws DeploymentException
     {
-        deploymentCoordinator = new DeploymentCoordinator(this);
+        deploymentCoordinator = new DeploymentCoordinator(this, autoDeployBusInterfaces);
         try
         {
             SimpleSchedule heartbeatSchedule = new SimpleSchedule();

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentUtil.java	2008-11-22 01:14:42 UTC (rev 24048)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentUtil.java	2008-11-22 09:16:04 UTC (rev 24049)
@@ -172,7 +172,7 @@
      * @throws org.jboss.esb.deploy.DeploymentException
      *                             Error digesting configuration.
      */
-    private static DeploymentRuntime createRuntime(final InputStream deploymentConfig, final DeploymentRuntime runtime) throws DeploymentException, IOException
+    public static DeploymentRuntime createRuntime(final InputStream deploymentConfig, final DeploymentRuntime runtime) throws DeploymentException, IOException
     {
         final DefaultConfigurationDigester digester = new DefaultConfigurationDigester(runtime.getResourceLocator());
         final DeploymentUnit deploymentUnit = digester.digest(deploymentConfig);

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 01:14:42 UTC (rev 24048)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/BusMediator.java	2008-11-22 09:16:04 UTC (rev 24049)
@@ -41,7 +41,7 @@
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
- * JBoss ESB Deployment Bus Listener.
+ * JBoss ESB Deployment Bus Mediator.
  * <p/>
  * Coordinates the details of interfacing to a Bus on behalf of a deployment.
  *

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 01:14:42 UTC (rev 24048)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java	2008-11-22 09:16:04 UTC (rev 24049)
@@ -26,7 +26,6 @@
 import org.jboss.esb.api.routing.RoutingException;
 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.properties.ApplicationProperties;
@@ -35,8 +34,8 @@
 import org.jboss.esb.schedule.SchedulingException;
 import org.jboss.esb.util.AssertArgument;
 
+import java.util.Iterator;
 import java.util.List;
-import java.util.Iterator;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
@@ -67,23 +66,31 @@
      */
     private boolean broadcastHeartbeat = true;
     /**
-     * Bus listener list.
+     * Bus mediator list.
      */
     private List<BusMediator> busMediators = new CopyOnWriteArrayList<BusMediator>();
     /**
      * The Routing Context for the local deployment.
      */
     private BusRoutingContext busRoutingContext;
+    /**
+     * Flag to indicate whether or not the {@link org.jboss.esb.federate.DeploymentCoordinator}
+     * should auto-deploy the configured {@link org.jboss.esb.api.bus.Bus} interfaces for the deployment.
+     */
+    private boolean autoDeployBusInterfaces;
 
     /**
      * Public constructor.
      *
      * @param runtime The Deployment runtime with which the coordinator is associated.
+     * @param autoDeployBusInterfaces Flag to indicate whether or not the {@link org.jboss.esb.federate.DeploymentCoordinator}
+     * should auto-deploy the configured {@link org.jboss.esb.api.bus.Bus} interfaces for the deployment.
      */
-    public DeploymentCoordinator(final DeploymentRuntime runtime)
+    public DeploymentCoordinator(final DeploymentRuntime runtime, final boolean autoDeployBusInterfaces)
     {
         AssertArgument.isNotNull(runtime, "runtime");
         this.runtime = runtime;
+        this.autoDeployBusInterfaces = autoDeployBusInterfaces;
     }
 
     /**
@@ -94,16 +101,33 @@
     @Initialize
     public final void initialize() throws DeploymentException
     {
-        ApplicationProperties deploymentProperties = PropertiesUtil.getDeploymentConfig(runtime.getDeploymentName(), runtime.getResourceLocator());
-
         // Create the BusRoutingContext before starting the local bus interfaces.
         // This way it's available to have DeploymentMonitors attached and receive messages
         // as soon as this deployment gets "online" notifications from other deployments...
         busRoutingContext = runtime.createRoutingContext();
 
-        // Start all configured bus interfaces...
+        if(autoDeployBusInterfaces)
+        {
+            // Start all configured bus interfaces...
+            deployConfiguredBusInterfaces();
+        }
+    }
+
+    /**
+     * Deploy all the configured {@link Bus} interfaces for the deployment.
+     * <p/>
+     * A deployment's set of {@link Bus} interfaces can be configured in the deployment's configuration, or can be injected
+     * manually via the {@link #addBusMediator(BusMediator)} method, and removed via the {@link #removeBusMediator(BusMediator)}
+     * method.
+     *
+     * @throws DeploymentException Unable to start one of the {@link Bus} interfaces.
+     */
+    public final void deployConfiguredBusInterfaces() throws DeploymentException
+    {
         try
         {
+            ApplicationProperties deploymentProperties = runtime.getDeploymentProperties();
+
             new PropertiesIterator(deploymentProperties)
             {
                 @Override
@@ -159,6 +183,8 @@
 
     /**
      * Add the supplied {@link BusMediator} instance.
+     * <p/>
+     * This allows a {@link Bus} interface to be manually injected at runtime e.g. as an OSGi service.
      *
      * @param busMediator Bus mediator.
      * @throws DeploymentException The Bus is not connected.
@@ -187,6 +213,7 @@
      * @param busMediator Bus mediator.
      * @throws DeploymentException The Bus is not connected.
      * @throws RoutingException    Failed to send the online notification.
+     * @see #addBusMediator(BusMediator)
      */
     public final void removeBusMediator(final BusMediator busMediator) throws DeploymentException, RoutingException
     {

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-22 01:14:42 UTC (rev 24048)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/invm/InVMBus.java	2008-11-22 09:16:04 UTC (rev 24049)
@@ -29,6 +29,7 @@
 
 import java.util.Collection;
 import java.util.Map;
+import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -59,6 +60,15 @@
     private ExecutorService executor;
 
     /**
+     * Default constructor.
+     */
+    public InVMBus()
+    {
+        // Set a default config (empty)...
+        setProperties(new Properties());
+    }
+
+    /**
      * Connect to the bus.
      *
      * @throws RoutingException Connection exception.

Added: 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	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/BusInjectionTest.java	2008-11-22 09:16:04 UTC (rev 24049)
@@ -0,0 +1,33 @@
+/*
+ * 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()
+    {
+    }
+}


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




More information about the jboss-svn-commits mailing list