• Post Reply Bookmark Topic Watch Topic
  • New Topic

RMI chat server  RSS feed

 
shreya
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi I'm new to RMI

i wanted to know that whether client need to bind its object to its registry so that server could invoke its methods for eg..

when server want to notify client it has message for him..
server would have to invoke its method..

actually i read somewhere about this application and found that client had not bind its objects in registry for server to get its reference..but server has still used its object to call methods of client..

also applet has URL for naming.lookup which involved getCodebase().getHost()...why is it so??
when we are looking for reference in some other machine not locally..
 
Ajay Saxena
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i wanted to know that whether client need to bind its object to its registry so that server could invoke its methods for eg..


Not really!

Please understand that the registry enables clients to access remote server objects in a location transparent manner. The clients are actually agnostic of the remote server's location.The registry just enables this by being a broker between the client and the server.

So typically the root remote server object is bound to the registry.References to other remote objects could be usually obtainable from this root reference

So,in your case,you need to expose the methods of the client that could be called back by the server in a remote interface,and pass the client reference(this) to the server through a remote method on the server. What would actually get passed to the server is the remote stub of the client.

The server can then directly invoke the callback methods on the client reference.

You can even avoid making the Client extend UnicastRemoteObject,if you just want the client remote methods to be callable from the server. In the latter case,you only need to add the following line to your client class constructor

UnicastRemoteObject.export(this)

[ August 15, 2008: Message edited by: Ajay Saxena ]
[ August 22, 2008: Message edited by: Ajay Saxena ]
 
shreya
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Mr.Ajay for clearing my doubt.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shreya,

On your way in, you might not have noticed our naming policy.

Kindly change your display name according to the policy.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!