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 194-199
Link Here
|
194 |
clientAuth); |
214 |
clientAuth); |
195 |
} |
215 |
} |
196 |
|
216 |
|
|
|
217 |
// Force server bind address if required |
218 |
if (rmiBindAddress != null) { |
219 |
try { |
220 |
ssf = new RmiServerBindSocketFactory(InetAddress.getByName(rmiBindAddress)); |
221 |
} catch (UnknownHostException e) { |
222 |
log.error("Invalid bind address: " + rmiBindAddress, e); |
223 |
} |
224 |
} |
225 |
|
197 |
// Force the use of local ports if required |
226 |
// Force the use of local ports if required |
198 |
if (useLocalPorts) { |
227 |
if (useLocalPorts) { |
199 |
csf = new RmiClientLocalhostSocketFactory(csf); |
228 |
csf = new RmiClientLocalhostSocketFactory(csf); |
Lines 219-225
Link Here
|
219 |
|
248 |
|
220 |
// Create the Platform server |
249 |
// Create the Platform server |
221 |
csPlatform = createServer("Platform", rmiRegistryPortPlatform, |
250 |
csPlatform = createServer("Platform", rmiRegistryPortPlatform, |
222 |
rmiServerPortPlatform, env, |
251 |
rmiServerPortPlatform, env, csf, ssf, |
223 |
ManagementFactory.getPlatformMBeanServer()); |
252 |
ManagementFactory.getPlatformMBeanServer()); |
224 |
|
253 |
|
225 |
} else if (Lifecycle.STOP_EVENT == event.getType()) { |
254 |
} else if (Lifecycle.STOP_EVENT == event.getType()) { |
Lines 229-239
Link Here
|
229 |
|
258 |
|
230 |
private JMXConnectorServer createServer(String serverName, |
259 |
private JMXConnectorServer createServer(String serverName, |
231 |
int theRmiRegistryPort, int theRmiServerPort, |
260 |
int theRmiRegistryPort, int theRmiServerPort, |
232 |
HashMap<String,Object> theEnv, MBeanServer theMBeanServer) { |
261 |
HashMap<String,Object> theEnv, RMIClientSocketFactory csf, RMIServerSocketFactory ssf, MBeanServer theMBeanServer) { |
233 |
|
262 |
|
234 |
// Create the RMI registry |
263 |
// Create the RMI registry |
235 |
try { |
264 |
try { |
236 |
LocateRegistry.createRegistry(theRmiRegistryPort); |
265 |
LocateRegistry.createRegistry(theRmiRegistryPort, csf, ssf); |
237 |
} catch (RemoteException e) { |
266 |
} catch (RemoteException e) { |
238 |
log.error(sm.getString( |
267 |
log.error(sm.getString( |
239 |
"jmxRemoteLifecycleListener.createRegistryFailed", |
268 |
"jmxRemoteLifecycleListener.createRegistryFailed", |
Lines 311-314
Link Here
|
311 |
|
340 |
|
312 |
|
341 |
|
313 |
} |
342 |
} |
|
|
343 |
|
344 |
public static class RmiServerBindSocketFactory |
345 |
implements RMIServerSocketFactory { |
346 |
private final InetAddress bindAddress; |
347 |
|
348 |
public RmiServerBindSocketFactory(InetAddress address) { |
349 |
bindAddress = address; |
314 |
} |
350 |
} |
|
|
351 |
|
352 |
public ServerSocket createServerSocket(int port) throws IOException { |
353 |
return new ServerSocket(port, 0, bindAddress); |
354 |
} |
355 |
|
356 |
} |
357 |
} |