• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RMI

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
reply
    Bookmark Topic Watch Topic
  • New Topic