Lines 21-27
Link Here
|
21 |
import java.io.Serializable; |
21 |
import java.io.Serializable; |
22 |
import java.lang.management.ManagementFactory; |
22 |
import java.lang.management.ManagementFactory; |
23 |
import java.net.MalformedURLException; |
23 |
import java.net.MalformedURLException; |
|
|
24 |
import java.net.UnknownHostException; |
24 |
import java.net.Socket; |
25 |
import java.net.Socket; |
|
|
26 |
import java.net.ServerSocket; |
27 |
import java.net.InetAddress; |
25 |
import java.rmi.RemoteException; |
28 |
import java.rmi.RemoteException; |
26 |
import java.rmi.registry.LocateRegistry; |
29 |
import java.rmi.registry.LocateRegistry; |
27 |
import java.rmi.server.RMIClientSocketFactory; |
30 |
import java.rmi.server.RMIClientSocketFactory; |
Lines 61-66
Link Here
|
61 |
protected static final StringManager sm = |
64 |
protected static final StringManager sm = |
62 |
StringManager.getManager(Constants.Package); |
65 |
StringManager.getManager(Constants.Package); |
63 |
|
66 |
|
|
|
67 |
protected String rmiBindAddress = null; |
64 |
protected int rmiRegistryPortPlatform = -1; |
68 |
protected int rmiRegistryPortPlatform = -1; |
65 |
protected int rmiServerPortPlatform = -1; |
69 |
protected int rmiServerPortPlatform = -1; |
66 |
protected boolean rmiSSL = true; |
70 |
protected boolean rmiSSL = true; |
Lines 76-81
Link Here
|
76 |
protected JMXConnectorServer csPlatform = null; |
80 |
protected JMXConnectorServer csPlatform = null; |
77 |
|
81 |
|
78 |
/** |
82 |
/** |
|
|
83 |
* Get the inet address on which the Platform RMI server is exported. |
84 |
* @return The textual representation of inet address |
85 |
*/ |
86 |
public String getRmiBindAddress() { |
87 |
return rmiBindAddress; |
88 |
} |
89 |
|
90 |
/** |
91 |
* Set the inet address on which the Platform RMI server is exported. |
92 |
* @param theRmiBindAddress The textual representation of inet address |
93 |
*/ |
94 |
public void setRmiBindAddress(String theRmiBindAddress) { |
95 |
rmiBindAddress = theRmiBindAddress; |
96 |
} |
97 |
|
98 |
/** |
79 |
* Get the port on which the Platform RMI server is exported. This is the |
99 |
* Get the port on which the Platform RMI server is exported. This is the |
80 |
* port that is normally chosen by the RMI stack. |
100 |
* port that is normally chosen by the RMI stack. |
81 |
* @return The port number |
101 |
* @return The port number |
Lines 192-198
Link Here
|
192 |
csf = new SslRMIClientSocketFactory(); |
212 |
csf = new SslRMIClientSocketFactory(); |
193 |
ssf = new SslRMIServerSocketFactory(ciphers, protocols, |
213 |
ssf = new SslRMIServerSocketFactory(ciphers, protocols, |
194 |
clientAuth); |
214 |
clientAuth); |
|
|
215 |
|
216 |
if (rmiBindAddress != null) { |
217 |
log.warn("Ignoring rmiBindAddress as incompatible with rmiSSL"); |
195 |
} |
218 |
} |
|
|
219 |
} else if (rmiBindAddress != null) { |
220 |
// Force server bind address if required |
221 |
try { |
222 |
ssf = new RmiServerBindSocketFactory(InetAddress.getByName(rmiBindAddress)); |
223 |
} catch (UnknownHostException e) { |
224 |
log.error("Invalid bind address: " + rmiBindAddress, e); |
225 |
} |
226 |
} |
196 |
|
227 |
|
197 |
// Force the use of local ports if required |
228 |
// Force the use of local ports if required |
198 |
if (useLocalPorts) { |
229 |
if (useLocalPorts) { |
Lines 219-225
Link Here
|
219 |
|
250 |
|
220 |
// Create the Platform server |
251 |
// Create the Platform server |
221 |
csPlatform = createServer("Platform", rmiRegistryPortPlatform, |
252 |
csPlatform = createServer("Platform", rmiRegistryPortPlatform, |
222 |
rmiServerPortPlatform, env, |
253 |
rmiServerPortPlatform, env, csf, ssf, |
223 |
ManagementFactory.getPlatformMBeanServer()); |
254 |
ManagementFactory.getPlatformMBeanServer()); |
224 |
|
255 |
|
225 |
} else if (Lifecycle.STOP_EVENT == event.getType()) { |
256 |
} else if (Lifecycle.STOP_EVENT == event.getType()) { |
Lines 229-239
Link Here
|
229 |
|
260 |
|
230 |
private JMXConnectorServer createServer(String serverName, |
261 |
private JMXConnectorServer createServer(String serverName, |
231 |
int theRmiRegistryPort, int theRmiServerPort, |
262 |
int theRmiRegistryPort, int theRmiServerPort, |
232 |
HashMap<String,Object> theEnv, MBeanServer theMBeanServer) { |
263 |
HashMap<String,Object> theEnv, RMIClientSocketFactory csf, RMIServerSocketFactory ssf, MBeanServer theMBeanServer) { |
233 |
|
264 |
|
234 |
// Create the RMI registry |
265 |
// Create the RMI registry |
235 |
try { |
266 |
try { |
236 |
LocateRegistry.createRegistry(theRmiRegistryPort); |
267 |
LocateRegistry.createRegistry(theRmiRegistryPort, csf, ssf); |
237 |
} catch (RemoteException e) { |
268 |
} catch (RemoteException e) { |
238 |
log.error(sm.getString( |
269 |
log.error(sm.getString( |
239 |
"jmxRemoteLifecycleListener.createRegistryFailed", |
270 |
"jmxRemoteLifecycleListener.createRegistryFailed", |
Lines 311-314
Link Here
|
311 |
|
342 |
|
312 |
|
343 |
|
313 |
} |
344 |
} |
|
|
345 |
|
346 |
public static class RmiServerBindSocketFactory |
347 |
implements RMIServerSocketFactory { |
348 |
private final InetAddress bindAddress; |
349 |
|
350 |
public RmiServerBindSocketFactory(InetAddress address) { |
351 |
bindAddress = address; |
314 |
} |
352 |
} |
|
|
353 |
|
354 |
public ServerSocket createServerSocket(int port) throws IOException { |
355 |
return new ServerSocket(port, 0, bindAddress); |
356 |
} |
357 |
|
358 |
} |
359 |
} |