You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ha...@apache.org on 2014/12/16 00:22:02 UTC
[17/17] activemq git commit:
https://issues.apache.org/jira/browse/AMQ-5239
https://issues.apache.org/jira/browse/AMQ-5239
Add a getter for the BrokerService map.
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/3ab3f04f
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/3ab3f04f
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/3ab3f04f
Branch: refs/heads/activemq-5.10.x
Commit: 3ab3f04f941d4b83d95031f1f5335d0529b6b9cc
Parents: f59e51b
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Jun 24 11:18:58 2014 -0400
Committer: Hadrian Zbarcea <ha...@apache.org>
Committed: Mon Dec 15 17:06:57 2014 -0500
----------------------------------------------------------------------
.../activemq/osgi/ActiveMQServiceFactory.java | 32 ++++++++++++--------
1 file changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/3ab3f04f/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java
----------------------------------------------------------------------
diff --git a/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java b/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java
index 16da689..430a300 100644
--- a/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java
+++ b/activemq-osgi/src/main/java/org/apache/activemq/osgi/ActiveMQServiceFactory.java
@@ -16,6 +16,13 @@
*/
package org.apache.activemq.osgi;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.spring.SpringBrokerContext;
import org.apache.activemq.spring.Utils;
@@ -29,8 +36,6 @@ import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource;
-import java.util.*;
-
public class ActiveMQServiceFactory implements ManagedServiceFactory {
private static final Logger LOG = LoggerFactory.getLogger(ActiveMQServiceFactory.class);
@@ -43,17 +48,22 @@ public class ActiveMQServiceFactory implements ManagedServiceFactory {
return "ActiveMQ Server Controller";
}
+ public Map<String, BrokerService> getBrokersMap() {
+ return Collections.unmodifiableMap(brokers);
+ }
+
+ @SuppressWarnings("rawtypes")
@Override
synchronized public void updated(String pid, Dictionary properties) throws ConfigurationException {
// First stop currently running broker (if any)
deleted(pid);
- String config = (String)properties.get("config");
+ String config = (String) properties.get("config");
if (config == null) {
throw new ConfigurationException("config", "Property must be set");
}
- String name = (String)properties.get("broker-name");
+ String name = (String) properties.get("broker-name");
if (name == null) {
throw new ConfigurationException("broker-name", "Property must be set");
}
@@ -65,18 +75,18 @@ public class ActiveMQServiceFactory implements ManagedServiceFactory {
Resource resource = Utils.resourceFromString(config);
ResourceXmlApplicationContext ctx = new ResourceXmlApplicationContext(resource, Collections.EMPTY_LIST, null, Collections.EMPTY_LIST, false) {
+ @Override
protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
reader.setValidating(false);
}
};
// Handle properties in configuration
- PropertyPlaceholderConfigurer configurator =
- new PropertyPlaceholderConfigurer();
+ PropertyPlaceholderConfigurer configurator = new PropertyPlaceholderConfigurer();
- //convert dictionary to properties. Is there a better way?
+ // convert dictionary to properties. Is there a better way?
Properties props = new Properties();
- Enumeration elements = properties.keys();
+ Enumeration<?> elements = properties.keys();
while (elements.hasMoreElements()) {
Object key = elements.nextElement();
props.put(key, properties.get(key));
@@ -94,7 +104,7 @@ public class ActiveMQServiceFactory implements ManagedServiceFactory {
if (broker == null) {
throw new ConfigurationException(null, "Broker not defined");
}
- //TODO deal with multiple brokers
+ // TODO deal with multiple brokers
SpringBrokerContext brokerContext = new SpringBrokerContext();
brokerContext.setConfigurationUrl(resource.getURL().toExternalForm());
@@ -104,8 +114,6 @@ public class ActiveMQServiceFactory implements ManagedServiceFactory {
broker.start();
broker.waitUntilStarted();
brokers.put(pid, broker);
-
-
} catch (Exception e) {
throw new ConfigurationException(null, "Cannot start the broker", e);
}
@@ -127,7 +135,7 @@ public class ActiveMQServiceFactory implements ManagedServiceFactory {
}
synchronized public void destroy() {
- for (String broker: brokers.keySet()) {
+ for (String broker : brokers.keySet()) {
deleted(broker);
}
}