[jboss-svn-commits] JBL Code SVN: r22983 - labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Sep 22 07:55:55 EDT 2008
Author: tfennelly
Date: 2008-09-22 07:55:54 -0400 (Mon, 22 Sep 2008)
New Revision: 22983
Modified:
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigUtil.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/PropertiesUtil.java
Log:
Moved getConfigStream from PropertiesUtil to ConfigUtil
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigUtil.java 2008-09-22 11:29:00 UTC (rev 22982)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigUtil.java 2008-09-22 11:55:54 UTC (rev 22983)
@@ -19,6 +19,14 @@
*/
package org.jboss.esb.deploy.config;
+import org.jboss.esb.classpath.ClassUtil;
+import org.jboss.esb.deploy.DeploymentException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
/**
* Configuration utilities.
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
@@ -26,9 +34,51 @@
public abstract class ConfigUtil
{
/**
+ * Classpath dir name for ESB configs.
+ */
+ static final String ESBCONFIG_CP_DIR = "/META-INF/jbossesb/";
+
+ /**
* Private Constructor.
*/
private ConfigUtil()
{
}
+
+ /**
+ * Get the specified configuration stream.
+ * <p/>
+ * Checks in the following order:
+ * <ol>
+ * <li>File: "<configPath>"</li>
+ * <li>Classpath: "/META-INF/busconfig/<configPath>"</li>
+ * </ol>
+ *
+ * @param configPath The configuration file path.
+ * @return The configuration stream, or null if the specified configuration cannot be found.
+ * @throws org.jboss.esb.deploy.DeploymentException Unable to read configuration.
+ */
+ public static InputStream getConfigStream(final String configPath) throws DeploymentException
+ {
+ String fileCheckPath = configPath;
+ String cpCheckPath = ESBCONFIG_CP_DIR + configPath;
+ InputStream configStream;
+
+ // 1st: Check for a deployment specific config on the local file system...
+ File checkFile = new File(fileCheckPath);
+ if (checkFile.exists() && !checkFile.isDirectory())
+ {
+ try
+ {
+ return new FileInputStream(checkFile);
+ }
+ catch (IOException e)
+ {
+ throw new DeploymentException("Error reading configuration file '" + checkFile.getAbsolutePath() + "'.", e);
+ }
+ }
+
+ // 2nd: Check for a deployment specific config on the classpath...
+ return ClassUtil.getResourceAsStream(cpCheckPath, ConfigUtil.class);
+ }
}
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/PropertiesUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/PropertiesUtil.java 2008-09-22 11:29:00 UTC (rev 22982)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/PropertiesUtil.java 2008-09-22 11:55:54 UTC (rev 22983)
@@ -20,13 +20,9 @@
package org.jboss.esb.deploy.config;
import org.apache.log4j.Logger;
-import org.jboss.esb.classpath.ClassUtil;
import org.jboss.esb.deploy.DeploymentException;
-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.io.UnsupportedEncodingException;
@@ -51,10 +47,6 @@
* File dir name for ESB configs.
*/
private static final String BUSCONFIG_FILE_DIR = "busconfig/";
- /**
- * Classpath dir name for ESB configs.
- */
- private static final String ESBCONFIG_CP_DIR = "/META-INF/jbossesb/";
/**
* Private constructor.
@@ -161,31 +153,14 @@
* </ol>
*
* @param configPath The configuration file path.
- * @return The bus configuration as a {@link java.util.Properties} instance.
+ * @return The bus configuration as a {@link java.util.Properties} instance, or null if
+ * the specified configuration cannot be found.
* @throws DeploymentException Unable to read configuration.
*/
public static ApplicationProperties getConfig(final String configPath) throws DeploymentException
{
- String fileCheckPath = configPath;
- String cpCheckPath = ESBCONFIG_CP_DIR + configPath;
- InputStream configStream;
-
- // 1st: Check for a deployment specific config on the local file system...
- File checkFile = new File(fileCheckPath);
- if (checkFile.exists() && !checkFile.isDirectory())
- {
- try
- {
- return ApplicationProperties.loadProperties(new FileInputStream(checkFile));
- }
- catch (IOException e)
- {
- throw new DeploymentException("Error reading properties file '" + checkFile.getAbsolutePath() + "'.", e);
- }
- }
-
- // 2nd: Check for a deployment specific config on the classpath...
- configStream = ClassUtil.getResourceAsStream(cpCheckPath, DeploymentCoordinator.class);
+ InputStream configStream = ConfigUtil.getConfigStream(configPath);
+
if (configStream != null)
{
try
@@ -194,7 +169,7 @@
}
catch (IOException e)
{
- throw new DeploymentException("Error reading properties classpath file '" + cpCheckPath + "'.", e);
+ throw new DeploymentException("Error reading properties file '" + configPath + "'.", e);
}
}
More information about the jboss-svn-commits
mailing list