Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

question on isIdentical()

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand when a single client gets 2 stubs from the same home by calling create() method twice, we can use isIdentical() to check whether they are identical or not?
How can two different clients use isIdentical() method...to compare whether their stubs are got from the same home interface?because they are in no way related?
please throw some light
thanks
Pradeep
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can you explain your question again please, perhaps providing an example of what you are trying to achieve?
Thanks
-=david=-
 
pradeep arum
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
let me put my question this way.
is it possisible for 2 different clients to use the method isIdentical() ie. to check whether 2 objects are similar or not?if yes,how can one client get the object of another.
say client1 has a reference ref1 to the component interface and client2 has a reference ref2 to the same component interface,now,can i say somehow in client2, ref2.isIdentical(ref1),if so how? client2 doesnt know ref1,right?
thanks
Pradeep
 
David Harrigan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic