I'm fairly new to RMI and I'm writting test code to see how things work. I wrote a server that registers itself and a client that connects the server and call it's methods. The thing I don't understand is how to get the server to call client methods. Say something happens on the server and it wants to notify all the connected client without having them asking anything? Is there a simple way to do that? (I've got that annoying feeling that I'm missing something really obvious...)
You'll find more information on this topic using the phrase "RMI callback".
Basically you make the client a "server" also (meaning a class somewhere on the client has to implement Remote), and send a reference to it (the stub of the client side Remote) to the server, who saves it in a list of clients. Then, when the server needs to notify the clients, it uses the saved stub to "call-back" some method on the client.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.