activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r436833 - /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
Date Fri, 25 Aug 2006 15:31:23 GMT
Author: jstrachan
Date: Fri Aug 25 08:31:22 2006
New Revision: 436833

URL: http://svn.apache.org/viewvc?rev=436833&view=rev
Log:
patch supplied by John Heitmann to allow the rmi port to be configured to fix AMQ-892

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java?rev=436833&r1=436832&r2=436833&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
Fri Aug 25 08:31:22 2006
@@ -58,6 +58,7 @@
     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 @@
                     }
                 }
             }
-            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 @@
             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(){
@@ -406,6 +417,14 @@
 
     public void setConnectorPort(int connectorPort){
         this.connectorPort=connectorPort;
+    }
+
+    public int getRmiServerPort(){
+        return rmiServerPort;
+    }
+
+    public void setRmiServerPort(int rmiServerPort){
+        this.rmiServerPort=rmiServerPort;
     }
 
     public boolean isCreateConnector(){



Mime
View raw message