Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI

 
Ray Ye
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a class implements both Remote and Serializable interface, when used as an argument in RMI call, how will be the object of this class passed? Is it passed by reference (stub) or by value (serialized)?

Thanks,

Ray
 
Dushy Inguva
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ray,

If a parameter/return type of a RMI call is a Remote object, it will be passed by reference(The Stub will be passed).

Dushy
 
Ray Ye
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dushy,

Thanks for you reply.

However, I am not sure if you see in RMI specification,
2.6.2 Passing Remote Objects
When passing an exported remote object as a parameter or return value in a remote method call, the stub for that remote object is passed instead. Remote objects that are not exported will not be replaced with a stub instance. A remote object passed as a parameter can only implement remote interfaces.

It mentioned that "A remote object passed as a parameter can only implement remote interfaces". And in this case, it violates the rule, so how does it behave in run-time? Is it defined somewhere or is implementation dependent?

Thanks again,

Ray
 
Dushy Inguva
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ray,

When passing an exported remote object as a parameter or return value in a remote method call, the stub for that remote object is passed instead. Remote objects that are not exported will not be replaced with a stub instance. A remote object passed as a parameter can only implement remote interfaces

What i make out of this is.
1. A class implements Remote interface, extends RemoteObject or calls the export method on itself:Reference is passed (I have tested this)
2. A class implements Remote interface and does nothing else: Value is passed (I have not tested this)

Anyone else on this one?
Dushy
 
Ray Ye
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dushy,

I tried an exported object that implements both Remote and Serializable interfaces and passed as a paramter in the RMI call, it is passed by reference (stub).

Cheers,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic