[jboss-svn-commits] JBL Code SVN: r22720 - 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
Fri Sep 12 11:45:46 EDT 2008
Author: tfennelly
Date: 2008-09-12 11:45:46 -0400 (Fri, 12 Sep 2008)
New Revision: 22720
Added:
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusUtil.java
Removed:
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBusDispatcher.java
Modified:
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/ApplicationProperties.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/federate/DeploymentCoordinator.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBus.java
Log:
Moved a few bits around
Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/ApplicationProperties.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/ApplicationProperties.java 2008-09-12 15:04:56 UTC (rev 22719)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/ApplicationProperties.java 2008-09-12 15:45:46 UTC (rev 22720)
@@ -151,4 +151,25 @@
return defaultVal;
}
}
+
+ /**
+ * Read the stream to a {@link java.util.Properties} instance.
+ *
+ * @param configStream The configuration stream.
+ * @return The {@link java.util.Properties} instance.
+ * @throws java.io.IOException Unable to read the configuration.
+ */
+ public static ApplicationProperties loadProperties(final InputStream configStream) throws IOException
+ {
+ try
+ {
+ ApplicationProperties properties = new ApplicationProperties();
+ properties.load(configStream);
+ return properties;
+ }
+ finally
+ {
+ configStream.close();
+ }
+ }
}
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-12 15:04:56 UTC (rev 22719)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java 2008-09-12 15:45:46 UTC (rev 22720)
@@ -31,6 +31,7 @@
import org.jboss.esb.dispatch.DispatcherProxy;
import org.jboss.esb.dispatch.LocalDispatcher;
import org.jboss.esb.federate.DeploymentCoordinator;
+import org.jboss.esb.federate.bus.BusUtil;
import org.jboss.esb.message.MessageTransformer;
import org.jboss.esb.properties.ApplicationProperties;
import org.jboss.esb.schedule.JobScheduler;
@@ -455,7 +456,7 @@
try
{
SimpleSchedule heartbeatSchedule = new SimpleSchedule();
- ApplicationProperties localBusProperties = DeploymentCoordinator.getBusConfig("jms", deploymentName);
+ ApplicationProperties localBusProperties = BusUtil.getBusConfig("jms", deploymentName);
heartbeatSchedule.setFrequency(localBusProperties.getLongProperty(DeploymentCoordinator.COORDINATOR_HEARTBEAT_FREQUENCY_KEY, DeploymentCoordinator.COORDINATOR_HEARTBEAT_DEFAULT_FREQUENCY));
heartbeatSchedule.setExecCount(-1);
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-12 15:04:56 UTC (rev 22719)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java 2008-09-12 15:45:46 UTC (rev 22720)
@@ -22,7 +22,6 @@
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.bus.Bus;
@@ -38,12 +37,7 @@
import org.jboss.esb.schedule.SchedulingException;
import org.jboss.esb.util.AssertArgument;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.Map;
-import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -156,8 +150,6 @@
// TODO: Move this to a deployment related config i.e. a non-bus related config
monitorTimeout = (busProperties.getLongProperty(COORDINATOR_HEARTBEAT_FREQUENCY_KEY, COORDINATOR_HEARTBEAT_DEFAULT_FREQUENCY) * 4);
jmsBusDeployment = new BusDeployment(bus);
-
- // TODO: For each bus... attach the appropriate dispatchers based on the local service/router config...
}
}
@@ -230,91 +222,6 @@
}
/**
- * Get the bus configuration for the specified protocol and deployment name combination.
- * <p/>
- * Checks in the following order:
- * <ol>
- * <li>File: "busconfig/<protpcol>/<deploymentName>.properties"</li>
- * <li>Classpath: "/META-INF/busconfig/<protpcol>/<deploymentName>.properties"</li>
- * <li>File: "busconfig/<protpcol>/default.properties"</li>
- * <li>Classpath: "/META-INF/busconfig/<protpcol>/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 ApplicationProperties getBusConfig(final String protocol, final String deploymentName) throws IOException
- {
- String firstCheckPath = "busconfig/" + protocol + "/" + deploymentName + ".properties";
- String secondCheckPath = "/META-INF/jbossesb/" + firstCheckPath;
- String thirdCheckPath = "busconfig/" + protocol + "/" + "default.properties";
- String fourthCheckPath = "/META-INF/jbossesb/busconfig/" + protocol + "/" + "default.properties";
- InputStream configStream;
-
- // 1st: Check for a deployment specific config on the local file system...
- File checkFile = new File(firstCheckPath);
- if (checkFile.exists() && !checkFile.isDirectory())
- {
- return readConfig(new FileInputStream(checkFile));
- }
-
- // 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 the default config on the local file system...
- checkFile = new File(thirdCheckPath);
- if (checkFile.exists() && !checkFile.isDirectory())
- {
- return readConfig(new FileInputStream(checkFile));
- }
-
- // 4th: Check for the default config on the classpath...
- configStream = ClassUtil.getResourceAsStream(fourthCheckPath, 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. File: " + thirdCheckPath + "\n"
- + "\t4. Classpath: " + fourthCheckPath);
-
- 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 ApplicationProperties readConfig(final InputStream configStream) throws IOException
- {
- try
- {
- ApplicationProperties properties = new ApplicationProperties();
- properties.load(configStream);
- return properties;
- }
- finally
- {
- configStream.close();
- }
- }
-
- /**
* JBoss ESB Deployment.
*/
private class BusDeployment
Added: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusUtil.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusUtil.java 2008-09-12 15:45:46 UTC (rev 22720)
@@ -0,0 +1,145 @@
+/*
+ * 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.bus;
+
+import org.apache.log4j.Logger;
+import org.jboss.esb.classpath.ClassUtil;
+import org.jboss.esb.federate.DeploymentCoordinator;
+import org.jboss.esb.properties.ApplicationProperties;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLEncoder;
+
+/**
+ * Bus management utility methods.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public abstract class BusUtil
+{
+
+ /**
+ * Logger.
+ */
+ private static Logger logger = Logger.getLogger(BusUtil.class);
+ /**
+ * File dir name for ESB configs.
+ */
+ private static final String BUSCONFIG_FILE_DIR = "busconfig/";
+ /**
+ * Classpath dir name for ESB configs.
+ */
+ private static final String BUSCONFIG_CP_DIR = "/META-INF/jbossesb/" + BUSCONFIG_FILE_DIR;
+
+ /**
+ * Private constructor.
+ */
+ private BusUtil()
+ {
+ }
+
+ /**
+ * Get the bus configuration for the specified protocol and deployment name combination.
+ * <p/>
+ * Checks in the following order:
+ * <ol>
+ * <li>File: "busconfig/<protpcol>/<deploymentName>.properties"</li>
+ * <li>Classpath: "/META-INF/busconfig/<protpcol>/<deploymentName>.properties"</li>
+ * <li>File: "busconfig/<protpcol>/default.properties"</li>
+ * <li>Classpath: "/META-INF/busconfig/<protpcol>/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 java.util.Properties} instance.
+ * @throws java.io.IOException Unable to read configuration.
+ */
+ public static ApplicationProperties getBusConfig(final String protocol, final String deploymentName) throws IOException
+ {
+ String firstCheckPath = protocol + "/" + URLEncoder.encode(deploymentName, "UTF-8") + ".properties";
+ String secondCheckPath = protocol + "/" + "default.properties";
+
+ ApplicationProperties properties;
+
+ // First check for a deployment specific config ...
+ properties = getBusConfig(firstCheckPath);
+ if (properties != null)
+ {
+ return properties;
+ }
+
+ // Then check for a default ...
+ properties = getBusConfig(secondCheckPath);
+ if (properties != null)
+ {
+ return properties;
+ }
+
+ logger.debug("Unable to find JBoss ESB Bus configuration for protocol '" + protocol + "', deployment '" + deploymentName + "'. Tried:\n"
+ + "\t1. File: " + BUSCONFIG_FILE_DIR + firstCheckPath + "\n"
+ + "\t2. Classpath: " + BUSCONFIG_CP_DIR + firstCheckPath + "\n"
+ + "\t3. File: " + BUSCONFIG_FILE_DIR + secondCheckPath + "\n"
+ + "\t4. Classpath: " + BUSCONFIG_CP_DIR + secondCheckPath);
+
+ return null;
+ }
+
+ /**
+ * Get the specified bus configuration from the bus configurations directory.
+ * <p/>
+ * Checks in the following order:
+ * <ol>
+ * <li>File: "busconfig/<configPath>"</li>
+ * <li>Classpath: "/META-INF/busconfig/<configPath>"</li>
+ * </ol>
+ *
+ * @param configPath The configuration file path.
+ * @return The bus configuration as a {@link java.util.Properties} instance.
+ * @throws java.io.IOException Unable to read configuration.
+ */
+ public static ApplicationProperties getBusConfig(final String configPath) throws IOException
+ {
+ String firstCheckPath = BUSCONFIG_FILE_DIR + configPath;
+ String secondCheckPath = BUSCONFIG_CP_DIR + configPath;
+ InputStream configStream;
+
+ // 1st: Check for a deployment specific config on the local file system...
+ File checkFile = new File(firstCheckPath);
+ if (checkFile.exists() && !checkFile.isDirectory())
+ {
+ return ApplicationProperties.loadProperties(new FileInputStream(checkFile));
+ }
+
+ // 2nd: Check for a deployment specific config on the classpath...
+ configStream = ClassUtil.getResourceAsStream(secondCheckPath, DeploymentCoordinator.class);
+ if (configStream != null)
+ {
+ return ApplicationProperties.loadProperties(configStream);
+ }
+
+ return null;
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/BusUtil.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-09-12 15:04:56 UTC (rev 22719)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBus.java 2008-09-12 15:45:46 UTC (rev 22720)
@@ -23,6 +23,7 @@
import org.jboss.esb.deploy.DeploymentException;
import org.jboss.esb.federate.DeploymentCoordinator;
import org.jboss.esb.federate.bus.Bus;
+import org.jboss.esb.federate.bus.BusUtil;
import org.jboss.esb.federate.notify.AbstractDeploymentNotification;
import org.jboss.esb.federate.notify.NotificationListener;
import org.jboss.esb.jms.AbstractMessageListener;
@@ -133,7 +134,7 @@
try
{
- busProperties = DeploymentCoordinator.getBusConfig("jms", deploymentName);
+ busProperties = BusUtil.getBusConfig("jms", deploymentName);
}
catch (IOException e)
{
Deleted: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBusDispatcher.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBusDispatcher.java 2008-09-12 15:04:56 UTC (rev 22719)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/bus/jms/JMSBusDispatcher.java 2008-09-12 15:45:46 UTC (rev 22720)
@@ -1,46 +0,0 @@
-/*
- * 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.bus.jms;
-
-import org.jboss.esb.context.InvocationContext;
-import org.jboss.esb.message.Message;
-import org.jboss.esb.routing.MessageDispatcher;
-import org.jboss.esb.routing.RoutingException;
-
-/**
- * JMS Bus Dispatcher.
- * <p/>
- * Dispatches a message from a JMS Bus to a Service or OutboundRouter.
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class JMSBusDispatcher implements MessageDispatcher
-{
- /**
- * Dispatch the message from the Bus.
- * @param message The message.
- * @param invocationContext Message invocation context.
- * @throws RoutingException Dispatch failure.
- */
- public final void dispatch(final Message message, final InvocationContext invocationContext) throws RoutingException
- {
- // TODO...
- }
-}
More information about the jboss-svn-commits
mailing list