activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1436956 - in /activemq/trunk: activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/ activemq-osgi/src/main/java/org/apache/activemq/osgi/
Date Tue, 22 Jan 2013 14:34:16 GMT
Author: dejanb
Date: Tue Jan 22 14:34:16 2013
New Revision: 1436956

URL: http://svn.apache.org/viewvc?rev=1436956&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-4034 - support configuration properties

Modified:
    activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq.xml
    activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/org.apache.activemq.server-default.cfg
    activemq/trunk/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java

Modified: activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq.xml?rev=1436956&r1=1436955&r2=1436956&view=diff
==============================================================================
--- activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq.xml
(original)
+++ activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/activemq.xml
Tue Jan 22 14:34:16 2013
@@ -26,7 +26,7 @@
 
 
     <broker xmlns="http://activemq.apache.org/schema/core"
-            brokerName="localhost"
+            brokerName="${broker-name}"
             dataDirectory="data"
             start="false">
 

Modified: activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/org.apache.activemq.server-default.cfg
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/org.apache.activemq.server-default.cfg?rev=1436956&r1=1436955&r2=1436956&view=diff
==============================================================================
--- activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/org.apache.activemq.server-default.cfg
(original)
+++ activemq/trunk/activemq-karaf-itest/src/test/resources/org/apache/activemq/karaf/itest/org.apache.activemq.server-default.cfg
Tue Jan 22 14:34:16 2013
@@ -1,3 +1,3 @@
-broker-name=localhost
-data=${karaf.data}/localhost
+broker-name=amq-broker
+data=${karaf.data}/${broker-name}
 config=${karaf.base}/etc/activemq.xml
\ No newline at end of file

Modified: activemq/trunk/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java?rev=1436956&r1=1436955&r2=1436956&view=diff
==============================================================================
--- activemq/trunk/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java
(original)
+++ activemq/trunk/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java
Tue Jan 22 14:34:16 2013
@@ -25,10 +25,12 @@ import org.osgi.service.cm.ManagedServic
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
 import org.springframework.core.io.Resource;
 
-import java.util.Dictionary;
-import java.util.HashMap;
+import java.util.*;
 
 public class ActiveMQServiceFactory implements ManagedServiceFactory {
 
@@ -54,17 +56,37 @@ public class ActiveMQServiceFactory impl
         }
 
         LOG.info("Starting broker " + name);
-        //TODO properties
 
         try {
             Thread.currentThread().setContextClassLoader(BrokerService.class.getClassLoader());
             Resource resource = Utils.resourceFromString(config);
-            ResourceXmlApplicationContext ctx = new ResourceXmlApplicationContext((resource))
{
+
+            ResourceXmlApplicationContext ctx = new ResourceXmlApplicationContext(resource,
Collections.EMPTY_LIST, null, Collections.EMPTY_LIST, false) {
                 protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
                     reader.setValidating(false);
                 }
             };
 
+            // Handle properties in configuration
+            PropertySourcesPlaceholderConfigurer configurator =
+                        new PropertySourcesPlaceholderConfigurer();
+
+            //convert dictionary to properties. Is there a better way?
+            Properties props = new Properties();
+            Enumeration elements = properties.keys();
+            while (elements.hasMoreElements()) {
+                Object key = elements.nextElement();
+                props.put(key, properties.get(key));
+            }
+
+            configurator.setProperties(props);
+            configurator.setIgnoreUnresolvablePlaceholders(true);
+
+            ctx.addBeanFactoryPostProcessor(configurator);
+
+            ctx.refresh();
+
+            // Start the broker
             BrokerService broker = ctx.getBean(BrokerService.class);
             if (broker == null) {
                 throw new ConfigurationException(null, "Broker not defined");



Mime
View raw message