• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Mock question from Headfirst EJB

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ana, it is very clear now. Thanks!
 
reply
    Bookmark Topic Watch Topic
  • New Topic