aspose file tools*
The moose likes Distributed Java and the fly likes rmi both ways Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "rmi both ways" Watch "rmi both ways" New topic
Author

rmi both ways

bertrand moulard
Greenhorn

Joined: Feb 08, 2005
Posts: 6
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...)

Thanks (and sorry if the question is stupid)
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

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.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
bertrand moulard
Greenhorn

Joined: Feb 08, 2005
Posts: 6
Thanks for that, it's been helpful!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rmi both ways