patch from Andrew Deason for AMQ-1260 - applied with thanks!

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@549840 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2007-06-22 15:19:30 +00:00
parent f09dcd932d
commit fccb3cc2b0
2 changed files with 18 additions and 1 deletions

View File

@ -34,6 +34,7 @@ import javax.management.remote.JMXServiceURL;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
@ -46,6 +47,8 @@ import java.util.Set;
public class RemoteJMXBrokerFacade extends BrokerFacadeSupport {
private static final transient Log log = LogFactory.getLog(RemoteJMXBrokerFacade.class);
private String jmxUrl;
private String jmxRole;
private String jmxPassword;
private String brokerName;
private JMXConnector connector;
@ -57,6 +60,14 @@ public class RemoteJMXBrokerFacade extends BrokerFacadeSupport {
this.jmxUrl = url;
}
public void setJmxRole(String role) {
this.jmxRole = role;
}
public void setJmxPassword(String password) {
this.jmxPassword = password;
}
/**
* Shutdown this facade aka close any open connection.
*/
@ -110,6 +121,10 @@ public class RemoteJMXBrokerFacade extends BrokerFacadeSupport {
protected JMXConnector createConnection() {
String[] urls = this.jmxUrl.split(",");
HashMap env = new HashMap();
env.put("jmx.remote.credentials",
new String[] {this.jmxRole, this.jmxPassword});
if (urls == null || urls.length == 0) {
urls = new String[]{this.jmxUrl};
}
@ -118,7 +133,7 @@ public class RemoteJMXBrokerFacade extends BrokerFacadeSupport {
for (int i = 0; i < urls.length; i++) {
try {
JMXConnector connector = JMXConnectorFactory
.connect(new JMXServiceURL(urls[i]));
.connect(new JMXServiceURL(urls[i]), env);
connector.connect();
MBeanServerConnection connection = connector
.getMBeanServerConnection();

View File

@ -29,6 +29,8 @@
<bean id="brokerQuery" class="org.apache.activemq.web.RemoteJMXBrokerFacade" autowire="constructor" destroy-method="shutdown">
<property name="jmxUrl" value="${webconsole.jmx.url}"/>
<property name="jmxRole" value="${webconsole.jmx.role}"/>
<property name="jmxPassword" value="${webconsole.jmx.password}"/>
<property name="brokerName"><null/></property>
</bean>