Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Basic Question on Parameter Passing  RSS feed

 
Suresh Bansal
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If i pass a parameter to ejb, and then change it in the ejb, will the object be changed in the calling program also ?
Generally it is changed in the calling program, but ejb call is a remote call, so i am not sure.
Suresh
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the ejb call is remote and it is not optimized away by the application server then it will be call by value. Therefore, the parameters will be copied and passed to the ejb. Any changes to the parameters in the ejb will not be reflected in the client.
If the ejb call is local or a remote call that is optimized away by the application server then it will be call by reference. Therefore, a reference to the parameters will be passed to the ejb. Any changes to the parameters may be reflected in the client depending on whether the parameters are mutable or not.
 
Suresh Bansal
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Chris, that was most helpfull ...
 
vikasids sharma
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris
1. I could not understand the meaning of "optimized away by application Server"
2. If it is something that depends on App.Server, can we control this optimization provided by App Server because the two points supported by you might affect the business logic.
Originally posted by Chris Mathews:
If the ejb call is remote and it is not optimized away by the application server then it will be call by value..
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I vaguely remember in Weblogic 5.1(EJB1.1) that there was some vendor-specific configuration that allowed remote calls to be optimized, if both the calling ejb and the callee ejb were running in the same container. I assumed that the objects were passed by reference in this case.
[ March 04, 2004: Message edited by: Vish Kumar ]
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vikasids sharma:
1. I could not understand the meaning of "optimized away by application Server"
2. If it is something that depends on App.Server, can we control this optimization provided by App Server because the two points supported by you might affect the business logic.

I've only used WebLogic, but I suspect many other appservers have similar capabilities. With WL, when you use the remote interfaces to access beans in the same JVM, you can configure WL to use the bean as if it were local under the covers. This means that parameters are passed by reference instead of by value.
Yes, this does mean it can affect your business logic. If you count on being able to modify the parameters without affecting the client, you must either copy the parameters or disable this optimization.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!