3

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

jtahlborn
  • 52,909
  • 5
  • 76
  • 118
Sebastian
  • 315
  • 2
  • 12
  • Change the RMIIO code and contribute it back to the project. They need it. – user207421 Jun 14 '18 at 23:46
  • @EJP: That's a non-answer to my questions. I did explicitly exclude that possibility. (It's unfortunate that this is so, for reasons having to do with processes at our shop that I cannot go into here.) I'd still be glad if somebody answered the question. – Sebastian Jun 15 '18 at 05:53
  • Correct. It was a comment, not an answer. I don't have an answer other than what's in my comment. 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?' Yes it's correct. – user207421 Jun 15 '18 at 07:07

1 Answers1

1

I found a feature of the RMIIO library that indeed solves my problem: you can supply your own class to do the exporting of remote objects. That class can be specified through a system property. Thus, the underlying Java remote stream implementation is decoupled from the RPC framework over which it is called. Good design!

Sebastian
  • 315
  • 2
  • 12