git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@812139 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2009-09-07 13:52:45 +00:00
parent 9b305d669b
commit c1051c8ee1
4 changed files with 68 additions and 0 deletions

View File

@ -905,6 +905,23 @@ public class BrokerService implements Service {
return null;
}
public Map<String, String> getTransportConnectorURIsAsMap() {
Map<String, String> answer = new HashMap<String, String>();
for (TransportConnector connector : transportConnectors) {
try {
URI uri = connector.getConnectUri();
String scheme = uri.getScheme();
if (scheme != null) {
answer.put(scheme.toLowerCase(), uri.toString());
System.err.println(scheme + " = " + uri);
}
} catch (Exception e) {
LOG.debug("Failed to read URI to build transportURIsAsMap", e);
}
}
return answer;
}
public String[] getTransportConnectorURIs() {
return transportConnectorURIs;
}
@ -1958,4 +1975,6 @@ public class BrokerService implements Service {
public CountDownLatch getSlaveStartSignal() {
return slaveStartSignal;
}
}

View File

@ -18,6 +18,7 @@ package org.apache.activemq.broker.jmx;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.util.concurrent.atomic.AtomicInteger;
@ -319,4 +320,30 @@ public class BrokerView implements BrokerViewMBean {
throw e.getTargetException();
}
}
public String getOpenWireURL() {
String answer = brokerService.getTransportConnectorURIsAsMap().get("tcp");
return answer != null ? answer : "";
}
public String getStompURL() {
String answer = brokerService.getTransportConnectorURIsAsMap().get("stomp");
return answer != null ? answer : "";
}
public String getSslURL() {
String answer = brokerService.getTransportConnectorURIsAsMap().get("ssl");
return answer != null ? answer : "";
}
public String getStompSslURL() {
String answer = brokerService.getTransportConnectorURIsAsMap().get("stomp+ssl");
return answer != null ? answer : "";
}
public String getVMURL() {
URI answer = brokerService.getVmConnectorURI();
return answer != null ? answer.toString() : "";
}
}

View File

@ -223,4 +223,19 @@ public interface BrokerViewMBean extends Service {
@MBeanInfo(value="Reloads log4j.properties from the classpath.")
public void reloadLog4jProperties() throws Throwable;
@MBeanInfo("The url of the openwire connector")
String getOpenWireURL();
@MBeanInfo("The url of the stomp connector")
String getStompURL();
@MBeanInfo("The url of the SSL connector")
String getSslURL();
@MBeanInfo("The url of the Stomp SSL connector")
String getStompSslURL();
@MBeanInfo("The url of the VM connector")
String getVMURL();
}

View File

@ -72,6 +72,13 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
TestRunner.run(MBeanTest.class);
}
public void testConnectors() throws Exception{
ObjectName brokerName = assertRegisteredObjectName(domain + ":Type=Broker,BrokerName=localhost");
BrokerViewMBean broker = (BrokerViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
assertEquals("openwire URL doesn't equal bind Address",broker.getOpenWireURL(),this.bindAddress);
}
public void testMBeans() throws Exception {
connection = connectionFactory.createConnection();
useConnection(connection);