Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI marshaling and unmarshaling

 
abhijit chavan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

currently i am working on a project in which i need some help.

I want to ask can i have multiple RMI servers and a single client on my server machine. Will single client communicate with multiple servers or do i need to do this with sockets.

What i know is when we start a rmi server a specified objects are registered with rmiregistry using Naming.rebind(). so that remotely placed machine can invoke a method on that object.

Which data does RMI marshal and unmarshal is a whole object or just the methods return parameter.

thanks and regards
abhijit
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.) You can have multiple servers and a single client on one machine - just bind the different servers under different names in the registry, and have the client connect to each of the servers using different names for each. You may want to use the Naming.list("rmi://localhost") method to get back a String array of all names bound in the registry to help the client find servers.

2.) When you first connect to the remote "server" object you get back a stub - this is basically a "remote reference" to the object. What you get back as a return value from a method depends on what type the return value is. If a return value is Serializable you get back a copy of that object on the client. If a return value is Remote you get back a stub to the remote object on the server - which behaves just like the stub to your original "server" object.
 
abhijit chavan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i write rmi client in servlet or jsp page. Where do i place my policy file then and what policy entry do i have to add in.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can make RMI calls from a servlet or JSP page (though you may want to do something so you don't have to constantly call Naming.lookup() and get a reference - that can take a while. It's easy to stick the stub reference into the application or session contexts using listeners.)

There are some pointers on setting security managers and policy files in this question to JGuru, but a lot is dependent on the app server you are using.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic