[jboss-svn-commits] JBL Code SVN: r22985 - in labs/jbossesb/workspace/skeagh: runtime/src/main/java/org/jboss/esb/deploy and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Sep 22 09:00:16 EDT 2008
Author: tfennelly
Date: 2008-09-22 09:00:16 -0400 (Mon, 22 Sep 2008)
New Revision: 22985
Added:
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/PropertiesIterator.java
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/federate/DeploymentCoordinator.java
Log:
Created PropertiesIterator.
Added: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/PropertiesIterator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/PropertiesIterator.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/PropertiesIterator.java 2008-09-22 13:00:16 UTC (rev 22985)
@@ -0,0 +1,119 @@
+/*
+ * 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.properties;
+
+import org.jboss.esb.util.AssertArgument;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * {@link Properties} iterator utility class.
+ * <p/>
+ * The easiest way to use this class is to simple create an anonymous
+ * instance. The following example shows how to iterate all entries
+ * having a key prefix of "bus.":
+ * <pre>
+ * new PropertyIterator(properties) {
+ * public void processEntry(String key, String value) {
+ * // code to process entry...
+ * }.iterate("bus.");
+ * }
+ * </pre>
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public abstract class PropertiesIterator
+{
+ /**
+ * The properties instance.
+ */
+ private Properties properties;
+
+ /**
+ * Public constructor.
+ *
+ * @param properties The Properties instance to be iterated over.
+ */
+ public PropertiesIterator(final Properties properties)
+ {
+ AssertArgument.isNotNull(properties, "properties");
+ this.properties = properties;
+ }
+
+ /**
+ * Iterate all entries in the supplied {@link Properties}
+ * object, calling {@link #processEntry(String, String)} for each entry.
+ *
+ * @throws Exception Error processing an entry.
+ */
+ public final void iterate() throws Exception
+ {
+ Set<Map.Entry<Object, Object>> configEntries = properties.entrySet();
+
+ for (Map.Entry<Object, Object> configEntry : configEntries)
+ {
+ String key = (String) configEntry.getKey();
+ String value = (String) configEntry.getValue();
+
+ processEntry(key, value);
+ }
+ }
+
+ /**
+ * Iterate a subset of the entries in the supplied {@link Properties}
+ * object, calling {@link #processEntry(String, String)} for each entry.
+ * <p/>
+ * The key prefix is tripped off the key supplied to the
+ * {@link # processEntry (String, String)} method.
+ *
+ * @param keyPrefix The key prefix for of the entry subset to be processed.
+ * @throws Exception Error processing an entry.
+ */
+ public final void iterate(final String keyPrefix) throws Exception
+ {
+ Set<Map.Entry<Object, Object>> configEntries = properties.entrySet();
+
+ for (Map.Entry<Object, Object> configEntry : configEntries)
+ {
+ String propertyName = (String) configEntry.getKey();
+ if (propertyName.startsWith(keyPrefix))
+ {
+ String key = propertyName.substring(keyPrefix.length());
+ String value = (String) configEntry.getValue();
+
+ processEntry(key, value);
+ }
+ }
+ }
+
+ /**
+ * Process an entry key value pair.
+ *
+ * @param key The entry key.
+ * @param value The entry value. If the {@link #iterate(String)} method
+ * is being used, the key prefix will have been stripped off.
+ * @throws Exception Error processing the entry.
+ * @see #iterate()
+ * @see #iterate(String)
+ */
+ public abstract void processEntry(String key, String value) throws Exception;
+}
Property changes on: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/PropertiesIterator.java
___________________________________________________________________
Name: svn:eol-style
+ native
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-22 12:15:57 UTC (rev 22984)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java 2008-09-22 13:00:16 UTC (rev 22985)
@@ -234,6 +234,11 @@
deploymentId += ":" + deploymentName;
logger.info("Starting JBoss ESB deployment: '" + deploymentName + "'.");
+
+ // Add the pre-installed deployment units e.g. for the "Dead Letter" Service
+ // and any other that the deployment may have...
+ addPreinstalledDeploymentUnits();
+
try
{
// Deploy everything in order...
@@ -257,6 +262,17 @@
}
/**
+ * Add the pre-installed deployment units.
+ * <p/>
+ * An example of a "pre-installed" deployment unit would be for a
+ * Dead Letter service.
+ */
+ private void addPreinstalledDeploymentUnits()
+ {
+
+ }
+
+ /**
* Undeploy the Runtime.
*
* @throws DeploymentException Error undeploying ESB Runtime.
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-22 12:15:57 UTC (rev 22984)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentCoordinator.java 2008-09-22 13:00:16 UTC (rev 22985)
@@ -38,6 +38,7 @@
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.routing.RoutingException;
import org.jboss.esb.schedule.AbstractScheduleListener;
import org.jboss.esb.schedule.SchedulingException;
@@ -140,16 +141,10 @@
routingContext = runtime.createRoutingContext();
// Start all configured bus interfaces...
- Set<Map.Entry<Object, Object>> configEntries = deploymentProperties.entrySet();
- for (Map.Entry<Object, Object> configEntry : configEntries)
+ try
{
- String propertyName = (String) configEntry.getKey();
- if (propertyName.startsWith("bus."))
- {
- String busProtocol = propertyName.substring("bus.".length());
- String busClassName = (String) configEntry.getValue();
-
- try
+ new PropertiesIterator(deploymentProperties) {
+ public void processEntry(String busProtocol, String busClassName) throws DeploymentException
{
Bus bus = Bus.Factory.newInstance(busClassName);
ApplicationProperties busProperties = PropertiesUtil.getBusConfig(busProtocol, runtime.getDeploymentName());
@@ -176,18 +171,18 @@
}
}
}
- catch (DeploymentException e)
- {
- uninitialize();
- throw e;
- }
- catch (Throwable t)
- {
- uninitialize();
- throw new DeploymentException("Unexpected exception while starting Deployment Bus interfaces.", t);
- }
- }
+ }.iterate("bus.");
}
+ catch (DeploymentException e)
+ {
+ uninitialize();
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ uninitialize();
+ throw new DeploymentException("Unexpected exception while starting Deployment Bus interfaces.", t);
+ }
}
/**
More information about the jboss-svn-commits
mailing list