• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Object equality for Session beans

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The below lines are from the EJB 3 Spces!

3.4.5.1 Stateful Session Beans
A stateful session object has a unique identity that is assigned by the container at the time the object is
created. A client of the stateful session bean business interface can determine if two business interface
references refer to the same session object by use of the equals method.
For example,
@EJB Cart cart1;
@EJB Cart cart2;
...
if (cart1.equals(cart1)) { // this test must return true
...
}
...
if (cart1.equals(cart2)) { // this test must return false
...
}
All stateful session bean references to the same business interface for the same stateful session bean
instance will be equal. Stateful session bean references to different interface types or to different session
bean instances will not have the same identity.



Does this hold good for Stateless beans as well?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just read the next lines from the specs,

3.4.5.2 Stateless Session Beans
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.
For example,
@EJB Cart cart1;
@EJB Cart cart2;
...
if (cart1.equals(cart1)) { // this test must return true
...
}
...
if (cart1.equals(cart2)) { // this test must also return true
...
}
The equals method always returns true when used to compare references to the same business interface
type of the same session bean. Session bean references to either different business interface types
or different session beans will not be equal.



Got my doubt clarified!

The specs are awesome and now I find that they are a must read for the SCBCD 5!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic