This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes RMI marshaling and unmarshaling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI marshaling and unmarshaling" Watch "RMI marshaling and unmarshaling" New topic
Author

RMI marshaling and unmarshaling

abhijit chavan
Greenhorn

Joined: Apr 15, 2005
Posts: 6
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

Joined: Oct 18, 2000
Posts: 4121

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.


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

Joined: Apr 15, 2005
Posts: 6
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

Joined: Oct 18, 2000
Posts: 4121

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI marshaling and unmarshaling
 
Similar Threads
singleton java object in weblogic cluster
Question regarding Design
What is distributed Computing from an Application's Point of View
Logging from the Data singleton
RMI behind NAT