Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock question from Headfirst EJB

 
Elinor Chang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't quite understand the following mock exam question from the book:

Given a remote client R, that has valid reference to session beans A and B, and given that A is a local client to B, which statements are true? (Choose all that apply)

1. R cannot pass his reference for A, to B
2. A cannot pass his reference for B, to R
3. A cannot invoke methods on B
4. B cannot invoke methods on R

the answer is 2, 4

What does the question is all about? Why the answers?

Thanks
 
Ana Nava
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the question is all about?


This question tests the following EJB2.0 Spec.

A client can pass a remote home object reference to another application. The receiving application can use the home interface in the same way that it would use a remote home object reference obtained via JNDI.

A client can pass a local home object reference to another application through its local interface. A local home object reference cannot be passed as an argument or result of a method on an enterprise bean�s remote home or remote interface.

The above Specs clearly explain the answers as well.
 
Miki Muzsi
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also very confused in this question.

First of all, if A is local to B, how can R (a remote) have a reference to A (a local)? Is that possible? And what about that Local and Remote should never ever be mixed?

Second, why can A call methods on B? They both use the local interfaces?

Miki
 
Ana Nava
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok lets analyze the question piece by piece...

Given a remote client R, that has valid reference to session beans A and B


As R (a remote client) has "valid" reference this means that it has a remote reference to A and remote reference to B.

1. R cannot pass his reference for A, to B


This is not a right choice because R can pass his remote reference of A to B as per the Spec "A client can pass a remote home object reference to another application".

and given that A is a local client to B


Although R has a remote reference to B, A has a local reference to B. (yes it is possible, but should be done with attention due to the reasons stated in page, 164 of HFEJB).

So choice 2 would be right because we cannot pass a local reference (A) to a remote reference (B to R).

Choice 3 is not right because, A can invoke methods on B.

Hope this helps...
 
Miki Muzsi
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ana, it is very clear now. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic