[jboss-svn-commits] JBL Code SVN: r24005 - in labs/jbossesb/workspace/skeagh: commons/src/main/java/org/jboss/esb/util and 19 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Nov 20 15:33:51 EST 2008
Author: tfennelly
Date: 2008-11-20 15:33:51 -0500 (Thu, 20 Nov 2008)
New Revision: 24005
Added:
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/bus/BusFactory.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/BusNotificationListener.java
Removed:
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/NotificationListener.java
Modified:
labs/jbossesb/workspace/skeagh/api/
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/FileUtil.java
labs/jbossesb/workspace/skeagh/container/
labs/jbossesb/workspace/skeagh/container/osgi/
labs/jbossesb/workspace/skeagh/examples/
labs/jbossesb/workspace/skeagh/examples/file-router/
labs/jbossesb/workspace/skeagh/examples/jms-router/
labs/jbossesb/workspace/skeagh/performance/
labs/jbossesb/workspace/skeagh/routing/
labs/jbossesb/workspace/skeagh/routing/file/
labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/util/FileRouterUtil.java
labs/jbossesb/workspace/skeagh/routing/jms/
labs/jbossesb/workspace/skeagh/routing/pom.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/bus/Bus.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBus.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
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/bus/jms/JMSBus_Standalone_Test.java
Log:
https://jira.jboss.org/jira/browse/JBESB-2182
Property changes on: labs/jbossesb/workspace/skeagh/api
___________________________________________________________________
Name: svn:ignore
- api.iml
+ api.iml
jbossesb-api.iml
Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/FileUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/FileUtil.java 2008-11-20 19:31:23 UTC (rev 24004)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/FileUtil.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -274,21 +274,22 @@
{
AssertArgument.isNotNullAndNotEmpty(fromExpression, "expression");
- final int indexOfFileSeparator = fromExpression.indexOf(File.separatorChar);
- final int indexOfVariable = fromExpression.indexOf('$');
+ final String normalizedFromExpression = fromExpression.replace('\\', '/');
+ final int indexOfFileSeparator = normalizedFromExpression.indexOf('/');
+ final int indexOfVariable = normalizedFromExpression.indexOf('$');
// A path was specified.
if (indexOfFileSeparator != -1)
{
if (indexOfVariable != -1)
{
- return new File(fromExpression.substring(0, indexOfVariable));
+ return new File(normalizedFromExpression.substring(0, indexOfVariable));
}
else
{
// No variables exist in expression. This is simply a path to a file.
// Return the File object to the parent and not the file itself.
- return new File(fromExpression).getParentFile();
+ return new File(normalizedFromExpression).getParentFile();
}
}
Property changes on: labs/jbossesb/workspace/skeagh/container
___________________________________________________________________
Name: svn:ignore
+ container.iml
Property changes on: labs/jbossesb/workspace/skeagh/container/osgi
___________________________________________________________________
Name: svn:ignore
+ jbossesb-osgi-runtime.iml
Property changes on: labs/jbossesb/workspace/skeagh/examples
___________________________________________________________________
Name: svn:ignore
+ examples.iml
Property changes on: labs/jbossesb/workspace/skeagh/examples/file-router
___________________________________________________________________
Name: svn:ignore
+ jbossesb-examples-file-router.iml
Property changes on: labs/jbossesb/workspace/skeagh/examples/jms-router
___________________________________________________________________
Name: svn:ignore
+ jbossesb-examples-jms-router.iml
Property changes on: labs/jbossesb/workspace/skeagh/performance
___________________________________________________________________
Name: svn:ignore
+ jbossesb-perf.iml
jbossesb-perf.ipr
jbossesb-perf.iws
Property changes on: labs/jbossesb/workspace/skeagh/routing
___________________________________________________________________
Name: svn:ignore
+ routing.iml
Property changes on: labs/jbossesb/workspace/skeagh/routing/file
___________________________________________________________________
Name: svn:ignore
+ jbossesb-routing-file.iml
Modified: labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/util/FileRouterUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/util/FileRouterUtil.java 2008-11-20 19:31:23 UTC (rev 24004)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/main/java/org/jboss/esb/file/util/FileRouterUtil.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -20,14 +20,14 @@
*/
package org.jboss.esb.file.util;
-import java.io.File;
-import java.io.IOException;
-
import org.jboss.esb.api.exception.ConfigurationException;
import org.jboss.esb.classpath.ClassUtil;
import org.jboss.esb.file.FileOutboundRouter;
import org.jboss.esb.util.FileUtil;
+import java.io.File;
+import java.io.IOException;
+
/**
* Utility methods that are common to File Routers, both inbound and
* outbound.
@@ -83,6 +83,12 @@
public static File createTargetDirectory(final String pattern) throws ConfigurationException
{
final File dir = FileUtil.evalTargetDirectory(pattern);
+
+ if(dir == null)
+ {
+ throw new ConfigurationException("Unable to evaluate target directory '" + pattern + "'.");
+ }
+
try
{
FileUtil.createDestinationDirectory(dir);
Property changes on: labs/jbossesb/workspace/skeagh/routing/jms
___________________________________________________________________
Name: svn:ignore
+ jbossesb-routing-jms.iml
Modified: labs/jbossesb/workspace/skeagh/routing/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/pom.xml 2008-11-20 19:31:23 UTC (rev 24004)
+++ labs/jbossesb/workspace/skeagh/routing/pom.xml 2008-11-20 20:33:51 UTC (rev 24005)
@@ -15,7 +15,7 @@
<url>http://www.jboss.org/jbossesb/</url>
<modules>
- <module>file</module>
+ <!-- module>file</module -->
<module>jms</module>
</modules>
Modified: labs/jbossesb/workspace/skeagh/runtime/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/pom.xml 2008-11-20 19:31:23 UTC (rev 24004)
+++ labs/jbossesb/workspace/skeagh/runtime/pom.xml 2008-11-20 20:33:51 UTC (rev 24005)
@@ -35,7 +35,7 @@
<dependency>
<groupId>org.milyn</groupId>
<artifactId>milyn-smooks-javabean</artifactId>
- <version>1.1-SNAPSHOT</version>
+ <version>1.1</version>
</dependency>
<dependency>
<groupId>quartz</groupId>
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-20 19:31:23 UTC (rev 24004)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -37,6 +37,7 @@
import org.jboss.esb.dispatch.FilteredDispatchChain;
import org.jboss.esb.dispatch.LocalDispatcher;
import org.jboss.esb.federate.DeploymentCoordinator;
+import org.jboss.esb.federate.BusMediator;
import org.jboss.esb.federate.bus.BusDispatcher;
import org.jboss.esb.federate.bus.BusInboundRouter;
import org.jboss.esb.federate.bus.BusOutboundRouter;
@@ -791,7 +792,7 @@
{
SimpleSchedule heartbeatSchedule = new SimpleSchedule();
- heartbeatSchedule.setFrequency(deploymentProperties.getLongProperty(DeploymentCoordinator.COORDINATOR_HEARTBEAT_FREQUENCY_KEY, DeploymentCoordinator.COORDINATOR_HEARTBEAT_DEFAULT_FREQUENCY));
+ heartbeatSchedule.setFrequency(deploymentProperties.getLongProperty(BusMediator.COORDINATOR_HEARTBEAT_FREQUENCY_KEY, BusMediator.COORDINATOR_HEARTBEAT_DEFAULT_FREQUENCY));
heartbeatSchedule.setExecCount(-1);
deployResource(DeploymentCoordinator.DEPLOYMENT_COORDINTATION_SCHEDULE_KEY, heartbeatSchedule, deployedResources);
deploymentCoordinator.setScheduleResourceId(DeploymentCoordinator.DEPLOYMENT_COORDINTATION_SCHEDULE_KEY);
Added: 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 (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/BusMediator.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -0,0 +1,382 @@
+/*
+ * 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 org.apache.log4j.Logger;
+import org.jboss.esb.api.context.AddressingContext;
+import org.jboss.esb.api.context.DeploymentContext;
+import org.jboss.esb.api.routing.RoutingException;
+import org.jboss.esb.api.service.ServiceName;
+import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.federate.bus.Bus;
+import org.jboss.esb.federate.bus.BusInboundRouter;
+import org.jboss.esb.federate.bus.BusMessage;
+import org.jboss.esb.federate.bus.BusMessageListener;
+import org.jboss.esb.federate.bus.BusOutboundRouter;
+import org.jboss.esb.federate.bus.BusRoutingContext;
+import org.jboss.esb.federate.notify.AbstractDeploymentNotification;
+import org.jboss.esb.federate.notify.DeploymentDetailsNotification;
+import org.jboss.esb.federate.notify.DeploymentHeartbeatNotification;
+import org.jboss.esb.federate.notify.DeploymentUndeployNotification;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * JBoss ESB Deployment Bus Listener.
+ * <p/>
+ * Coordinates the details of interfacing to a Bus on behalf of a deployment.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public final class BusMediator
+{
+ /**
+ * logger.
+ */
+ private static Logger logger = Logger.getLogger(BusMediator.class);
+ /**
+ * The Bus.
+ */
+ private Bus bus;
+ /**
+ * DeploymentRuntime associated with the Bus interface.
+ */
+ private DeploymentRuntime runtime;
+ /**
+ * The local deployment's bus routing context.
+ */
+ private BusRoutingContext routingContext;
+ /**
+ * Bus notification listener.
+ */
+ private BusNotificationListener notificationListener = new BusNotificationListener();
+ /**
+ * Bus message listener for the local deployment.
+ */
+ private DeploymentBusMessageListener busMessageListener = new DeploymentBusMessageListener();
+ /**
+ * Deployment monitors - monitoring other deployments using this bus.
+ */
+ private Map<String, DeploymentMonitor> deploymentMonitors = new ConcurrentHashMap<String, DeploymentMonitor>();
+ /**
+ * Heartbeat notification object to be sent out on the bus.
+ */
+ private DeploymentHeartbeatNotification heartbeatNotification;
+ /**
+ * Online notification object to be sent out on the bus.
+ */
+ private DeploymentDetailsNotification onlineNotification;
+ /**
+ * 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.
+ */
+ public static final long COORDINATOR_HEARTBEAT_DEFAULT_FREQUENCY = 5000;
+
+ /**
+ * Private constructor.
+ *
+ * @param bus The Bus.
+ * @param runtime DeploymentRuntime associated with the Bus interface.
+ */
+ public BusMediator(final Bus bus, final DeploymentRuntime runtime)
+ {
+ this.bus = bus;
+ this.runtime = runtime;
+ bus.setNotificationListener(notificationListener);
+ bus.setMessageListener(busMessageListener);
+
+ routingContext = runtime.getDeploymentCoordinator().getBusRoutingContext();
+
+ // Initialize the notification objects...
+ heartbeatNotification = DeploymentHeartbeatNotification.toNotification(runtime);
+ onlineNotification = DeploymentDetailsNotification.toNotification(runtime);
+
+ // Set the deploymnt monitor timeout - 3 missed heartbeats...
+ monitorTimeout = (runtime.getDeploymentProperties().getLongProperty(COORDINATOR_HEARTBEAT_FREQUENCY_KEY, COORDINATOR_HEARTBEAT_DEFAULT_FREQUENCY) * 3);
+ }
+
+ /**
+ * Get the Bus instance associated with the BusDeployment instance.
+ *
+ * @return The Bus instance associated with the BusDeployment instance.
+ */
+ public Bus getBus()
+ {
+ return bus;
+ }
+
+ /**
+ * Get all active Deployment Monitors for this Bus deployment.
+ *
+ * @return All active Deployment Monitors for this Bus deployment.
+ */
+ public Map<String, DeploymentMonitor> getDeploymentMonitors()
+ {
+ return deploymentMonitors;
+ }
+
+ /**
+ * Send the online notification.
+ * @throws RoutingException Failed to send notification.
+ */
+ public final void sendOnlineNotification() throws RoutingException
+ {
+ bus.sendNotification(onlineNotification);
+ }
+
+ /**
+ * Send the heartbeat notification.
+ * @throws RoutingException Failed to send notification.
+ */
+ public final void sendHeartbeatNotification() throws RoutingException
+ {
+ bus.sendNotification(heartbeatNotification);
+ }
+
+ /**
+ * Attach the specified DeploymentMonitor instance to all
+ * BusOutboundRouter instances that manage a service or out routers
+ * for the Service associated with the BusOutboundRouter instance.
+ *
+ * @param monitor The DeploymentMonitor.
+ * @see #detachDeploymentMonitor(DeploymentMonitor)
+ */
+ private void attachDeploymentMonitor(final DeploymentMonitor monitor)
+ {
+ synchronized (routingContext)
+ {
+ Set<Map.Entry<ServiceName, BusOutboundRouter>> serviceOutRouterSet = routingContext.getBusOutRouters().entrySet();
+
+ for (Map.Entry<ServiceName, BusOutboundRouter> serviceOutRouter : serviceOutRouterSet)
+ {
+ ServiceName serviceName = serviceOutRouter.getKey();
+
+ if (monitor.hasService(serviceName) || monitor.hasServiceRouter(serviceName))
+ {
+ BusOutboundRouter router = serviceOutRouter.getValue();
+ router.addMonitor(monitor);
+ }
+ }
+ }
+ }
+
+ /**
+ * Detach the specified DeploymentMonitor instance from any
+ * BusOutboundRouter instances that hold a reference to it.
+ *
+ * @param monitor The DeploymentMonitor.
+ * @see #attachDeploymentMonitor(DeploymentMonitor)
+ */
+ private void detachDeploymentMonitor(final DeploymentMonitor monitor)
+ {
+ synchronized (routingContext)
+ {
+ Set<Map.Entry<ServiceName, BusOutboundRouter>> serviceOutRouterSet = routingContext.getBusOutRouters().entrySet();
+
+ for (Map.Entry<ServiceName, BusOutboundRouter> serviceOutRouter : serviceOutRouterSet)
+ {
+ BusOutboundRouter router = serviceOutRouter.getValue();
+ router.removeMonitor(monitor);
+ }
+ }
+ }
+
+ /**
+ * Bus notification listener.
+ */
+ private class BusNotificationListener implements org.jboss.esb.federate.notify.BusNotificationListener
+ {
+ /**
+ * Deployment notification handler.
+ *
+ * @param notification The notification.
+ * @throws org.jboss.esb.deploy.DeploymentException Invalid deployment detected.
+ */
+ public final synchronized void onNotification(final AbstractDeploymentNotification notification) throws DeploymentException
+ {
+ String deploymentId = notification.getDeploymentId();
+
+ if (runtime.getDeploymentId().equals(deploymentId))
+ {
+ throw new DeploymentException("Cannot accept deployment notification for deployment '" + deploymentId + "'. Deployment IDs must be unique!");
+ }
+
+ if (notification instanceof DeploymentHeartbeatNotification)
+ {
+ DeploymentMonitor deploymentMonitor = deploymentMonitors.get(deploymentId);
+ if (deploymentMonitor != null)
+ {
+ deploymentMonitor.setLastHeartbeat(System.currentTimeMillis());
+ deploymentMonitor.setOnline(true);
+ }
+ else
+ {
+ logger.warn("Deployment '" + runtime.getDeploymentName() + ":" + runtime.getDeploymentId() + "' received heartbeat from unknown deployment '" + notification.getDeploymentName() + ":" + notification.getDeploymentId() + "'.");
+ // Send our deployment details... will trigger the other deployment
+ // to send its details...
+ sendDeploymentDetailsNotification();
+ }
+ }
+ else if (notification instanceof DeploymentDetailsNotification)
+ {
+ DeploymentMonitor monitor = deploymentMonitors.get(deploymentId);
+ DeploymentDetailsNotification deployNotification = (DeploymentDetailsNotification) notification;
+
+ if (monitor != null)
+ {
+ // If the monitor for the current deployment says the deployment is not online, and the
+ // new deployment looks to be the same as the current deployment, just mark
+ // the current deployment as being online again...
+ if (!monitor.isOnline() && monitor.getServiceSets().equals(deployNotification.getServiceSet()))
+ {
+ monitor.setOnline(true);
+ }
+
+ // If the other deployment is already monitoring this deployment, no
+ // need to notify... just return...
+ if (deployNotification.getMonitoredDeployments().contains(runtime.getDeploymentId()))
+ {
+ return;
+ }
+ }
+ else
+ {
+ // New deployment. Add a monitor...
+ monitor = new DeploymentMonitor(deployNotification.getServiceSet(), bus, runtime.getContext());
+ attachDeploymentMonitor(monitor);
+ deploymentMonitors.put(deploymentId, monitor);
+ onlineNotification.getMonitoredDeployments().add(deploymentId);
+ }
+
+ // Send out the deployment details of this deployment so the new deployment
+ // can register them....
+ sendDeploymentDetailsNotification();
+ }
+ else if (notification instanceof DeploymentUndeployNotification)
+ {
+ DeploymentMonitor monitor = deploymentMonitors.get(deploymentId);
+
+ if (monitor != null)
+ {
+ detachDeploymentMonitor(monitor);
+ deploymentMonitors.remove(deploymentId);
+ onlineNotification.getMonitoredDeployments().remove(deploymentId);
+ }
+ else
+ {
+ logger.warn("Received undeploy notification for deployment with deploymentId '" + deploymentId + "'. Unknown deployment.");
+ }
+ }
+ }
+
+ /**
+ * Send the deployment details for this deployment out onto the bus.
+ *
+ * @throws org.jboss.esb.deploy.DeploymentException Failed to send.
+ */
+ private void sendDeploymentDetailsNotification() throws DeploymentException
+ {
+ try
+ {
+ bus.sendNotification(onlineNotification);
+ }
+ catch (RoutingException e)
+ {
+ throw new DeploymentException("Failed to send DeploymentDetails notification broadcast out onto Bus (" + bus.getClass().getName() + ").", e);
+ }
+ }
+ }
+
+ /**
+ * Bus notification listener.
+ */
+ private class DeploymentBusMessageListener implements BusMessageListener
+ {
+ /**
+ * BusMessage handler.
+ *
+ * @param busMessage The message.
+ * @throws org.jboss.esb.api.routing.RoutingException Error handling the bus message.
+ */
+ public void onMessage(final BusMessage busMessage) throws RoutingException
+ {
+ AddressingContext addressing = busMessage.getAddressingContext();
+ if (addressing == null)
+ {
+ throw new RoutingException("Invalid ESB Message. AddressingContext not set on BusMessage.");
+ }
+
+ ServiceName toService = addressing.getTo();
+ if (toService == null)
+ {
+ throw new RoutingException("Invalid ESB Message. 'To' address not set. Message from '" + addressing.getFrom() + "'.");
+ }
+
+ BusInboundRouter inRouter = routingContext.getBusInRouters().get(toService);
+ if (inRouter == null)
+ {
+ throw new RoutingException("Invalid ESB Message from '" + addressing.getFrom() + "'. Service '" + toService + "' unknown on this deployment.");
+ }
+
+ // And hand it off to the inrouter to manage the processing of it...
+ DeploymentContext.setContext(runtime.getContext());
+ try
+ {
+ inRouter.receive(busMessage);
+ }
+ finally
+ {
+ DeploymentContext.setContext(null);
+ }
+ }
+ }
+
+ /**
+ * Check the monitors.
+ * <p/>
+ * Checks are the monitored deployments still online.
+ */
+ public void checkMonitors()
+ {
+ // TODO: Do we need to synchronize this? The ConcurrentHashMap docs would suggest it's OK to iterate the Map as long as you don't use an Iterator....
+ long currentTime = System.currentTimeMillis();
+ Set<Map.Entry<String, DeploymentMonitor>> deploymentMonitorSet = deploymentMonitors.entrySet();
+ for (Map.Entry<String, DeploymentMonitor> entry : deploymentMonitorSet)
+ {
+ DeploymentMonitor deploymentMonitor = entry.getValue();
+ if (currentTime > deploymentMonitor.getLastHeartbeat() + monitorTimeout)
+ {
+ deploymentMonitor.setOnline(false);
+ }
+ }
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/BusMediator.java
___________________________________________________________________
Name: svn:eol-style
+ native
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-20 19:31:23 UTC (rev 24004)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -22,35 +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.context.AddressingContext;
-import org.jboss.esb.api.context.DeploymentContext;
+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.Bus;
-import org.jboss.esb.federate.bus.BusInboundRouter;
-import org.jboss.esb.federate.bus.BusMessage;
-import org.jboss.esb.federate.bus.BusMessageListener;
-import org.jboss.esb.federate.bus.BusOutboundRouter;
+import org.jboss.esb.federate.bus.BusFactory;
import org.jboss.esb.federate.bus.BusRoutingContext;
-import org.jboss.esb.federate.notify.AbstractDeploymentNotification;
-import org.jboss.esb.federate.notify.DeploymentDetailsNotification;
-import org.jboss.esb.federate.notify.DeploymentHeartbeatNotification;
import org.jboss.esb.federate.notify.DeploymentUndeployNotification;
-import org.jboss.esb.federate.notify.NotificationListener;
import org.jboss.esb.properties.ApplicationProperties;
import org.jboss.esb.properties.PropertiesIterator;
-import org.jboss.esb.api.routing.RoutingException;
import org.jboss.esb.schedule.AbstractScheduleListener;
import org.jboss.esb.schedule.SchedulingException;
-import org.jboss.esb.api.service.ServiceName;
import org.jboss.esb.util.AssertArgument;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
/**
* Deployment Coordinator.
@@ -66,14 +53,6 @@
* Deployment coordination schedule key name.
*/
public static final String DEPLOYMENT_COORDINTATION_SCHEDULE_KEY = "deployment.coordintation.schedule";
- /**
- * Heartbeat frequency config key.
- */
- public static final String COORDINATOR_HEARTBEAT_FREQUENCY_KEY = "coordinator.heartbeat.frequency";
- /**
- * Default heartbeat frequency.
- */
- public static final long COORDINATOR_HEARTBEAT_DEFAULT_FREQUENCY = 5000;
/**
* Logger.
@@ -84,29 +63,17 @@
*/
private DeploymentRuntime runtime;
/**
- * Heartbeat notification object.
- */
- private DeploymentHeartbeatNotification heartbeatNotification;
- /**
* Flag for turning on/off heartbeat broadcasting.
*/
private boolean broadcastHeartbeat = true;
/**
- * Service details notification object.
+ * Bus listener list.
*/
- private DeploymentDetailsNotification detailsNotification;
+ private List<BusMediator> busMediators = new ArrayList<BusMediator>();
/**
- * Bus list.
- */
- private List<BusDeployment> busDeployments = new ArrayList<BusDeployment>();
- /**
- * Coordinator monitor timeout. The number of milliseconds before a deployment is marked as offline.
- */
- private long monitorTimeout;
- /**
* The Routing Context for the local deployment.
*/
- private BusRoutingContext routingContext;
+ private BusRoutingContext busRoutingContext;
/**
* Public constructor.
@@ -117,10 +84,6 @@
{
AssertArgument.isNotNull(runtime, "runtime");
this.runtime = runtime;
-
- // Initialize the notification objects...
- heartbeatNotification = DeploymentHeartbeatNotification.toNotification(runtime);
- detailsNotification = DeploymentDetailsNotification.toNotification(runtime);
}
/**
@@ -133,13 +96,10 @@
{
ApplicationProperties deploymentProperties = PropertiesUtil.getDeploymentConfig(runtime.getDeploymentName(), runtime.getResourceLocator());
- // Set the deploymnt monitor timeout - 3 missed heartbeats...
- monitorTimeout = (deploymentProperties.getLongProperty(COORDINATOR_HEARTBEAT_FREQUENCY_KEY, COORDINATOR_HEARTBEAT_DEFAULT_FREQUENCY) * 3);
-
// 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...
- routingContext = runtime.createRoutingContext();
+ busRoutingContext = runtime.createRoutingContext();
// Start all configured bus interfaces...
try
@@ -149,27 +109,19 @@
@Override
public void processEntry(final String busProtocol, final String busClassName) throws DeploymentException
{
- Bus bus = Bus.Factory.newInstance(busClassName);
- ApplicationProperties busProperties = PropertiesUtil.getBusConfig(busProtocol, runtime.getDeploymentName(), runtime.getResourceLocator());
+ Bus bus = BusFactory.newInstance(busProtocol, busClassName, runtime);
- bus.setDeploymentName(runtime.getDeploymentName());
- bus.setDeploymentId(runtime.getDeploymentId());
- bus.setProperties(busProperties);
bus.connect();
-
if (bus.isConnected())
{
- busDeployments.add(new BusDeployment(bus));
-
try
{
- // Tell the other deployments using this bus that this deployment is online...
- bus.sendNotification(detailsNotification);
+ addBusMediator(new BusMediator(bus, runtime));
}
catch (RoutingException e)
{
bus.close();
- logger.error("Unable to start Bus. Failed to deliver Deployment Details Notification (on statrup) to bus '" + bus.getClass().getName() + "'.", e);
+ logger.error("Unable to start Bus Interface. Failed to deliver Deployment Details Notification (on statrup) to bus '" + bus.getClass().getName() + "'.", e);
return;
}
}
@@ -189,30 +141,60 @@
}
/**
+ * Get the {@link BusRoutingContext} associated with this deployment.
+ * @return The routing context.
+ */
+ public final BusRoutingContext getBusRoutingContext()
+ {
+ return busRoutingContext;
+ }
+
+ /**
+ * 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.
+ */
+ public final void addBusMediator(final BusMediator busMediator) throws DeploymentException, RoutingException
+ {
+ Bus bus = busMediator.getBus();
+
+ if (!bus.isConnected())
+ {
+ throw new DeploymentException("Cannot add a BusMediator for a bus that is not connected.");
+ }
+
+ busMediators.add(busMediator);
+
+ // Tell the other deployments using this bus that this deployment is online...
+ busMediator.sendOnlineNotification();
+ }
+
+ /**
* Uninitialize the coordinator.
*/
@Uninitialize
public final void uninitialize()
{
- if (!busDeployments.isEmpty())
+ if (!busMediators.isEmpty())
{
- for (BusDeployment busDeployment : busDeployments)
+ for (BusMediator busMediator : busMediators)
{
try
{
- busDeployment.getBus().sendNotification(DeploymentUndeployNotification.toNotification(runtime));
+ busMediator.getBus().sendNotification(DeploymentUndeployNotification.toNotification(runtime));
}
catch (Throwable t)
{
- logger.error("Error sending undeploy notification on Bus '" + busDeployment.getBus().getClass().getName() + "'.", t);
+ logger.error("Error sending undeploy notification on Bus '" + busMediator.getBus().getClass().getName() + "'.", t);
}
try
{
- busDeployment.getBus().close();
+ busMediator.getBus().close();
}
catch (Throwable t)
{
- logger.error("Error closing Bus '" + busDeployment.getBus().getClass().getName() + "'.", t);
+ logger.error("Error closing Bus '" + busMediator.getBus().getClass().getName() + "'.", t);
}
}
}
@@ -226,28 +208,28 @@
@Override
public final void onSchedule() throws SchedulingException
{
- if (!busDeployments.isEmpty())
+ if (!busMediators.isEmpty())
{
- for (BusDeployment busDeployment : busDeployments)
+ for (BusMediator busMediator : busMediators)
{
try
{
if (broadcastHeartbeat)
{
- busDeployment.getBus().sendNotification(heartbeatNotification);
+ busMediator.sendHeartbeatNotification();
}
}
catch (Throwable t)
{
- logger.error("Error sending heartbeat notification on Bus '" + busDeployment.getBus().getClass().getName() + "'.", t);
+ logger.error("Error sending heartbeat notification on Bus '" + busMediator.getBus().getClass().getName() + "'.", t);
}
try
{
- busDeployment.checkMonitors();
+ busMediator.checkMonitors();
}
catch (Throwable t)
{
- logger.error("Error checking monitors on Bus '" + busDeployment.getBus().getClass().getName() + "'.", t);
+ logger.error("Error checking monitors on Bus '" + busMediator.getBus().getClass().getName() + "'.", t);
}
}
}
@@ -264,13 +246,13 @@
}
/**
- * Get the {@link BusDeployment} instances being managed by this deployment.
+ * Get the {@link BusMediator} instances being managed by this deployment.
*
- * @return The {@link BusDeployment} instances being managed by this deployment.
+ * @return The {@link BusMediator} instances being managed by this deployment.
*/
- public final List<BusDeployment> getBusDeployments()
+ public final List<BusMediator> getBusMediators()
{
- return busDeployments;
+ return busMediators;
}
/**
@@ -278,290 +260,16 @@
*/
public final void stopListeningOnBuses()
{
- for (BusDeployment busDeployment : busDeployments)
+ for (BusMediator busMediator : busMediators)
{
try
{
- busDeployment.bus.stopListening();
+ busMediator.getBus().stopListening();
}
catch (Throwable t)
{
- logger.error("Error while stopping message listening on Bus '" + busDeployment.bus.getClass().getName() + "'.", t);
+ logger.error("Error while stopping message listening on Bus '" + busMediator.getBus().getClass().getName() + "'.", t);
}
}
}
-
- /**
- * Attach the specified DeploymentMonitor instance to all
- * BusOutboundRouter instances that manage a service or out routers
- * for the Service associated with the BusOutboundRouter instance.
- *
- * @param monitor The DeploymentMonitor.
- * @see #detachDeploymentMonitor(DeploymentMonitor)
- */
- private void attachDeploymentMonitor(final DeploymentMonitor monitor)
- {
- synchronized (routingContext)
- {
- Set<Map.Entry<ServiceName, BusOutboundRouter>> serviceOutRouterSet = routingContext.getBusOutRouters().entrySet();
-
- for (Map.Entry<ServiceName, BusOutboundRouter> serviceOutRouter : serviceOutRouterSet)
- {
- ServiceName serviceName = serviceOutRouter.getKey();
-
- if (monitor.hasService(serviceName) || monitor.hasServiceRouter(serviceName))
- {
- BusOutboundRouter router = serviceOutRouter.getValue();
- router.addMonitor(monitor);
- }
- }
- }
- }
-
-
- /**
- * Detach the specified DeploymentMonitor instance from any
- * BusOutboundRouter instances that hold a reference to it.
- *
- * @param monitor The DeploymentMonitor.
- * @see #attachDeploymentMonitor(DeploymentMonitor)
- */
- private void detachDeploymentMonitor(final DeploymentMonitor monitor)
- {
- synchronized (routingContext)
- {
- Set<Map.Entry<ServiceName, BusOutboundRouter>> serviceOutRouterSet = routingContext.getBusOutRouters().entrySet();
-
- for (Map.Entry<ServiceName, BusOutboundRouter> serviceOutRouter : serviceOutRouterSet)
- {
- BusOutboundRouter router = serviceOutRouter.getValue();
- router.removeMonitor(monitor);
- }
- }
- }
-
- /**
- * JBoss ESB Deployment.
- */
- public final class BusDeployment
- {
- /**
- * The Bus.
- */
- private Bus bus;
- /**
- * Bus notification listener.
- */
- private NotificationListener notificationListener = new BusNotificationListener();
- /**
- * Bus message listener for the local deployment.
- */
- private DeploymentBusMessageListener busMessageListener = new DeploymentBusMessageListener();
- /**
- * Deployment monitors - monitoring other deployments using this bus.
- */
- private Map<String, DeploymentMonitor> deploymentMonitors = new ConcurrentHashMap<String, DeploymentMonitor>();
-
- /**
- * Private constructor.
- *
- * @param bus The Bus.
- */
- private BusDeployment(final Bus bus)
- {
- this.bus = bus;
- bus.setNotificationListener(notificationListener);
- bus.setBusMessageListener(busMessageListener);
- }
-
- /**
- * Get the Bus instance associated with the BusDeployment instance.
- *
- * @return The Bus instance associated with the BusDeployment instance.
- */
- public Bus getBus()
- {
- return bus;
- }
-
- /**
- * Get all active Deployment Monitors for this Bus deployment.
- *
- * @return All active Deployment Monitors for this Bus deployment.
- */
- public Map<String, DeploymentMonitor> getDeploymentMonitors()
- {
- return deploymentMonitors;
- }
-
- /**
- * Bus notification listener.
- */
- private class BusNotificationListener implements NotificationListener
- {
- /**
- * Deployment notification handler.
- *
- * @param notification The notification.
- * @throws DeploymentException Invalid deployment detected.
- */
- public final synchronized void onNotification(final AbstractDeploymentNotification notification) throws DeploymentException
- {
- String deploymentId = notification.getDeploymentId();
-
- if (runtime.getDeploymentId().equals(deploymentId))
- {
- throw new DeploymentException("Cannot accept deployment notification for deployment '" + deploymentId + "'. Deployment IDs must be unique!");
- }
-
- if (notification instanceof DeploymentHeartbeatNotification)
- {
- DeploymentMonitor deploymentMonitor = deploymentMonitors.get(deploymentId);
- if (deploymentMonitor != null)
- {
- deploymentMonitor.setLastHeartbeat(System.currentTimeMillis());
- deploymentMonitor.setOnline(true);
- }
- else
- {
- logger.warn("Deployment '" + runtime.getDeploymentName() + ":" + runtime.getDeploymentId() + "' received heartbeat from unknown deployment '" + notification.getDeploymentName() + ":" + notification.getDeploymentId() + "'.");
- // Send our deployment details... will trigger the other deployment
- // to send its details...
- sendDeploymentDetailsNotification();
- }
- }
- else if (notification instanceof DeploymentDetailsNotification)
- {
- DeploymentMonitor monitor = deploymentMonitors.get(deploymentId);
- DeploymentDetailsNotification deployNotification = (DeploymentDetailsNotification) notification;
-
- if (monitor != null)
- {
- // If the monitor for the current deployment says the deployment is not online, and the
- // new deployment looks to be the same as the current deployment, just mark
- // the current deployment as being online again...
- if (!monitor.isOnline() && monitor.getServiceSets().equals(deployNotification.getServiceSet()))
- {
- monitor.setOnline(true);
- }
-
- // If the other deployment is already monitoring this deployment, no
- // need to notify... just return...
- if (deployNotification.getMonitoredDeployments().contains(runtime.getDeploymentId()))
- {
- return;
- }
- }
- else
- {
- // New deployment. Add a monitor...
- monitor = new DeploymentMonitor(deployNotification.getServiceSet(), bus, runtime.getContext());
- attachDeploymentMonitor(monitor);
- deploymentMonitors.put(deploymentId, monitor);
- detailsNotification.getMonitoredDeployments().add(deploymentId);
- }
-
- // Send out the deployment details of this deployment so the new deployment
- // can register them....
- sendDeploymentDetailsNotification();
- }
- else if (notification instanceof DeploymentUndeployNotification)
- {
- DeploymentMonitor monitor = deploymentMonitors.get(deploymentId);
-
- if (monitor != null)
- {
- detachDeploymentMonitor(monitor);
- deploymentMonitors.remove(deploymentId);
- detailsNotification.getMonitoredDeployments().remove(deploymentId);
- }
- else
- {
- logger.warn("Received undeploy notification for deployment with deploymentId '" + deploymentId + "'. Unknown deployment.");
- }
- }
- }
-
- /**
- * Send the deployment details for this deployment out onto the bus.
- *
- * @throws DeploymentException Failed to send.
- */
- private void sendDeploymentDetailsNotification() throws DeploymentException
- {
- try
- {
- bus.sendNotification(detailsNotification);
- }
- catch (RoutingException e)
- {
- throw new DeploymentException("Failed to send DeploymentDetails notification broadcast out onto Bus (" + bus.getClass().getName() + ").", e);
- }
- }
- }
-
- /**
- * Bus notification listener.
- */
- private class DeploymentBusMessageListener implements BusMessageListener
- {
- /**
- * BusMessage handler.
- *
- * @param busMessage The message.
- * @throws RoutingException Error handling the bus message.
- */
- public void onMessage(final BusMessage busMessage) throws RoutingException
- {
- AddressingContext addressing = busMessage.getAddressingContext();
- if (addressing == null)
- {
- throw new RoutingException("Invalid ESB Message. AddressingContext not set on BusMessage.");
- }
-
- ServiceName toService = addressing.getTo();
- if (toService == null)
- {
- throw new RoutingException("Invalid ESB Message. 'To' address not set. Message from '" + addressing.getFrom() + "'.");
- }
-
- BusInboundRouter inRouter = routingContext.getBusInRouters().get(toService);
- if (inRouter == null)
- {
- throw new RoutingException("Invalid ESB Message from '" + addressing.getFrom() + "'. Service '" + toService + "' unknown on this deployment.");
- }
-
- // And hand it off to the inrouter to manage the processing of it...
- DeploymentContext.setContext(getDeploymentContext());
- try
- {
- inRouter.receive(busMessage);
- }
- finally
- {
- DeploymentContext.setContext(null);
- }
- }
- }
-
- /**
- * Check the monitors.
- * <p/>
- * Checks are the monitored deployments still online.
- */
- private void checkMonitors()
- {
- // TODO: Do we need to synchronize this? The ConcurrentHashMap docs would suggest it's OK to iterate the Map as long as you don't use an Iterator....
- long currentTime = System.currentTimeMillis();
- Set<Map.Entry<String, DeploymentMonitor>> deploymentMonitorSet = deploymentMonitors.entrySet();
- for (Map.Entry<String, DeploymentMonitor> entry : deploymentMonitorSet)
- {
- DeploymentMonitor deploymentMonitor = entry.getValue();
- if (currentTime > deploymentMonitor.getLastHeartbeat() + monitorTimeout)
- {
- deploymentMonitor.setOnline(false);
- }
- }
- }
- }
}
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/Bus.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/Bus.java 2008-11-20 19:31:23 UTC (rev 24004)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/Bus.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -19,13 +19,13 @@
*/
package org.jboss.esb.federate.bus;
-import org.jboss.esb.classpath.ClassUtil;
+import org.jboss.esb.api.routing.RoutingException;
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.federate.notify.AbstractDeploymentNotification;
-import org.jboss.esb.federate.notify.NotificationListener;
-import org.jboss.esb.properties.ApplicationProperties;
-import org.jboss.esb.api.routing.RoutingException;
+import org.jboss.esb.federate.notify.BusNotificationListener;
+import java.util.Properties;
+
/**
* JBoss ESB Bus definition.
* <p/>
@@ -55,7 +55,7 @@
*
* @param properties The Bus properties.
*/
- void setProperties(ApplicationProperties properties);
+ void setProperties(Properties properties);
/**
* Connect the bus.
@@ -95,14 +95,14 @@
*
* @param listener The message listener.
*/
- void setBusMessageListener(BusMessageListener listener);
+ void setMessageListener(BusMessageListener listener);
/**
* Set the bus notification listener.
*
* @param listener Notification listener.
*/
- void setNotificationListener(NotificationListener listener);
+ void setNotificationListener(BusNotificationListener listener);
/**
* Send a notification message onto the Bus.
@@ -114,44 +114,4 @@
* @throws RoutingException Error sending notification onto the Bus.
*/
void sendNotification(AbstractDeploymentNotification notification) throws RoutingException;
-
- /**
- * Bus Factory class.
- */
- public final class Factory
- {
- /**
- * Private default constructor.
- */
- private Factory()
- {
- }
-
- /**
- * New Bus instance.
- *
- * @param className Bus class name.
- * @return Bus instance.
- * @throws DeploymentException Error creating Bus instance.
- */
- public static Bus newInstance(final String className) throws DeploymentException
- {
- try
- {
- return (Bus) ClassUtil.forName(className, Bus.class).newInstance();
- }
- catch (InstantiationException e)
- {
- throw new DeploymentException("Failed to create instance of Bus class '" + className + "'. Class must define a public default constructor.", e);
- }
- catch (IllegalAccessException e)
- {
- throw new DeploymentException("Failed to create instance of Bus class '" + className + "'.", e);
- }
- catch (ClassNotFoundException e)
- {
- throw new DeploymentException("Failed to create instance of Bus class '" + className + "'. Class not found on classpath.", e);
- }
- }
- }
}
Added: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusFactory.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusFactory.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusFactory.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -0,0 +1,79 @@
+/*
+ * 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.bus;
+
+import org.jboss.esb.classpath.ClassUtil;
+import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.config.PropertiesUtil;
+import org.jboss.esb.properties.ApplicationProperties;
+
+/**
+ * Bus Factory class.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public final class BusFactory
+{
+ /**
+ * Private default constructor.
+ */
+ private BusFactory()
+ {
+ }
+
+ /**
+ * New Bus interface instance for the specified {@link DeploymentRuntime) instance.
+ *
+ * @param busProtocol The bus transport protocol.
+ * @param className Bus class name.
+ * @param runtime The {@link DeploymentRuntime) instance.
+ * @return Bus instance.
+ * @throws org.jboss.esb.deploy.DeploymentException Error creating Bus instance.
+ */
+ public static Bus newInstance(final String busProtocol, final String className, final DeploymentRuntime runtime) throws DeploymentException
+ {
+ Bus bus;
+
+ try
+ {
+ bus = (Bus) ClassUtil.forName(className, Bus.class).newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new DeploymentException("Failed to create instance of Bus class '" + className + "'. Class must define a public default constructor.", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new DeploymentException("Failed to create instance of Bus class '" + className + "'.", e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new DeploymentException("Failed to create instance of Bus class '" + className + "'. Class not found on classpath.", e);
+ }
+
+ ApplicationProperties busProperties = PropertiesUtil.getBusConfig(busProtocol, runtime.getDeploymentName(), runtime.getResourceLocator());
+
+ bus.setDeploymentName(runtime.getDeploymentName());
+ bus.setDeploymentId(runtime.getDeploymentId());
+ bus.setProperties(busProperties);
+
+ return bus;
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusFactory.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBus.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBus.java 2008-11-20 19:31:23 UTC (rev 24004)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBus.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -20,21 +20,20 @@
package org.jboss.esb.federate.bus.jms;
import org.apache.log4j.Logger;
-import org.jboss.esb.api.context.ResourceLocator;
import org.jboss.esb.api.context.DeploymentContext;
+import org.jboss.esb.api.context.ResourceLocator;
+import org.jboss.esb.api.routing.RoutingException;
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.deploy.DeploymentRuntime;
import org.jboss.esb.federate.bus.Bus;
import org.jboss.esb.federate.bus.BusMessage;
import org.jboss.esb.federate.bus.BusMessageListener;
import org.jboss.esb.federate.notify.AbstractDeploymentNotification;
-import org.jboss.esb.federate.notify.NotificationListener;
+import org.jboss.esb.federate.notify.BusNotificationListener;
import org.jboss.esb.jms.AbstractMessageHandler;
import org.jboss.esb.jms.AbstractMessageListener;
import org.jboss.esb.jms.JMSSession;
import org.jboss.esb.jms.MessageSender;
-import org.jboss.esb.properties.ApplicationProperties;
-import org.jboss.esb.api.routing.RoutingException;
import javax.jms.JMSException;
import javax.jms.ObjectMessage;
@@ -43,7 +42,7 @@
/**
* ESB Bus implementation for JMS.
* <p/>
- * Acts as the interface to the JMS Bus for the local deployment.
+ * Acts as the interface to the JMS Bus for a deployment.
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
@@ -76,7 +75,7 @@
/**
* Bus Properties.
*/
- private ApplicationProperties properties;
+ private Properties properties;
/**
* Deployment name.
*/
@@ -96,27 +95,27 @@
/**
* JMS Deployment coordination listener.
*/
- private JMSCoordinationListener jmsCoordinationListener;
+ private JMSCoordinationListener notificationListener;
/**
- * Deployment notification broadcaster.
+ * JMS Bus Message Listener.
*/
- private MessageSender jmsCoordinationSender;
+ private JMSQueueMessageListener messageListener;
/**
* Notification callback.
*/
- private NotificationListener coordinationCallback;
+ private BusNotificationListener notificationCallback;
/**
- * Bus message listener.
+ * Bus message callback.
*/
- private BusMessageListener busMessageCallback;
+ private BusMessageListener messageCallback;
/**
- * JMS Bus Message Listener.
+ * Deployment notification broadcaster.
*/
- private JMSQueueMessageListener jmsBusListener;
+ private MessageSender notificationSender;
/**
* JMS Bus Message Sender.
*/
- private MessageSender jmsBusSender;
+ private MessageSender messageSender;
/**
* Set the deploymentName for the local deployment.
@@ -143,22 +142,12 @@
*
* @param properties The Bus properties.
*/
- public final void setProperties(final ApplicationProperties properties)
+ public final void setProperties(final Properties properties)
{
this.properties = properties;
}
/**
- * Get the Bus configuration properties.
- *
- * @return The bus configuration properties.
- */
- public final ApplicationProperties getProperties()
- {
- return properties;
- }
-
- /**
* Connect the bus.
*
* @throws DeploymentException Connection exception.
@@ -204,7 +193,7 @@
{
try
{
- if (jmsCoordinationListener == null && jmsCoordinationSender == null && jmsBusListener == null && jmsBusSender == null)
+ if (notificationListener == null && notificationSender == null && messageListener == null && messageSender == null)
{
if (!logger.isDebugEnabled())
{
@@ -245,10 +234,10 @@
{
try
{
- closeJMSHandler("Deployment Coordination Listener", jmsCoordinationListener);
- closeJMSHandler("Deployment Coordination Sender", jmsCoordinationSender);
- closeJMSHandler("JMS Bus Listener", jmsBusListener);
- closeJMSHandler("JMS Bus Sender", jmsBusSender);
+ closeJMSHandler("Deployment Coordination Listener", notificationListener);
+ closeJMSHandler("Deployment Coordination Sender", notificationSender);
+ closeJMSHandler("JMS Bus Listener", messageListener);
+ closeJMSHandler("JMS Bus Sender", messageSender);
}
finally
{
@@ -267,10 +256,10 @@
{
try
{
- ObjectMessage jmsMessage = jmsBusSender.getSession().createObjectMessage(message);
+ ObjectMessage jmsMessage = messageSender.getSession().createObjectMessage(message);
jmsMessage.setStringProperty(DEPLOYMENT_ID, targetDeploymentId);
- jmsBusSender.send(jmsMessage);
+ messageSender.send(jmsMessage);
}
catch (JMSException e)
{
@@ -279,14 +268,13 @@
}
/**
- * Add a message dispatcher for receiving messages from the bus for
- * the specified local service.
+ * Set the
*
* @param listener The message dispatcher.
*/
- public final void setBusMessageListener(final BusMessageListener listener)
+ public final void setMessageListener(final BusMessageListener listener)
{
- this.busMessageCallback = listener;
+ this.messageCallback = listener;
}
/**
@@ -294,9 +282,9 @@
*
* @param listener Notification listener.
*/
- public final void setNotificationListener(final NotificationListener listener)
+ public final void setNotificationListener(final BusNotificationListener listener)
{
- this.coordinationCallback = listener;
+ this.notificationCallback = listener;
}
/**
@@ -310,11 +298,11 @@
*/
public final void sendNotification(final AbstractDeploymentNotification notification) throws RoutingException
{
- if (jmsCoordinationSender != null)
+ if (notificationSender != null)
{
try
{
- jmsCoordinationSender.send(jmsCoordinationSender.getSession().createObjectMessage(notification));
+ notificationSender.send(notificationSender.getSession().createObjectMessage(notification));
}
catch (JMSException e)
{
@@ -338,8 +326,8 @@
*/
public final void stopListening()
{
- closeJMSHandler("JMS Bus Listener", jmsBusListener);
- jmsBusListener = null;
+ closeJMSHandler("JMS Bus Listener", messageListener);
+ messageListener = null;
}
/**
@@ -353,14 +341,14 @@
{
String coordinationTopicName = busProperties.getProperty(DEPLOYMENT_COORDINTATION_TOPIC_KEY, DEFAULT_DEPLOYMENT_COORDINTATION_TOPIC_NAME);
- jmsCoordinationListener = new JMSCoordinationListener(coordinationTopicName, busProperties);
+ notificationListener = new JMSCoordinationListener(coordinationTopicName, busProperties);
try
{
- jmsCoordinationListener.connect();
+ notificationListener.connect();
}
catch (JMSException e)
{
- jmsCoordinationListener = null;
+ notificationListener = null;
throw new DeploymentException("Deployment '" + deploymentName + "' 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: " + busProperties, e);
@@ -378,14 +366,14 @@
{
String coordinationTopicName = busProperties.getProperty(DEPLOYMENT_COORDINTATION_TOPIC_KEY, DEFAULT_DEPLOYMENT_COORDINTATION_TOPIC_NAME);
- jmsCoordinationSender = new MessageSender(coordinationTopicName, topicSession);
+ notificationSender = new MessageSender(coordinationTopicName, topicSession);
try
{
- jmsCoordinationSender.connect();
+ notificationSender.connect();
}
catch (JMSException e)
{
- jmsCoordinationSender = null;
+ notificationSender = null;
throw new DeploymentException("Deployment '" + deploymentName + "' 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: " + busProperties, e);
@@ -403,14 +391,14 @@
{
String busQueueName = busProperties.getProperty(BUS_QUEUE_KEY, DEFAULT_BUS_QUEUE_NAME);
- jmsBusListener = new JMSQueueMessageListener(busQueueName, busProperties);
+ messageListener = new JMSQueueMessageListener(busQueueName, busProperties);
try
{
- jmsBusListener.connect();
+ messageListener.connect();
}
catch (JMSException e)
{
- jmsBusListener = null;
+ messageListener = null;
throw new DeploymentException("Deployment '" + deploymentName + "' is not being coordinated with any other local deployment. A JMSException occured while trying "
+ "to connect to the JMS Bus Queue '" + busQueueName + "'. The JMS Server must be running and this Queue must be deployed. "
+ "JNDI properties used: " + busProperties, e);
@@ -428,14 +416,14 @@
{
String busQueueName = busProperties.getProperty(BUS_QUEUE_KEY, DEFAULT_BUS_QUEUE_NAME);
- jmsBusSender = new MessageSender(busQueueName, queueSession);
+ messageSender = new MessageSender(busQueueName, queueSession);
try
{
- jmsBusSender.connect();
+ messageSender.connect();
}
catch (JMSException e)
{
- jmsBusSender = null;
+ messageSender = null;
throw new DeploymentException("Deployment '" + deploymentName + "' is not being coordinated with any other local deployment. A JMSException occured while trying "
+ "to connect to the JMS Bus Queue '" + busQueueName + "'. The JMS Server must be running and this Queue must be deployed. "
+ "JNDI properties used: " + busProperties, e);
@@ -447,7 +435,7 @@
*
* @param localBusProperties Local JMS Bus properties.
*/
- private void connectJMSSessions(final ApplicationProperties localBusProperties) throws DeploymentException
+ private void connectJMSSessions(final Properties localBusProperties) throws DeploymentException
{
ResourceLocator resourceLocator = DeploymentRuntime.getResourceLocator(DeploymentContext.getContext());
@@ -541,7 +529,7 @@
{
try
{
- coordinationCallback.onNotification((AbstractDeploymentNotification) objectMessage);
+ notificationCallback.onNotification((AbstractDeploymentNotification) objectMessage);
}
catch (DeploymentException e)
{
@@ -592,7 +580,7 @@
{
try
{
- busMessageCallback.onMessage((BusMessage) objectMessage);
+ messageCallback.onMessage((BusMessage) objectMessage);
}
catch (RoutingException e)
{
Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/BusNotificationListener.java (from rev 23980, labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/NotificationListener.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/BusNotificationListener.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/BusNotificationListener.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -0,0 +1,38 @@
+/*
+ * 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.notify;
+
+import org.jboss.esb.deploy.DeploymentException;
+
+/**
+ * Notification Listener interface.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public interface BusNotificationListener
+{
+ /**
+ * Deployment notification handler.
+ *
+ * @param notification The notification.
+ * @throws DeploymentException Invalid deployment detected.
+ */
+ void onNotification(AbstractDeploymentNotification notification) throws DeploymentException;
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/BusNotificationListener.java
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/NotificationListener.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/NotificationListener.java 2008-11-20 19:31:23 UTC (rev 24004)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/notify/NotificationListener.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -1,38 +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.notify;
-
-import org.jboss.esb.deploy.DeploymentException;
-
-/**
- * Notification Listener interface.
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public interface NotificationListener
-{
- /**
- * Deployment notification handler.
- *
- * @param notification The notification.
- * @throws DeploymentException Invalid deployment detected.
- */
- void onNotification(AbstractDeploymentNotification notification) throws DeploymentException;
-}
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-20 19:31:23 UTC (rev 24004)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceInvoker.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -26,8 +26,8 @@
import org.jboss.esb.deploy.DeploymentRuntime;
import org.jboss.esb.deploy.DeploymentUtil;
import org.jboss.esb.deploy.config.ServiceConfig;
-import org.jboss.esb.federate.DeploymentCoordinator;
import org.jboss.esb.federate.DeploymentMonitor;
+import org.jboss.esb.federate.BusMediator;
import org.jboss.esb.federate.bus.BusInboundRouter;
import org.jboss.esb.federate.bus.BusMessage;
import org.jboss.esb.federate.bus.BusRoutingContext;
@@ -195,7 +195,7 @@
private boolean routeByBus(final Message message, final AddressingContext invokeAddressingContext)
{
InvocationContext thisInvocationContext = InvocationContext.getContext();
- List<DeploymentCoordinator.BusDeployment> busDeployments = deploymentRuntime.getDeploymentCoordinator().getBusDeployments();
+ List<BusMediator> busMediators = deploymentRuntime.getDeploymentCoordinator().getBusMediators();
BusMessage busMessage = new BusMessage();
busMessage.setMessage(message);
@@ -204,9 +204,9 @@
// Iterate over all the Bus deployments looking for a deployment that
// is online and is hosting the target service...
- for (DeploymentCoordinator.BusDeployment busDeployment : busDeployments)
+ for (BusMediator busMediator : busMediators)
{
- Iterator<Map.Entry<String,DeploymentMonitor>> monitors = busDeployment.getDeploymentMonitors().entrySet().iterator();
+ 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-20 19:31:23 UTC (rev 24004)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/DeploymentCoordinatorTest.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -49,16 +49,16 @@
DeploymentCoordinator coordinator2 = deployment2.getDeploymentCoordinator();
DeploymentMonitor monitor;
- assertEquals(1, coordinator1.getBusDeployments().get(0).getDeploymentMonitors().size());
- assertEquals(1, coordinator2.getBusDeployments().get(0).getDeploymentMonitors().size());
+ assertEquals(1, coordinator1.getBusMediators().get(0).getDeploymentMonitors().size());
+ assertEquals(1, coordinator2.getBusMediators().get(0).getDeploymentMonitors().size());
// So deployment1 should be monitoring deployment2...
- monitor = (DeploymentMonitor) coordinator1.getBusDeployments().get(0).getDeploymentMonitors().values().toArray()[0];
+ monitor = (DeploymentMonitor) coordinator1.getBusMediators().get(0).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.getBusDeployments().get(0).getDeploymentMonitors().values().toArray()[0];
+ monitor = (DeploymentMonitor) coordinator2.getBusMediators().get(0).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());
@@ -71,25 +71,25 @@
DeploymentCoordinator coordinator3 = deployment3.getDeploymentCoordinator();
// Each of the 3 deployments should be monitoring the other 2 deployments...
- assertEquals(2, coordinator1.getBusDeployments().get(0).getDeploymentMonitors().size());
- assertEquals(2, coordinator2.getBusDeployments().get(0).getDeploymentMonitors().size());
- assertEquals(2, coordinator3.getBusDeployments().get(0).getDeploymentMonitors().size());
+ assertEquals(2, coordinator1.getBusMediators().get(0).getDeploymentMonitors().size());
+ assertEquals(2, coordinator2.getBusMediators().get(0).getDeploymentMonitors().size());
+ assertEquals(2, coordinator3.getBusMediators().get(0).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.getBusDeployments().get(0).getDeploymentMonitors().values().toString();
+ monitorsTOString = coordinator1.getBusMediators().get(0).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.getBusDeployments().get(0).getDeploymentMonitors().values().toString();
+ monitorsTOString = coordinator2.getBusMediators().get(0).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.getBusDeployments().get(0).getDeploymentMonitors().values().toString();
+ monitorsTOString = coordinator3.getBusMediators().get(0).getDeploymentMonitors().values().toString();
assertTrue(monitorsTOString.indexOf("{online=true} deployment1") != -1);
assertTrue(monitorsTOString.indexOf("{online=true} deployment2") != -1);
} finally {
@@ -97,16 +97,16 @@
}
Thread.sleep(500);
- assertEquals(1, coordinator1.getBusDeployments().get(0).getDeploymentMonitors().size());
- assertEquals(1, coordinator2.getBusDeployments().get(0).getDeploymentMonitors().size());
+ assertEquals(1, coordinator1.getBusMediators().get(0).getDeploymentMonitors().size());
+ assertEquals(1, coordinator2.getBusMediators().get(0).getDeploymentMonitors().size());
// So deployment1 should be monitoring deployment2...
- monitor = (DeploymentMonitor) coordinator1.getBusDeployments().get(0).getDeploymentMonitors().values().toArray()[0];
+ monitor = (DeploymentMonitor) coordinator1.getBusMediators().get(0).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.getBusDeployments().get(0).getDeploymentMonitors().values().toArray()[0];
+ monitor = (DeploymentMonitor) coordinator2.getBusMediators().get(0).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 {
@@ -115,7 +115,7 @@
Thread.sleep(500);
// deployment1 should no longer be be monitoring deployment2...
- assertEquals(0, coordinator1.getBusDeployments().get(0).getDeploymentMonitors().size());
+ assertEquals(0, coordinator1.getBusMediators().get(0).getDeploymentMonitors().size());
} finally {
deployment1.undeploy();
}
@@ -143,16 +143,16 @@
DeploymentCoordinator coordinator2 = deployment2.getDeploymentCoordinator();
DeploymentMonitor monitor;
- assertEquals(1, coordinator1.getBusDeployments().get(0).getDeploymentMonitors().size());
- assertEquals(1, coordinator2.getBusDeployments().get(0).getDeploymentMonitors().size());
+ assertEquals(1, coordinator1.getBusMediators().get(0).getDeploymentMonitors().size());
+ assertEquals(1, coordinator2.getBusMediators().get(0).getDeploymentMonitors().size());
// So deployment1 should be monitoring deployment2...
- monitor = (DeploymentMonitor) coordinator1.getBusDeployments().get(0).getDeploymentMonitors().values().toArray()[0];
+ monitor = (DeploymentMonitor) coordinator1.getBusMediators().get(0).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.getBusDeployments().get(0).getDeploymentMonitors().values().toArray()[0];
+ monitor = (DeploymentMonitor) coordinator2.getBusMediators().get(0).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());
@@ -161,7 +161,7 @@
Thread.sleep(6000);
// deployment2 should see deployment1 as being offline now...
- monitor = (DeploymentMonitor) coordinator2.getBusDeployments().get(0).getDeploymentMonitors().values().toArray()[0];
+ monitor = (DeploymentMonitor) coordinator2.getBusMediators().get(0).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());
@@ -170,7 +170,7 @@
Thread.sleep(6000);
// deployment2 should see deployment1 as being online again...
- monitor = (DeploymentMonitor) coordinator2.getBusDeployments().get(0).getDeploymentMonitors().values().toArray()[0];
+ monitor = (DeploymentMonitor) coordinator2.getBusMediators().get(0).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());
@@ -180,7 +180,7 @@
Thread.sleep(100);
// deployment1 should no longer be be monitoring deployment2...
- assertEquals(0, coordinator1.getBusDeployments().get(0).getDeploymentMonitors().size());
+ assertEquals(0, coordinator1.getBusMediators().get(0).getDeploymentMonitors().size());
} finally {
deployment1.undeploy();
}
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/bus/jms/JMSBus_Standalone_Test.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/bus/jms/JMSBus_Standalone_Test.java 2008-11-20 19:31:23 UTC (rev 24004)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/federate/bus/jms/JMSBus_Standalone_Test.java 2008-11-20 20:33:51 UTC (rev 24005)
@@ -23,7 +23,7 @@
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.federate.bus.BusMessage;
import org.jboss.esb.federate.bus.BusMessageListener;
-import org.jboss.esb.federate.notify.NotificationListener;
+import org.jboss.esb.federate.notify.BusNotificationListener;
import org.jboss.esb.federate.notify.AbstractDeploymentNotification;
import org.jboss.esb.federate.notify.DeploymentHeartbeatNotification;
import org.jboss.esb.test.JmsTestRunner;
@@ -47,17 +47,17 @@
{
JMSBus interface1 = createBusInterfaceInstance("deployment1");
TestBusMessageListener interface1Listener = new TestBusMessageListener();
- interface1.setBusMessageListener(interface1Listener);
+ interface1.setMessageListener(interface1Listener);
try
{
JMSBus interface2 = createBusInterfaceInstance("deployment2");
TestBusMessageListener interface2Listener = new TestBusMessageListener();
- interface2.setBusMessageListener(interface2Listener);
+ interface2.setMessageListener(interface2Listener);
try
{
JMSBus interface3 = createBusInterfaceInstance("deployment3");
TestBusMessageListener interface3Listener = new TestBusMessageListener();
- interface3.setBusMessageListener(interface3Listener);
+ interface3.setMessageListener(interface3Listener);
try
{
BusMessage message = new BusMessage();
@@ -215,7 +215,7 @@
}
}
- private class TestNotificationListener implements NotificationListener
+ private class TestNotificationListener implements BusNotificationListener
{
private List<AbstractDeploymentNotification> notificationsReceived = new ArrayList<AbstractDeploymentNotification>();
More information about the jboss-svn-commits
mailing list