posted 20 years ago
Hi,
It is possible.
A little example is worth a thousand words...
Below I have two versions of the AdviceClient demo'ed in the HFEJB book.
Example 1
Example 2
You can see that AdviceClient2 calls AdviceClient which passes back a reference to the EJBObject stub previously created.
I then run AdviceClient2, thus:
And you can see that a is indeed identical to b, or rather the object identity returned when AdviceClient2 does a create is identical to the object identity returned when AdviceClient does a create.
AdviceClient2 does indeed "know" about the "a" reference, because AdviceClient2 was compiled using this same client jar as AdviceClient (otherwise it would fail a compiliation because it wouldn't know about the Advice class or the AdviceHome class.
To paraphase the spec,
The isIdentical(EJBObject otherEJBObject) method will always return true when used to compare object references (Advice) of two session objects of the same stateless (I'm using a stateless bean here) session bean.
If you're using stateful session beans however, the above will return false, since each client is given it's own reference to a stateful bean, so AdviceClient will have its own object reference to Advice and AdviceClient2 will have its own object reference to Advice.
Hope this helps.
-=david=-
[ January 09, 2004: Message edited by: David Harrigan ]