This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
choice A:true, my explanation thinking R is also a bean(and also a client)) A can get a remote home reference for R and inturn get an remote component reference for R ,and since R is remote it can not be sent to B from A ,since A and B are Local.....so choice A is true choice B :true choice C:false,since A and B are local,Aa can get a component interface reference from B through B's home interface and so call on B's methods. choice D:false please help on this.....give links....explanation etc...think these topice are very important thanks pradeep
Failure is not when you fall down; its only when you fail to get up again.
Howdy -- let me see if I can explain it... it *IS* a confusing question. The way the question is worded, the scenario is like this:
A has a Remote interface that Client R is using. Client R has a remote reference to bean A. B has a Remote interface that Client R is using. Client R has a remote reference to bean B. Bean B has a local interface that bean A is using. Bean A is a local client of bean B. So, A has a local reference to B. Client R has a remote reference to A and B. BUT... bean B does not have a reference to Client R. So, to start with the simplest one... "D" is true because B cannot invoke methods on R, because "B" does not have a reference to R. In fact, NOBODY has a reference to R. "C" is false because A CAN invoke methods on B, since A is a client to B. "B" is true because A has a local reference to B, and since R is a Remote client, A is not allowed to pass a local reference out through a Remote method return value (or any Remote call argument). "A" is false because R CAN pass his reference for A over to B. The reason for this is that R has a REMOTE reference to A. Remote references can be passed around everywhere, without restriction. R can say, "Here you go B, here's a Remote reference to A." and that's not a problem. This would give B a Remote reference to A's Remote component interface (EJBObject stub) on which B could then call methods on A. It is always fine to send around Remote references to beans (meaning, references to the bean's Remote component interface). The problem is in sending LOCAL references. A local reference to a bean (and when I say "to a bean" I really mean "to the bean's component interface") must NOT be passed out of the JVM, so you can't go passing it out via arguments or return values like that. We never said that R is a bean. All we know is that R is a Remote client to A and B. For all we know, R is a servlet or stand-alone Java application. But it doesn't matter. Even if R really were a bean, it works the same way. Bert wrote this question... But I remember that it confused me the first time I saw it. You really have to think through all of the implications when you see questions like that. There ARE some on the exam like this... cheers, Kathy
Thanks Kathy for the good explanation... I also got this question wrong. I found it to be the toughest question in the entire book. I wonder how many people get this question right in the first instance. :roll: I think a couple of more lines of explanation to the answer in the book, would help people understand this question better..
Joined: Oct 01, 2003
thanks Kathy, I totally forgot to see my posting because it was answered about 12 hrs later....To be frank i did quite a bit of research and found out that a remote reference is shipped to the remote client as a whole new one in the remote JVM and a local client gets only an address to the local object ie an alias name pointing to the same object, and so i could figure out almost similarly as u did...and bursted the last piece of cloud around me after going through your material thanks again Pradeep
Originally posted by Kathy Sierra: "A" is false because R CAN pass his reference for A over to B. The reason for this is that R has a REMOTE reference to A. Remote references can be passed around everywhere, without restriction. R can say, "Here you go B, here's a Remote reference to A." and that's not a problem. This would give B a Remote reference to A's Remote component interface (EJBObject stub) on which B could then call methods on A. It is always fine to send around Remote references to beans (meaning, references to the bean's Remote component interface).
The first time through the book I got this one right. Then I got too smart and kablamyow! Nice to find this reasoning here. --Dale--
Joined: Aug 27, 2003
Dale, you are really smart indeed to get this one right. A lot of people including me have got this wrong the first time.
Joined: Mar 22, 2004
Originally posted by Vishwa Kumba: Dale, you are really smart indeed to get this one right
I don't think it had anything to do with "smart" because I missed it the second time through (when I was presumably "smarter"). --Dale--