• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to pass an object using RMI over the network from the server to the client  RSS feed

 
Mohd Nayeemuddin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir,
I want to know how to pass an object using RMI over the network from server to the client by stating an example with sample code.



Regards....
Nayeem.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mohd Nayeemuddin:
I want to know how to pass an object using RMI over the network from server to the client by stating an example with sample code.


Hi Mohd,

This question is no way related to JDBC.You could have posted it in Distributed Java form to get better response.

You can find numerous examples in the internet for this.You can have a remote method returning a object.

This explains about RMI with example code.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reading the RMI tutorial is indeed the best first step.

Note, however, that there is a flaw in the question that you ask. In neither ordinary Java nor RMI do you "pass an object". You pass references to objects. In RMI, this is complicated by the fact that the object references you use on the client side are in fact references to proxies for objects that exist on the server side.

Well, actually, I am very rusty on RMI, but I don't think it has any special way to pass objects by value, because its whole idea is to allow you to write code that looks like ordinary Java, but where some of the objects are actually implemented remotely.

I do use CORBA, which has such facilities, though I don't use them; Google "corba value type" for information.
[ July 12, 2007: Message edited by: Peter Chase ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In RMI "Remote" objects are passed by reference; "Serializable" objects are passed by value.

As far as passing them from the server to the client - this could either be done as making the object the return value of a method that the client calls on the server (easy way), or it could be done as a "client side callback" where the client "registers" with the server, and the server calls a method on the client passing the object as a parameter (more involved way).
[ July 12, 2007: Message edited by: Nathan Pruett ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!