• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Local Vs Remote

 
Nikhil Jain
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. In case of remote interface, objects are passed by value or a copy is made
2. In case of local interface, objects are passeed by reference.

What if we use remote interface on the same VM. Would the object still passed by value.

Secondly in Zaikin notes I read the following lines

Non-remote objects must be passed by value.
The EJB container is not allowed to pass non-remote objects by reference on inter-EJB invocations when the calling and called enterprise beans are collocated in the same JVM.

Should'nt the opposite be true in this case. Non-remote objects or local objects must be passed on reference??
 
bernard savary
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I think a ejb called with a remote interface will always follow the remote semantics (with marshalling , unmarshallling etc..) I am saying this because I was just testing propagation of Container manager PersistenceContext with extended scope ,basically to test Persistence context inheritance. I was calling a stateful session bean from another, I passed the reference of a new entity(detached) from Bean A to Bean B ,and in Bean B method, I do a persist of the new entity.
and I noticed that after the Bean B method call returns ,the state of entity in Bean A i.e whether it is managed or detached was dependent on the type of interface I used to call Bean B from bean A. When I use Local then the entity remains managed in BeanA but if I use remote it is detached .This is because using a remote will serialize the entity and results in entity being detached .
 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anu Tilwalli:

What if we use remote interface on the same VM. Would the object still passed by value.


I am not 100% percent sure of this. But I would give my opinion. I feel when the @Remote is demarcated on a class, on compilation, it would but obviously create proxies and stubs. So any call made by using these stubs would naturally result in remote calls.

If the class is marked as @Local then it won't create the stubs for remote invocation.
[ May 14, 2008: Message edited by: nitin pai ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic