Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question about the client view

 
Elinor Chang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am studing for the test. There is a question from HeadFirst EJB that I don't quite understand,

Give a remote client "R", that has valid references to sessin beans 'A' and 'B', and given that A is a local client to B, which statment is true? (Choose all that apply)

A. R cannot pass his reference for A, to B
B. A cannot pass his reference for B, to R
C. A cannot invoke methods on B
D. B cannot invoke methods on R

I am little confused on what does that mean by A is a local client to B? Can a session bean refer to another session bean?

The answer is said to be B and D. Why.

Thanks
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Elinor,

I think you posted this in the wrong forum - you probably meant to put this in the EJB Certification (SCBCD) forum. I have therefore moved it there.

I am little confused on what does that mean by A is a local client to B? Can a session bean refer to another session bean?


Yes, a session bean can have a reference to another session bean or to an entity bean. More importantly, it is possible to have local references (using the local interfaces) to the other objects. No RMI involved, no networking involved, no duplication of objects. Therefore much faster. But harder to move beans between containers later.

As for the question:
Give a remote client "R", that has valid references to sessin beans 'A' and 'B', and given that A is a local client to B


Perhaps you should draw yourself a diagram for this:



or



(Hmmm, on second thoughts, I am not sure if those diagrams actually confuse the issue )


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


Incorrect.

R has a remote reference to A, and could pass that remote reference to B if it wanted to (and B had a way of receiving it). You might want to do this if your beans are on different containers, and you wanted B to be able to use methods in your instance of A.


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


This is correct. A has a local reference to B, which cannot be sent via RMI or IIOP. Even if you somehow sent it, R would not be able to use a local object remotely.


C. A cannot invoke methods on B


Incorrect.

A is a client of B (has a local reference to B), so it can invoke methods on B.


D. B cannot invoke methods on R


Correct - R has a reference to B, and can invoke methods on B. But B does not have a reference to R.

Regards, Andrew
 
Elinor Chang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it. Guess I was stumped in the understanding of the question. Guess it's about who could call/refer whom. We can never mix local/remove at the same time.

Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic