Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Arguments and Return Types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Arguments and Return Types" Watch "Arguments and Return Types" New topic

Arguments and Return Types

Sandeep Prabhakar
Ranch Hand

Joined: Dec 22, 2005
Posts: 59
Hey Ranchers,

Consider this situation.

Say suppose I deploy a bean with Remote Home and Component Interface.

Suppose I have a client running in the same JVM which have a reference to this bean (a reference to the Bean's Remote Interface). Now are the parameters and return values passed by "Copy of Reference" or "Copy of Value"

p anish
Ranch Hand

Joined: Feb 26, 2005
Posts: 32
Ideally it should be copy of value.
But some server's do an optimization like if the call is from one remote bean to another remote bean and both beans are in the same JVM, hte container will automatically convert the remote call to a local call ( and passes argument as copy of reference). may some experts here can throw more lights on it.
Ugender Rekulampally
Ranch Hand

Joined: Nov 14, 2005
Posts: 135
The return type, if you are returning a Remote Interface from a method call, that would be a Pass by Value and that would be a stub and Container will take care of serializing it.

Sandeep Prabhakar
Ranch Hand

Joined: Dec 22, 2005
Posts: 59
Hey Folks,

The return value need not be a Remote Interface. It would be anything that is RMI-IIOP Compatible.
Anish, If the Container optimizes and passes a "Copy of Reference" than I feel that it would hurt the portability of Beans.
The bean developer may be tempted to depend on the side effects caused by passing the reference.
Please let me know if I am missing something here.

Patrick Williams
Ranch Hand

Joined: Apr 03, 2005
Posts: 213
Based on what I've read in HF EJB, Local Home and Component pass by reference and have to be in the same JVM. Remote Home and Component pass by value even if they are on the same machine as the bean object. Hope this helps.

Patrick<br /> <br />SCJP/SCWCD/SCBCD/SCDJWS/SCEA<br /> <br />Currently working on:<br />SCJP 6
I agree. Here's the link:
subject: Arguments and Return Types
It's not a secret anymore!