> Hallo!
> I have a stupid question:
[quoted text clipped - 13 lines]
> The first solution (without "narrow") it's correct?! If not, why it works
> with JBoss?!
The second solution uses a remote lookup. The first does a lookup "in
VM". That means, you just execute call by reference and not call by
value. It is possible with JBoss since client and EJB container are
coupled in the same VM (I assume the lookup is done from a web container
which is usually bundled with the ejb container in JBoss. If not, you
have to use the remote lookup syntax.).
-marek
Capitan Mutanda - 11 Nov 2003 16:40 GMT
> > Hallo!
> > I have a stupid question:
[quoted text clipped - 20 lines]
> which is usually bundled with the ejb container in JBoss. If not, you
> have to use the remote lookup syntax.).
I don't get your answer ... I'm learning EJBs just know... your explanation
holds if use use CabinLocalHome. In the second he is narrowing from
Object to CabinHomeRemote. My impression is that there is some code
missing..
cheers
cm
Marek Lange - 11 Nov 2003 19:25 GMT
Capitan Mutanda schrieb:
>>The second solution uses a remote lookup. The first does a lookup "in
>>VM". That means, you just execute call by reference and not call by
[quoted text clipped - 7 lines]
> Object to CabinHomeRemote. My impression is that there is some code
> missing..
I think JBoss is just optimizing the call. There is no need to use local
interfaces since JBoss recognizes in VM calls. I am not sure whether the
code will work in other app servers.
-marek
> CabinHomeRemote home=(CabinHomeRemote)jndiContext.lookup("CabinHomeRemote");
> ....
[...]
> Object ref=(CabinHomeRemote)jndiContext.lookup("CabinHomeRemote");
> CabinHomeRemote
> home=(CabinHomeRemote)PortableRemoteObject.narrow(ref,CabinHomeRemote.class)
> ;
[...]
> The first solution (without "narrow") it's correct?! If not, why it works
> with JBoss?!
From what they say, the first version may work, but it's recommended to
use version 2 for remote Objects. I heard that JBoss optimizes these
calls if your code and the Beans run in one VM.
When you look in the PortableRemoteObject implementation [1], you can
see that it's more or less a simple type check:
public java.lang.Object narrow ( java.lang.Object narrowFrom,
java.lang.Class narrowTo)
throws ClassCastException {
[...]
Class narrowFromClass = narrowFrom.getClass();
try {
// Will a cast work?
if (narrowTo.isAssignableFrom(narrowFromClass)) {
// Yep, so we're done...
result = narrowFrom;
[1] com.sun.corba.se.internal.javax.rmi.PortableRemoteObject
Johann

Signature
ich bin mir zimlich sicher wo ich bin du treumer.
("Bernd P." in dag° und in <b1mjh6$14dal3$1@ID-156972.news.dfncis.de>)