[jboss-cvs] JBossAS SVN: r108257 - trunk/system/src/main/java/org/jboss/system/server/jmx.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 21 11:28:51 EDT 2010


Author: smarlow at redhat.com
Date: 2010-09-21 11:28:51 -0400 (Tue, 21 Sep 2010)
New Revision: 108257

Modified:
   trunk/system/src/main/java/org/jboss/system/server/jmx/JMXConnector.java
Log:
JBAS-8407 IPv6 support in JMXConnector

Modified: trunk/system/src/main/java/org/jboss/system/server/jmx/JMXConnector.java
===================================================================
--- trunk/system/src/main/java/org/jboss/system/server/jmx/JMXConnector.java	2010-09-21 15:15:22 UTC (rev 108256)
+++ trunk/system/src/main/java/org/jboss/system/server/jmx/JMXConnector.java	2010-09-21 15:28:51 UTC (rev 108257)
@@ -38,8 +38,7 @@
 import javax.naming.StringRefAddr;
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
+import java.net.MalformedURLException;
 import java.rmi.NotBoundException;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
@@ -140,7 +139,7 @@
             env.put(RMIConnectorServer.AUTHENTICATOR, new JMXConnectorAuthenticator( securityDomain) );
          // note:  don't pass clientSocketFactory to RMIJRMPServerImpl ctor or JBAS-7933 regression will occur. 
          rmiServer = new RMIJRMPServerImpl(rmiServerPort, null, serverSocketFactory, env);
-         JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://" + hostname);
+         JMXServiceURL url = buildJMXServiceURL();
          adapter = new RMIConnectorServer(url, env, rmiServer, wrapMBeanServer(mbeanServer));
          adapter.start();
          url = adapter.getAddress();
@@ -166,6 +165,23 @@
       }
    }
 
+   /**
+    * build URL and handle IPV6 literal address case.
+    * TODO:  share IPV6 logic like this via a shared library.  
+    */
+   private JMXServiceURL buildJMXServiceURL() throws MalformedURLException {
+      String host = hostname;
+      if(host.indexOf(':') != -1) {  // is this a IPV6 literal address? if yes, surround with square brackets
+                                     // as per rfc2732.
+                                     // IPV6 literal addresses have one or more colons
+                                     // IPV4 addresses/hostnames have no colons
+         host = "[" + host + "]";
+         
+      }
+      JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://" + host);
+      return url;
+   }
+
    public void stop()  {
       try {
          registry.unbind(RMI_BIND_NAME);



More information about the jboss-cvs-commits mailing list