[jboss-svn-commits] JBL Code SVN: r24147 - in labs/jbossesb/workspace/skeagh: commons/src/test/java/org/jboss/esb/properties and 25 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Nov 30 05:17:55 EST 2008
Author: tfennelly
Date: 2008-11-30 05:17:54 -0500 (Sun, 30 Nov 2008)
New Revision: 24147
Added:
labs/jbossesb/workspace/skeagh/container/osgi/configloader/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/pom.xml
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/esb/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/esb/osgi/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/esb/osgi/configloader/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/esb/osgi/configloader/PropertyLoaderService.java
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/esb/osgi/configloader/package.html
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/resources/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/resources/log4j.xml
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/test/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/test/java/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/test/java/org/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/test/java/org/jboss/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/test/java/org/jboss/esb/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/test/java/org/jboss/esb/osgi/
labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/test/resources/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/jmsbus.properties
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/pax.runner.args
Removed:
labs/jbossesb/workspace/skeagh/container/osgi/jmsbus/src/main/resources/META-INF/
Modified:
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/TokenReplacer.java
labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/properties/PropertyReplacementTest.java
labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/properties/props.properties
labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/properties/props.xml
labs/jbossesb/workspace/skeagh/container/osgi/jmsbus/pom.xml
labs/jbossesb/workspace/skeagh/container/osgi/jmsbus/src/main/java/org/jboss/esb/osgi/jmsbus/JmsBusProviderActivator.java
labs/jbossesb/workspace/skeagh/container/osgi/pom.xml
labs/jbossesb/workspace/skeagh/container/osgi/runtime/src/main/java/org/jboss/esb/osgi/bus/AbstractBusProviderActivator.java
labs/jbossesb/workspace/skeagh/container/osgi/runtime/src/main/java/org/jboss/esb/osgi/config/OsgiConfigUtil.java
labs/jbossesb/workspace/skeagh/container/osgi/runtime/src/main/java/org/jboss/esb/osgi/config/OsgiPropertyTokenReplacer.java
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/config.properties
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/pom.xml
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsBus.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigUtil.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/PropertiesUtil.java
Log:
https://jira.jboss.org/jira/browse/JBESB-2182
Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/TokenReplacer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/TokenReplacer.java 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/properties/TokenReplacer.java 2008-11-30 10:17:54 UTC (rev 24147)
@@ -55,7 +55,7 @@
/**
* Regular expression replacement token pattern.
*/
- String PATTERN_EXPRESSION = "\\$\\{[.\\w]+\\}";
+ String PATTERN_EXPRESSION = "\\$\\{[.:.\\w]+\\}";
/**
* Get the identifier for the TokenReplacer.
@@ -110,7 +110,7 @@
int end = m.end();
String fullToken = string.substring((start + 2), (end - 1));
TokenReplacer replacer = null;
- int wordSeperatorIndex = fullToken.indexOf('.');
+ int wordSeperatorIndex = fullToken.indexOf(':');
if (wordSeperatorIndex != -1)
{
Modified: labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/properties/PropertyReplacementTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/properties/PropertyReplacementTest.java 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/properties/PropertyReplacementTest.java 2008-11-30 10:17:54 UTC (rev 24147)
@@ -50,8 +50,8 @@
assertEquals("8080", properties.getProperty("HOST_PORT"));
assertEquals(8080L, properties.getLongProperty("HOST_PORT", 2000L));
assertEquals(2000L, properties.getLongProperty("X", 2000L));
- assertEquals("xxxx${x.y}", properties.getProperty("someotherprop"));
- assertEquals(true, properties.getBooleanProperty("someboolval", false));
+ assertEquals("xxxx${x:y}", properties.getProperty("someotherprop"));
+ assertEquals(true, properties.getBooleanProperty("someboolval", false));
assertEquals(true, properties.getBooleanProperty("x", true));
assertEquals(false, properties.getBooleanProperty("x", false));
}
Modified: labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/properties/props.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/properties/props.properties 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/properties/props.properties 2008-11-30 10:17:54 UTC (rev 24147)
@@ -1,6 +1,6 @@
-index.system.url=http://${env.HOST}:${env.PORT.NUM}/myapp/index.html
+index.system.url=http://${env:HOST}:${env:PORT.NUM}/myapp/index.html
HOST_NAME=localhost
-index.prop.url=http://${local.HOST_NAME}:${HOST_PORT}/myapp/index.html
+index.prop.url=http://${local:HOST_NAME}:${HOST_PORT}/myapp/index.html
HOST_PORT=8080
-someotherprop=xxxx${x.y}
+someotherprop=xxxx${x:y}
someboolval=true
\ No newline at end of file
Modified: labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/properties/props.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/properties/props.xml 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/commons/src/test/java/org/jboss/esb/properties/props.xml 2008-11-30 10:17:54 UTC (rev 24147)
@@ -1,4 +1,4 @@
<config>
- <entry name="index.system.url">http://${env.HOST}:${PORT}/myapp/index.html</entry>
+ <entry name="index.system.url">http://${env:HOST}:${PORT}/myapp/index.html</entry>
<entry name="HOST_NAME">localhost</entry>
</config>
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/skeagh/container/osgi/configloader
___________________________________________________________________
Name: svn:ignore
+ *.iml
Added: labs/jbossesb/workspace/skeagh/container/osgi/configloader/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/configloader/pom.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/container/osgi/configloader/pom.xml 2008-11-30 10:17:54 UTC (rev 24147)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-osgi</artifactId>
+ <version>5.0-SNAPSHOT</version>
+ </parent>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-osgi-configloader</artifactId>
+ <packaging>bundle</packaging>
+ <version>${jboss.esb.version}</version>
+ <name>JBoss ESB OSGi Properties Configuration Loader Service</name>
+ <url>http://www.jboss.org/jbossesb/</url>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-osgi-runtime</artifactId>
+ <version>${jboss.esb.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>org.jboss.esb.osgi.configloader</Export-Package>
+ <Import-Package>org.jboss.esb.osgi.config, org.osgi.service.cm, *;resolution:=optional</Import-Package> <!-- TODO: Replace global import with explicit package imports? -->
+ <Bundle-Activator>org.jboss.esb.osgi.configloader.PropertyLoaderService</Bundle-Activator>
+ <Embed-Dependency>log4j</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Property changes on: labs/jbossesb/workspace/skeagh/container/osgi/configloader/pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/esb/osgi/configloader/PropertyLoaderService.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/esb/osgi/configloader/PropertyLoaderService.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/esb/osgi/configloader/PropertyLoaderService.java 2008-11-30 10:17:54 UTC (rev 24147)
@@ -0,0 +1,205 @@
+/*
+ * 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.osgi.configloader;
+
+import org.apache.log4j.Logger;
+import org.jboss.esb.api.exception.DeploymentException;
+import org.jboss.esb.osgi.config.OsgiConfigUtil;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Dictionary;
+import java.util.Properties;
+
+/**
+ * Property Loader.
+ * <p/>
+ * Registers all the .properties in the specified directory with the Configuration
+ * Admin Service. Registers them under the "service.pid" property value from the
+ * .properties file in question. Doesn't register the .properties file if this
+ * property is not specified.
+ * <p/>
+ * This Service is only intended for examples etc. Would use something better in
+ * a real env. <b>Disclaimer</b>: I wasn't able to find something similar that I could
+ * reuse.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class PropertyLoaderService implements BundleActivator
+{
+ /**
+ * Properties directory System property.
+ */
+ private static final String ORG_JBOSS_ESB_PROPERTIES_DIR = "org.jboss.esb.properties.dir";
+ /**
+ * Logger.
+ */
+ private static Logger logger = Logger.getLogger(PropertyLoaderService.class);
+
+ /**
+ * Start the bundle.
+ * @param bundleContext The bundle context.
+ * @throws Exception Failed to start bundle.
+ */
+ public final void start(final BundleContext bundleContext) throws Exception
+ {
+ File propertiesDir = getPropertiesDir(bundleContext);
+
+ if(!propertiesDir.exists() || !propertiesDir.isDirectory())
+ {
+ logger.error("The Property Loader Service is deployed, but the properties files directory '" + propertiesDir.getAbsolutePath() + "' is unknown or is not a directory.");
+ return;
+ }
+
+ File[] propertiesFiles = propertiesDir.listFiles();
+ if(propertiesFiles.length > 0)
+ {
+ loadPropertiesFiles(propertiesFiles, bundleContext);
+ }
+ }
+
+ /**
+ * Stop the bundle.
+ * @param bundleContext The bundle context.
+ * @throws Exception Failed to stop bundle.
+ */
+ public final void stop(final BundleContext bundleContext) throws Exception
+ {
+ }
+
+ /**
+ * Load the proeprties files and register them with the Configuration Admin Service.
+ * @param propertiesFiles The properties files.
+ * @param bundleContext The bundle context.
+ */
+ private void loadPropertiesFiles(final File[] propertiesFiles, final BundleContext bundleContext)
+ {
+ ServiceReference configAdminServiceRef = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
+ ConfigurationAdmin configAdminService = null;
+
+ if(configAdminServiceRef == null)
+ {
+ logger.warn("The Property Loader Service is deployed, but there's no deployed 'Configuration Admin Service' (e.g. the Felix 'Configuration Admin Service').");
+ return;
+ }
+
+ try
+ {
+ configAdminService = (ConfigurationAdmin) bundleContext.getService(configAdminServiceRef);
+ if(configAdminService == null)
+ {
+ logger.warn("The Property Loader Service is deployed, but there's no deployed 'Configuration Admin Service' (e.g. the Felix 'Configuration Admin Service').");
+ return;
+ }
+
+ for(File propertiesFile : propertiesFiles)
+ {
+ if (propertiesFile.getName().endsWith(".properties"))
+ {
+ try
+ {
+ Properties properties = OsgiConfigUtil.getConfiguration(propertiesFile.getAbsolutePath(), bundleContext, false);
+ String servicePid = properties.getProperty(Constants.SERVICE_PID);
+
+ if(servicePid != null)
+ {
+ Configuration config;
+ try
+ {
+ Properties propertiesToAdd;
+ Dictionary propsDictionary;
+
+ config = configAdminService.getConfiguration(servicePid);
+ propsDictionary = config.getProperties();
+
+ if(propsDictionary != null)
+ {
+ propertiesToAdd = OsgiConfigUtil.toProperties(propsDictionary);
+ }
+ else
+ {
+ propertiesToAdd = new Properties();
+ }
+ propertiesToAdd.putAll(properties);
+ config.update(propertiesToAdd);
+
+ logger.debug("Loaded .properties configuration '" + propertiesFile.getAbsolutePath() + "' for " + Constants.SERVICE_PID + " '" + servicePid + "'.");
+ }
+ catch (IOException e)
+ {
+ logger.warn("Error getting configuration from Configuration Admin Service for " + Constants.SERVICE_PID + " '" + servicePid + "'.", e);
+ }
+ }
+ else
+ {
+ logger.debug("Not loading .properties configuration '" + propertiesFile.getAbsolutePath() + "'. No '" + Constants.SERVICE_PID + "' property defined.");
+ }
+ }
+ catch (DeploymentException e)
+ {
+ logger.warn("Error loading .properties configuration '" + propertiesFile.getAbsolutePath() + "'.", e);
+ }
+ }
+ }
+ }
+ finally
+ {
+ bundleContext.ungetService(configAdminServiceRef);
+ }
+ }
+
+ /**
+ * Get the properties files directory.
+ * <p/>
+ * Checks for the "org.jboss.esb.properties.dir" property in the System and the Bundle
+ * properties. If not set, it defaults to "./jbossesb".
+ *
+ * @param bundleContext The bundle context.
+ * @return The properties files directory.
+ */
+ private File getPropertiesDir(final BundleContext bundleContext)
+ {
+ String propertyiesDirConfig = System.getProperty(ORG_JBOSS_ESB_PROPERTIES_DIR);
+
+ if(propertyiesDirConfig == null)
+ {
+ propertyiesDirConfig = bundleContext.getProperty(ORG_JBOSS_ESB_PROPERTIES_DIR);
+ }
+
+ if(propertyiesDirConfig == null)
+ {
+ File defaultDir = new File("./jbossesb");
+ logger.info("Property '" + ORG_JBOSS_ESB_PROPERTIES_DIR + "' not specified as a System or OSGi container property. Loading properties files from default dir '" + defaultDir.getAbsolutePath() + "'.");
+ return defaultDir;
+ }
+ else
+ {
+ File propertyiesDir = new File(propertyiesDirConfig);
+ logger.info("Loading properties files from dir '" + propertyiesDir.getAbsolutePath() + "'.");
+ return propertyiesDir;
+ }
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/esb/osgi/configloader/PropertyLoaderService.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/esb/osgi/configloader/package.html
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/esb/osgi/configloader/package.html (rev 0)
+++ labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/java/org/jboss/esb/osgi/configloader/package.html 2008-11-30 10:17:54 UTC (rev 24147)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+JBoss ESB Service configuration utility for OSGi.
+
+<h2>Package Specification</h2>
+</body>
+</html>
\ No newline at end of file
Added: labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/resources/log4j.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/resources/log4j.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/resources/log4j.xml 2008-11-30 10:17:54 UTC (rev 24147)
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+
+ <category name="org.milyn">
+ <priority value="error"/>
+ </category>
+
+ <category name="org.quartz">
+ <priority value="error"/>
+ </category>
+
+ <category name="org.jboss">
+ <priority value="debug"/>
+ </category>
+
+ <category name="org.apache.activemq">
+ <priority value="ERROR"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
+
Property changes on: labs/jbossesb/workspace/skeagh/container/osgi/configloader/src/main/resources/log4j.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Modified: labs/jbossesb/workspace/skeagh/container/osgi/jmsbus/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/jmsbus/pom.xml 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/container/osgi/jmsbus/pom.xml 2008-11-30 10:17:54 UTC (rev 24147)
@@ -40,7 +40,7 @@
<configuration>
<instructions>
<Private-Package>org.jboss.esb.osgi.jmsbus</Private-Package>
- <Import-Package>org.jboss.esb.osgi.bus,org.jboss.esb.jms,org.jboss.esb.api.*, *;resolution:=optional</Import-Package> <!-- TODO: Replace global import with explicit package imports? -->
+ <Import-Package>org.jboss.esb.osgi.bus,org.jboss.esb.jms,org.jboss.esb.api.*,org.osgi.service.cm, *;resolution:=optional</Import-Package> <!-- TODO: Replace global import with explicit package imports? -->
<Bundle-Activator>org.jboss.esb.osgi.jmsbus.JmsBusProviderActivator</Bundle-Activator>
<Embed-Dependency>jbossesb-commons, commons-logging, log4j</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
Modified: labs/jbossesb/workspace/skeagh/container/osgi/jmsbus/src/main/java/org/jboss/esb/osgi/jmsbus/JmsBusProviderActivator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/jmsbus/src/main/java/org/jboss/esb/osgi/jmsbus/JmsBusProviderActivator.java 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/container/osgi/jmsbus/src/main/java/org/jboss/esb/osgi/jmsbus/JmsBusProviderActivator.java 2008-11-30 10:17:54 UTC (rev 24147)
@@ -21,10 +21,17 @@
import org.jboss.esb.api.bus.BusProvider;
import org.jboss.esb.jms.JmsBusProvider;
+import org.jboss.esb.osgi.bundle.BundleResourceLocator;
import org.jboss.esb.osgi.bus.AbstractBusProviderActivator;
-import org.jboss.esb.osgi.bundle.BundleResourceLocator;
+import org.jboss.esb.osgi.config.OsgiConfigUtil;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import java.util.Dictionary;
+import java.util.Hashtable;
import java.util.Properties;
/**
@@ -32,8 +39,20 @@
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
-public class JmsBusProviderActivator extends AbstractBusProviderActivator
+public class JmsBusProviderActivator extends AbstractBusProviderActivator implements ManagedService
{
+ /**
+ * Service PID for the JMS Bus.
+ */
+ public static final String JMSBUS_SERVICE_PID = "org.jboss.esb.jmsbus";
+ /**
+ * Bundle context.
+ */
+ private BundleContext bundleContext;
+ /**
+ * JMS Bus Managed Service registration.
+ */
+ private ServiceRegistration jmsBusManagedService;
/**
* Start the JMS {@link BusProvider} Service.
@@ -43,9 +62,41 @@
*/
public void start(final BundleContext bundleContext) throws Exception
{
- Properties busProperties = loadBusConfiguration("jmsbus.properties", bundleContext);
- BusProvider busProvider = new JmsBusProvider(busProperties, new BundleResourceLocator(bundleContext.getBundle()));
+ Dictionary props = new Hashtable();
- registerBusProviderService(busProvider, bundleContext);
+ props.put(Constants.SERVICE_PID, JMSBUS_SERVICE_PID);
+ jmsBusManagedService = bundleContext.registerService(ManagedService.class.getName(), this, props);
+
+ this.bundleContext = bundleContext;
}
+
+ /**
+ * Receive the bundle configuration.
+ * @param dictionary Configuration.
+ * @throws ConfigurationException Error configuring.
+ */
+ public void updated(Dictionary dictionary) throws ConfigurationException
+ {
+ if(dictionary != null)
+ {
+ Properties config = OsgiConfigUtil.toProperties(dictionary);
+ BusProvider busProvider = new JmsBusProvider(config, new BundleResourceLocator(bundleContext.getBundle()));
+
+ registerBusProviderService(busProvider, bundleContext);
+ }
+ }
+
+ /**
+ * Stop the JMS {@link org.jboss.esb.api.bus.BusProvider} Managed Service.
+ *
+ * @param bundleContext The bundle context.
+ */
+ public final void stop(final BundleContext bundleContext)
+ {
+ if (jmsBusManagedService != null)
+ {
+ jmsBusManagedService.unregister();
+ jmsBusManagedService = null;
+ }
+ }
}
Modified: labs/jbossesb/workspace/skeagh/container/osgi/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/pom.xml 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/container/osgi/pom.xml 2008-11-30 10:17:54 UTC (rev 24147)
@@ -15,6 +15,7 @@
<url>http://www.jboss.org/jbossesb/</url>
<modules>
+ <module>configloader</module>
<module>runtime</module>
<module>jmsbus</module>
</modules>
Modified: labs/jbossesb/workspace/skeagh/container/osgi/runtime/src/main/java/org/jboss/esb/osgi/bus/AbstractBusProviderActivator.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/runtime/src/main/java/org/jboss/esb/osgi/bus/AbstractBusProviderActivator.java 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/container/osgi/runtime/src/main/java/org/jboss/esb/osgi/bus/AbstractBusProviderActivator.java 2008-11-30 10:17:54 UTC (rev 24147)
@@ -20,13 +20,9 @@
package org.jboss.esb.osgi.bus;
import org.jboss.esb.api.bus.BusProvider;
-import org.jboss.esb.api.exception.DeploymentException;
-import org.jboss.esb.osgi.config.OsgiConfigUtil;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import java.util.Properties;
-
/**
* Abstract OSGi activator class for JBoss ESB {@link BusProvider}
* Services.
@@ -44,32 +40,7 @@
*/
protected final void registerBusProviderService(final BusProvider busProvider, final BundleContext bundleContext)
{
+ // TODO: Unregister the BusProvider Service if it's already registered and then reregister it.
bundleContext.registerService(BusProvider.class.getName(), busProvider, null);
}
-
- /**
- * Stop the JMS {@link org.jboss.esb.api.bus.BusProvider} Service.
- *
- * @param bundleContext The bundle context.
- */
- public final void stop(final BundleContext bundleContext)
- {
- // Nothing to do here. The OSGi will automatically unregister
- // the BusProvider Service for the JmsBusProvider.
- }
-
- /**
- * Load the Bus configuration.
- *
- * @param configPath Configuration path.
- * @param bundleContext Bundle context.
- * @return The Bus configuration properties.
- * @throws org.jboss.esb.api.exception.DeploymentException
- * Unable to access the bus configuration.
- * @throws java.io.IOException Error reading the bus configuration.
- */
- protected final Properties loadBusConfiguration(final String configPath, final BundleContext bundleContext) throws DeploymentException
- {
- return OsgiConfigUtil.getConfiguration(configPath, bundleContext);
- }
}
\ No newline at end of file
Modified: labs/jbossesb/workspace/skeagh/container/osgi/runtime/src/main/java/org/jboss/esb/osgi/config/OsgiConfigUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/runtime/src/main/java/org/jboss/esb/osgi/config/OsgiConfigUtil.java 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/container/osgi/runtime/src/main/java/org/jboss/esb/osgi/config/OsgiConfigUtil.java 2008-11-30 10:17:54 UTC (rev 24147)
@@ -21,12 +21,13 @@
import org.jboss.esb.api.exception.DeploymentException;
import org.jboss.esb.deploy.config.PropertiesUtil;
-import org.jboss.esb.deploy.config.ConfigUtil;
import org.jboss.esb.osgi.bundle.BundleResourceLocator;
import org.jboss.esb.properties.ApplicationProperties;
import org.osgi.framework.BundleContext;
import java.util.Properties;
+import java.util.Dictionary;
+import java.util.Enumeration;
/**
* OSGi Configuration utility.
@@ -46,21 +47,39 @@
* Get the named configuration form the specified bundle.
* @param configPath The configuration path.
* @param bundleContext The bundle context.
+ * @param resolve Resolve the path against the current working directory.
* @return The Properties instance.
* @throws DeploymentException Failed to read the properties file.
*/
- public static Properties getConfiguration(final String configPath, final BundleContext bundleContext) throws DeploymentException
+ public static Properties getConfiguration(final String configPath, final BundleContext bundleContext, final boolean resolve) throws DeploymentException
{
- ApplicationProperties properties = PropertiesUtil.getConfig(configPath, new BundleResourceLocator(bundleContext.getBundle()));
+ ApplicationProperties properties = new ApplicationProperties();
- if(properties == null)
- {
- throw new DeploymentException("Failed to load properties file '" + configPath + "' from filesystem (" + ConfigUtil.getFilePath(configPath) + ") or classpath (" + ConfigUtil.getClassPath(configPath) + ").");
- }
-
// Add a token replacer for getting properties from the bundle context...
properties.register(new OsgiPropertyTokenReplacer(bundleContext));
+ // And load the properties....
+ PropertiesUtil.getConfig(configPath, new BundleResourceLocator(bundleContext.getBundle()), properties, resolve);
return properties;
}
+
+ /**
+ * Convert the Dictionary instance ot a Properties instance.
+ * @param dictionary The dictionary.
+ * @return The Properties instance.
+ */
+ public static Properties toProperties(final Dictionary dictionary)
+ {
+ Properties config = new Properties();
+ Enumeration keys = dictionary.keys();
+
+ while(keys.hasMoreElements())
+ {
+ String key = (String) keys.nextElement();
+ String value = (String) dictionary.get(key);
+ config.put(key, value);
+ }
+
+ return config;
+ }
}
Modified: labs/jbossesb/workspace/skeagh/container/osgi/runtime/src/main/java/org/jboss/esb/osgi/config/OsgiPropertyTokenReplacer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/runtime/src/main/java/org/jboss/esb/osgi/config/OsgiPropertyTokenReplacer.java 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/container/osgi/runtime/src/main/java/org/jboss/esb/osgi/config/OsgiPropertyTokenReplacer.java 2008-11-30 10:17:54 UTC (rev 24147)
@@ -64,4 +64,4 @@
{
return bundleContext.getProperty(token);
}
-}
+}
\ No newline at end of file
Modified: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/config.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/config.properties 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/config.properties 2008-11-30 10:17:54 UTC (rev 24147)
@@ -26,6 +26,7 @@
${jre-${java.specification.version}}
org.osgi.framework.storage.clean=onFirstInit
+org.jboss.esb.properties.dir=./
m2.path=${user.home}/.m2/repository
apache.m2.path=${m2.path}/org/apache
@@ -36,14 +37,16 @@
felix.auto.start.1= \
"file:${apache.m2.path}/felix/org.apache.felix.shell/1.0.2/org.apache.felix.shell-1.0.2.jar" \
"file:${apache.m2.path}/felix/org.apache.felix.shell.tui/1.0.2/org.apache.felix.shell.tui-1.0.2.jar" \
+ "file:${apache.m2.path}/felix/org.apache.felix.configadmin/1.0.4/org.apache.felix.configadmin-1.0.4.jar" \
"file:${apache.m2.path}/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar" \
"file:${jbossesb.m2.path}/jbossesb-api/5.0-SNAPSHOT/jbossesb-api-5.0-SNAPSHOT.jar" \
"file:${jbossesb.m2.path}/jbossesb-osgi-runtime/5.0-SNAPSHOT/jbossesb-osgi-runtime-5.0-SNAPSHOT.jar" \
+ "file:${jbossesb.m2.path}/jbossesb-osgi-configloader/5.0-SNAPSHOT/jbossesb-osgi-configloader-5.0-SNAPSHOT.jar" \
"file:${jbossesb.m2.path}/jbossesb-routing-jms/5.0-SNAPSHOT/jbossesb-routing-jms-5.0-SNAPSHOT.jar" \
- "file:${jbossesb.m2.path}/jbossesb-routing-jms/5.0-SNAPSHOT/jbossesb-osgi-jmsbus-5.0-SNAPSHOT.jar" \
- "file:${jbossesb.m2.path}/jbossesb-examples-jms-router-esb-jms-router/5.0-SNAPSHOT/jbossesb-examples-jms-router-esb-jms-router-5.0-SNAPSHOT.jar"
+ "file:${jbossesb.m2.path}/jbossesb-osgi-jmsbus/5.0-SNAPSHOT/jbossesb-osgi-jmsbus-5.0-SNAPSHOT.jar" \
+ "file:${jbossesb.m2.path}/jbossesb-examples-jms-router-esb-jms-router/5.0-SNAPSHOT/jbossesb-examples-jms-router-esb-jms-router-5.0-SNAPSHOT.jar"
-felix.log.level=4
+felix.log.level=1
felix.startlevel.framework=1
felix.startlevel.bundle=1
#felix.service.urlhandlers=false
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/jmsbus.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/jmsbus.properties (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/jmsbus.properties 2008-11-30 10:17:54 UTC (rev 24147)
@@ -0,0 +1,19 @@
+###########################################################################################
+# JMS bus config.
+##########################################################################################
+
+# Service PID used by the Property Loader Service for loading the properties into the
+# Configuration Admin Service...
+service.pid=org.jboss.esb.jmsbus
+
+# JNDI Settings...
+java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
+java.naming.provider.url=tcp://localhost:61717
+
+# Bus Queues and Topics...
+deployment.coordintation.topic=jbossesb.deployment.coordintation.topic
+deployment.bus.queue=jbossesb.jms.bus
+
+# ActiveMQ Queue and Topic deployments...
+topic.jbossesb.deployment.coordintation.topic=jbossesb.deployment.coordintation.topic
+queue.jbossesb.jms.bus=jbossesb.jms.bus
Property changes on: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/jmsbus.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/pax.runner.args
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/pax.runner.args (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/pax.runner.args 2008-11-30 10:17:54 UTC (rev 24147)
@@ -0,0 +1 @@
+--org.ops4j.pax.runner.platform.workingDirectory=target
\ No newline at end of file
Modified: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/pom.xml 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/pom.xml 2008-11-30 10:17:54 UTC (rev 24147)
@@ -14,7 +14,8 @@
<packaging>bundle</packaging>
<properties>
- <felix.log.level>1</felix.log.level><!-- 4=debug -->
+ <felix.log.level>4</felix.log.level><!-- 4=debug -->
+ <org.jboss.esb.properties.dir>../</org.jboss.esb.properties.dir>
</properties>
<dependencies>
@@ -25,6 +26,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.configadmin</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+
+ <dependency>
<groupId>jboss.jbossesb</groupId>
<artifactId>jbossesb-api</artifactId>
<version>${jboss.esb.version}</version>
@@ -36,7 +43,12 @@
<artifactId>jbossesb-osgi-runtime</artifactId>
<version>${jboss.esb.version}</version>
</dependency>
- <dependency>
+ <dependency>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-osgi-configloader</artifactId>
+ <version>${jboss.esb.version}</version>
+ </dependency>
+ <dependency>
<groupId>jboss.jbossesb</groupId>
<artifactId>jbossesb-routing-jms</artifactId>
<version>${jboss.esb.version}</version>
@@ -69,9 +81,7 @@
<version>1.3</version>
<extensions>true</extensions>
<configuration>
- <org.ops4j.pax.runner.platform.workingDirectory>target</org.ops4j.pax.runner.platform.workingDirectory>
- <java.naming.factory.initial>org.apache.activemq.jndi.ActiveMQInitialContextFactory</java.naming.factory.initial>
- <java.naming.provider.url>tcp://localhost:61717</java.naming.provider.url>
+ <args>file:pax.runner.args</args>
</configuration>
</plugin>
<plugin>
Modified: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsBus.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsBus.java 2008-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsBus.java 2008-11-30 10:17:54 UTC (rev 24147)
@@ -368,8 +368,7 @@
catch (Throwable t)
{
closeJMSSessions();
- logger.debug("Failed to connect shared deployment JMS Topic Session.", t);
- return;
+ throw new DeploymentException("Failed to connect shared deployment JMS Topic Session.", t);
}
try
{
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-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java 2008-11-30 10:17:54 UTC (rev 24147)
@@ -490,7 +490,7 @@
String defaultCheckPath = "preinstalled/" + unitPath;
// Try for a deployment specific configuration...
- InputStream configStream = ConfigUtil.getConfigStream(deploymentCheckPath, resourceLocator);
+ InputStream configStream = ConfigUtil.getConfigStream(deploymentCheckPath, resourceLocator, true);
if (configStream != null)
{
try
@@ -505,7 +505,7 @@
}
// Try for a default configuration...
- configStream = ConfigUtil.getConfigStream(defaultCheckPath, resourceLocator);
+ configStream = ConfigUtil.getConfigStream(defaultCheckPath, resourceLocator, true);
if (configStream != null)
{
try
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-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigUtil.java 2008-11-30 10:17:54 UTC (rev 24147)
@@ -21,9 +21,9 @@
import org.jboss.esb.api.annotations.AnnotationConstants;
import org.jboss.esb.api.annotations.Property;
-import org.jboss.esb.classpath.ClassUtil;
import org.jboss.esb.api.context.ResourceLocator;
import org.jboss.esb.api.exception.DeploymentException;
+import org.jboss.esb.classpath.ClassUtil;
import org.jboss.esb.util.AssertArgument;
import org.milyn.javabean.DataDecoder;
@@ -60,7 +60,7 @@
}
/**
- * Get the specified configuration stream.
+ * Get the specified configuration stream using the passed in ResourceLocator.
* <p/>
* Checks in the following order:
* <ol>
@@ -69,34 +69,28 @@
* </ol>
*
* @param configPath The configuration file path.
+ * @param resourceLocator The {@link org.jboss.esb.api.context.ResourceLocator} implementation to use.
+ * @param resolve Resolve the path against the current working directory.
* @return The configuration stream, or null if the specified configuration cannot be found.
* @throws org.jboss.esb.api.exception.DeploymentException Unable to read configuration.
*/
- public static InputStream getConfigStream(final String configPath) throws DeploymentException
+ public static InputStream getConfigStream(final String configPath, final ResourceLocator resourceLocator, final boolean resolve) throws DeploymentException
{
- String fileCheckPath = getFilePath(configPath);
- String cpCheckPath = getClassPath(configPath);
+ AssertArgument.isNotNull(resourceLocator, "resourceLocator");
- // 1st: Check for a config on the local file system...
- File checkFile = new File(fileCheckPath);
- if (checkFile.exists() && !checkFile.isDirectory())
+ InputStream configStream = getConfigFileStream(configPath, resolve);
+ if(configStream == null)
{
- try
- {
- return new FileInputStream(checkFile);
- }
- catch (IOException e)
- {
- throw new DeploymentException("Error reading configuration file '" + checkFile.getAbsolutePath() + "'.", e);
- }
+ // 2nd: Check for a config using the resource locator...
+ String cpCheckPath = getClassPath(configPath);
+ configStream = resourceLocator.getResourceAsStream(cpCheckPath, ConfigUtil.class);
}
- // 2nd: Check for a config on the classpath...
- return ClassUtil.getResourceAsStream(cpCheckPath, ConfigUtil.class);
+ return configStream;
}
/**
- * Get the specified configuration stream using the passed in ResourceLocator.
+ * Get the specified configuration stream.
* <p/>
* Checks in the following order:
* <ol>
@@ -105,17 +99,19 @@
* </ol>
*
* @param configPath The configuration file path.
- * @param resourceLocator The {@link ResourceLocator} implementation to use.
+ * @param resolve Resolve the path against the current working directory.
* @return The configuration stream, or null if the specified configuration cannot be found.
* @throws org.jboss.esb.api.exception.DeploymentException Unable to read configuration.
*/
- public static InputStream getConfigStream(final String configPath, final ResourceLocator resourceLocator) throws DeploymentException
+ private static InputStream getConfigFileStream(final String configPath, final boolean resolve) throws DeploymentException
{
- AssertArgument.isNotNull(resourceLocator, "resourceLocator");
- String fileCheckPath = getFilePath(configPath);
- String cpCheckPath = getClassPath(configPath);
+ String fileCheckPath = configPath;
- // 1st: Check for a config on the local file system...
+ if(resolve)
+ {
+ fileCheckPath = getFilePath(configPath);
+ }
+
File checkFile = new File(fileCheckPath);
if (checkFile.exists() && !checkFile.isDirectory())
{
@@ -129,8 +125,7 @@
}
}
- // 2nd: Check for a config using the resource locator...
- return resourceLocator.getResourceAsStream(cpCheckPath, ConfigUtil.class);
+ return null;
}
/**
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-11-29 00:12:54 UTC (rev 24146)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/PropertiesUtil.java 2008-11-30 10:17:54 UTC (rev 24147)
@@ -72,14 +72,14 @@
ApplicationProperties deploymentProperties;
// Get the default ...
- properties = getConfig(defaultCheckPath, resourceLocator);
+ properties = getConfig(defaultCheckPath, resourceLocator, true);
if (properties == null)
{
throw new DeploymentException("Unable to find the default Bus configuration for protocol '" + protocol + "''.");
}
// Check for a deployment specific config ...
- deploymentProperties = getConfig(deploymentCheckPath, resourceLocator);
+ deploymentProperties = getConfig(deploymentCheckPath, resourceLocator, true);
if (deploymentProperties != null)
{
// Overlay the deault properties with the deployment specific properties....
@@ -116,14 +116,14 @@
ApplicationProperties deploymentProperties;
// Get the default ...
- properties = getConfig(defaultCheckPath, resourceLocator);
+ properties = getConfig(defaultCheckPath, resourceLocator, true);
if (properties == null)
{
throw new DeploymentException("Unable to find the default JBoss ESB Deployment configuration '" + defaultCheckPath + "' for deployment '" + deploymentName + "'.");
}
// Check for a deployment specific config ...
- deploymentProperties = getConfig(deploymentCheckPath, resourceLocator);
+ deploymentProperties = getConfig(deploymentCheckPath, resourceLocator, true);
if (deploymentProperties != null)
{
// Overlay the deault properties with the deployment specific properties....
@@ -144,13 +144,14 @@
*
* @param configPath The configuration file path.
* @param resourceLocator The {@link ResourceLocator} to use for looking up property files.
+ * @param resolve Resolve the path against the current working directory.
* @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, final ResourceLocator resourceLocator) throws DeploymentException
+ public static ApplicationProperties getConfig(final String configPath, final ResourceLocator resourceLocator, final boolean resolve) throws DeploymentException
{
- InputStream configStream = ConfigUtil.getConfigStream(configPath, resourceLocator);
+ InputStream configStream = ConfigUtil.getConfigStream(configPath, resourceLocator, resolve);
if (configStream != null)
{
@@ -166,4 +167,40 @@
return null;
}
+
+ /**
+ * Get the specified properties configuration.
+ * <p/>
+ * Checks in the following order:
+ * <ol>
+ * <li>File: "busconfig/<configPath>"</li>
+ * <li>Classpath: "/META-INF/jbossesb/<configPath>"</li>
+ * </ol>
+ *
+ * @param configPath The configuration file path.
+ * @param resourceLocator The {@link ResourceLocator} to use for looking up property files.
+ * @param properties The properties file to be populated.
+ * @param resolve Resolve the path against the current working directory.
+ * @throws DeploymentException Unable to read configuration.
+ */
+ public static void getConfig(final String configPath, final ResourceLocator resourceLocator, final ApplicationProperties properties, final boolean resolve) throws DeploymentException
+ {
+ InputStream configStream = ConfigUtil.getConfigStream(configPath, resourceLocator, resolve);
+
+ if (configStream != null)
+ {
+ try
+ {
+ properties.load(configStream);
+ }
+ catch (IOException e)
+ {
+ throw new DeploymentException("Error reading properties file '" + configPath + "'.", e);
+ }
+ }
+ else
+ {
+ throw new DeploymentException("Error reading properties file '" + configPath + "'.");
+ }
+ }
}
More information about the jboss-svn-commits
mailing list