• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question Reg parameter Passing - HFEJB Pg No 170

 
Natarajan Shankar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Givn Remote client 'R' that has valid reference to session bean 'A' and 'B', and given that 'A' is local client to 'B', which statement are true. (Choose all that apply)

A. R Cannot passs his reference for A, to B.

B. A Cannot pass his reference for B, to R.

C. A Cannot invoke method of B.

D. B cannot invoke method on R.

{Correct answer give was B and D.}

Can you pls. explain why A is not valid and B is valid.
My assumption is R is in one heap and Sesson bean A,B are in another heap. So R will not pass reference it can pass only reference copy.
 
Amitava Basu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You are correct, R is in a different heap than A & B. R's reference to A is nothing but a Stub.
Hence in side code, when R passes a reference of A to anybody it is actually passing the copy of the stub. And that is OK.
If R passes a copy of A's stub to B, then B can call methods or do other stuff on A as an remote object (though they are in the same heap).
Option (A) says that R Can not pass a reference of A to B (if fact it can) hence A is not correct.

Option (B) says that A can not pass it’s reference for B to R, yes it can not. Because A & B are LOCAL and they are not dealing with stubs they are dealing with actual references. Those references do not have any value to R being in a separate heap. Hence B is correct.

Let me know if you have any different opinion.
 
Natarajan Shankar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amitava Basu,
Thanks for your clarificatio.

when R passes a reference of A to anybody it is actually passing the copy of the stub.
And that is OK.


The above clarification you have given was the point I was missing in my understanding, when R passes a reference of A I was assuming the actual object reference. Thanks for you clarification. BTW, this solution will satisfy if we're assuiming this one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic