• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

A question aboute stateless session bean equals

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Give the following clientside code:


10.@EJB Foo f1;
11.@EJB Foo f2;
//more code here
20.boolean test1=f1.equals(f1);
21.boolean test2=f1.equals(f2);
...


If Foo is stateless,test1 is true(of course).
I think test2 is false,because a method equals() have been invoked on f1,so container have been offered a special Foo instance to f1,so f1 is not equals to f2.But the answer for test2 is true.
beg for help!
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See core spec 3.4.5.2 (there is also a similar example like yours):

All business object references of the same interface type for
the same stateless session bean have the same object identity,
which is assigned by the container.

Remember from SCJP that equals() only checks that two objects are
meaningfully equivalent.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In your case your are not getting the reference of the Bean where as the Reference of the Remote Object (Stub Class) which can be same in case of stateless bean.

you do a lookup to the given bean and the server returns a reference in the form of RemoteObject Stub class implementation of your Remote interface.

So when you call the equals method you are calling it on the Local Stub which extends LocalWrapperClass specific to container which might equate the
actual bean to which the stub is pointing to. So if your lookup returns the remote reference to the same SessionBean in the memory then the equals might pass.

No clear on the entire complex concepts but what I can say is if you lookup returns the references to same object in the Object Pool then the equality would pass.
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Goutham Pallipati wrote

So if your lookup returns the remote reference to the same SessionBean in the memory then the equals might pass.

No clear on the entire complex concepts but what I can say is if you lookup returns the references to same object in the Object Pool then the equality would pass.

The result of equals() in the present context doesn't depend on the refernced pool objects at all! It only depends on the class of the business interface and the bean class.
[ December 17, 2008: Message edited by: Ralph Jaus ]
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic