I work in a framework where remote objects export themselves like this: UnicastRemoteObject.exportObject(this, port, csf, ssf);
That's just a given, can't change it. I am now trying to include the RMIIO lib to do remote iteration. RMIIO exports remote objects with UnicastRemoteObject.exportObject(Remote, int)
, which according to the Javadoc uses RMISocketFactory
. By default, RMIIO sets the port to 0 (any port).
Now I absolutely need RMIIO to reuse the existing RMI port that is used by all other objects (it's the only one that's open in the firewall), and also respect my settings for the socket factories, because of SSL and compression etc. What's the best way to do that, apart from changing the 3rd-party code? I'm using Java 8.
I had hoped there were system properties that would allow me to control the socket factories from the outside, but there do not seem to be.
So now I think that I need to call RMISocketFactory.setSocketFactory(RMISocketFactory)
programmatically. Is that correct? It sounds a bit hairy to me. And is it correct that when I do that, I don't need to worry about specifying a port for the lib, because RMI would automatically try and reuse it when my socket factories implement equals()
and hashCode()
appropriately?
Sebastian