patch supplied by John Heitmann to allow the rmi port to be configured to fix AMQ-892

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@436833 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-08-25 15:31:22 +00:00
parent b54ce41de2
commit 1ad52f4209
1 changed files with 27 additions and 8 deletions

View File

@ -58,6 +58,7 @@ public class ManagementContext implements Service{
private boolean createConnector=true;
private boolean findTigerMbeanServer=false;
private int connectorPort=1099;
private int rmiServerPort;
private String connectorPath="/jmxrmi";
private AtomicBoolean started=new AtomicBoolean(false);
private JMXConnectorServer connectorServer;
@ -292,14 +293,19 @@ public class ManagementContext implements Service{
}
}
}
if(result==null&&createMBeanServer){
result=createMBeanServer();
if (result == null && createMBeanServer) {
result = createMBeanServer();
}
}catch(NoClassDefFoundError e){
log.error("Couldnot load MBeanServer",e);
}catch(Throwable e){
else {
createConnector(result);
}
}
catch (NoClassDefFoundError e) {
log.error("Could not load MBeanServer", e);
}
catch (Throwable e) {
// probably don't have access to system properties
log.error("Failed to initialize MBeanServer",e);
log.error("Failed to initialize MBeanServer", e);
}
return result;
}
@ -386,10 +392,15 @@ public class ManagementContext implements Service{
log.debug("Failed to create local registry",e);
}
// Create the JMXConnectorServer
String serviceURL="service:jmx:rmi:///jndi/rmi://localhost:"+connectorPort+connectorPath;
String rmiServer = "";
if (rmiServerPort != 0) {
// This is handy to use if you have a firewall and need to
// force JMX to use fixed ports.
rmiServer = "localhost:" + rmiServerPort;
}
String serviceURL = "service:jmx:rmi://"+rmiServer+"/jndi/rmi://localhost:"+connectorPort+connectorPath;
JMXServiceURL url=new JMXServiceURL(serviceURL);
connectorServer=JMXConnectorServerFactory.newJMXConnectorServer(url,null,mbeanServer);
// log.info("JMX consoles can connect to serviceURL: " + serviceURL);
}
public String getConnectorPath(){
@ -408,6 +419,14 @@ public class ManagementContext implements Service{
this.connectorPort=connectorPort;
}
public int getRmiServerPort(){
return rmiServerPort;
}
public void setRmiServerPort(int rmiServerPort){
this.rmiServerPort=rmiServerPort;
}
public boolean isCreateConnector(){
return createConnector;
}