• 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

Stateless session and EjbObject

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI there,
Stateless session bean can have ejbCreate() and ejbRemove() calls.
A stateless bean may be created without client being there as a part of containers policy.
this 2 methods cannot query security info and transaction stuff simply because there may not be a client to query to in both of those methods.

But when the client may not be there, why does ejb allow to call getEJBObject() from SessionContext interface from those 2 methods?

Please help me understand this.
(Please refer me to any already post que if there is any.)
Amol.
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think stateless bean can have BMT in ejbCreate and ejbRemove, right?
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Brenda Kwok:
I think stateless bean can have BMT in ejbCreate and ejbRemove, right?



NO ! SessionBean (both stateless and stateful) can have transaction (both BMT and CMT) for it's business methods only. Not for callback methods.
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

***********************SLSB********************************************
For SLSB, ejbCreate() and ejbRemove() called ven container wan2 increase/reduce the pool size to handle the client load.@ this time,there is no security ctx or txn ctx associated with the call. So bean instance cannot call ani security/txn related methods.[if u du so, container will throw java.lang.IllegalStateExce..n.]
But ven client calls create() on home obj, EJB specs says, u wan2 assume that corresponding ejbobject is created.[contaner may or may not create an ejbObject. some containers even reuse same ejbobject for all bean insatnce from same home. check containers docs for details].so u can safely call getEJBObject()[or getEJBLocalObject()] on the session ctx.
**********************************************************************

***********************SFSB********************************************
For SFSB, ejbCreate()/ejbRemove() called ven client calls create() or remove() on home object.(there r also other scenarios where ejbRemove() gets called).so the client (& the security ctx ) is always there.But there is no txn ctx associated with the call. So bean instance cannot call ani txn (CMT)related methods.
u can safely call getEJBObject()[or getEJBLocalObject()] on the session ctx since new ejbobject is created for each create() call on home.

**********************************************************************

***********************SB(general)**************************************
ejbPassivate(),ejbActivate(),setSessionCtx(ctx),ejbRemove(),ejbRemove() and afterCompletion(boolean)[onli for CMT] methods r cald with unspecified txn ctx.So u cant call ani txn [CMT]related methods in these methods.
**********************************************************************

***********************SB(BMT)**************************************

For SLSB BMT methods(getting UserTXn obj and calling methods on it) can onli called from Biz methods.
But for SFSB u can call BMT methods in ejbPassivate(),ejbActivate(),setSessionCtx(ctx),ejbRemove(),ejbRemove() and biz methods

**********************************************************************



Binoj V
 
amol deshpande
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thankx for description.Yeah container follows different order for EJBObject creation for Stateless bean.
Container may call Statelesss beans ejbCreate and ejbRemove as upon its requirement. Heance its not right to do any Tx stuff there even BMT UserTransation there. It would be illegal as those methods are not part of client actions.
Amol.
 
reply
    Bookmark Topic Watch Topic
  • New Topic