ASF Bugzilla – Attachment 30319 Details for
Bug 55017
Ability to configure RMI bind address
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to provider bind rmi bind address setup ability
localjmxbind.patch (text/plain), 3.85 KB, created by
Alexey Noskov
on 2013-05-24 14:50:10 UTC
(
hide
)
Description:
Patch to provider bind rmi bind address setup ability
Filename:
MIME Type:
Creator:
Alexey Noskov
Created:
2013-05-24 14:50:10 UTC
Size:
3.85 KB
patch
obsolete
>Index: java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java >=================================================================== >--- java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java (revision 1486077) >+++ java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java (working copy) >@@ -21,7 +21,10 @@ > import java.io.Serializable; > import java.lang.management.ManagementFactory; > import java.net.MalformedURLException; >+import java.net.UnknownHostException; > import java.net.Socket; >+import java.net.ServerSocket; >+import java.net.InetAddress; > import java.rmi.RemoteException; > import java.rmi.registry.LocateRegistry; > import java.rmi.server.RMIClientSocketFactory; >@@ -61,6 +64,7 @@ > protected static final StringManager sm = > StringManager.getManager(Constants.Package); > >+ protected String rmiBindAddress = null; > protected int rmiRegistryPortPlatform = -1; > protected int rmiServerPortPlatform = -1; > protected boolean rmiSSL = true; >@@ -76,6 +80,22 @@ > protected JMXConnectorServer csPlatform = null; > > /** >+ * Get the inet address on which the Platform RMI server is exported. >+ * @return The textual representation of inet address >+ */ >+ public String getRmiBindAddress() { >+ return rmiBindAddress; >+ } >+ >+ /** >+ * Set the inet address on which the Platform RMI server is exported. >+ * @param theRmiBindAddress The textual representation of inet address >+ */ >+ public void setRmiBindAddress(String theRmiBindAddress) { >+ rmiBindAddress = theRmiBindAddress; >+ } >+ >+ /** > * Get the port on which the Platform RMI server is exported. This is the > * port that is normally chosen by the RMI stack. > * @return The port number >@@ -194,6 +214,15 @@ > clientAuth); > } > >+ // Force server bind address if required >+ if (rmiBindAddress != null) { >+ try { >+ ssf = new RmiServerBindSocketFactory(InetAddress.getByName(rmiBindAddress)); >+ } catch (UnknownHostException e) { >+ log.error("Invalid bind address: " + rmiBindAddress, e); >+ } >+ } >+ > // Force the use of local ports if required > if (useLocalPorts) { > csf = new RmiClientLocalhostSocketFactory(csf); >@@ -219,7 +248,7 @@ > > // Create the Platform server > csPlatform = createServer("Platform", rmiRegistryPortPlatform, >- rmiServerPortPlatform, env, >+ rmiServerPortPlatform, env, csf, ssf, > ManagementFactory.getPlatformMBeanServer()); > > } else if (Lifecycle.STOP_EVENT == event.getType()) { >@@ -229,11 +258,11 @@ > > private JMXConnectorServer createServer(String serverName, > int theRmiRegistryPort, int theRmiServerPort, >- HashMap<String,Object> theEnv, MBeanServer theMBeanServer) { >+ HashMap<String,Object> theEnv, RMIClientSocketFactory csf, RMIServerSocketFactory ssf, MBeanServer theMBeanServer) { > > // Create the RMI registry > try { >- LocateRegistry.createRegistry(theRmiRegistryPort); >+ LocateRegistry.createRegistry(theRmiRegistryPort, csf, ssf); > } catch (RemoteException e) { > log.error(sm.getString( > "jmxRemoteLifecycleListener.createRegistryFailed", >@@ -311,4 +340,18 @@ > > > } >+ >+ public static class RmiServerBindSocketFactory >+ implements RMIServerSocketFactory { >+ private final InetAddress bindAddress; >+ >+ public RmiServerBindSocketFactory(InetAddress address) { >+ bindAddress = address; > } >+ >+ public ServerSocket createServerSocket(int port) throws IOException { >+ return new ServerSocket(port, 0, bindAddress); >+ } >+ >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 55017
:
30319
|
30320
|
30321
|
30398