Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP 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
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Operations Allowed in the Methods of a Session Bean

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

One doubt in "Operations Allowed in the Methods of a Session Bean".

From my understanding
PostConstruct, Pre-Destroy, PrePassivate,PostActivate callback
methods run in a unspecified Transaction Context. So Resource manager access and Enterprise bean access should not be allowed in these methods.


If I see the tables (Table1-page 74 and Table2-page 82 ) from ejb-3_0-pr-spec-ejbcore.pdf spec, there are some differences.

For Statefull Session beens

Operations allowed in PostConstruct, Pre-Destroy, PrePassivate,PostActivate are
1. SessionContext methods: getBusinessObject,getEJBHome, getEJBLocalHome, getCallerPrincipal,isCallerInRole, getEJBObject, getEJBLocalObject
2. JNDI access to java:comp/env
3. Resource manager access
4. Enterprise bean access

For Stateless Session beens
Operations allowed in PostConstruct, Pre-Destroy are

1. SessionContext methods: getBusinessObject,getEJBHome, getEJBLocalHome, getEJBObject,getEJBLocalObject, getTimerService
2. JNDI access to java:comp/env

As we know all the above methods are running in unspecified transaction.
Why Resource manager access and Enterprise bean access are allowed in Statefull session bean?
Can any body please help me to understand the difference here?

Regards,
Chittaranjan
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Resource manager access and Enterprise bean access are allowed if methods are running in a meaningful transaction or have a client security context. Since stateful session beans have a client associated when these methods are called, although not in transaction, the access to resources is allowed.

Stateless beans do not have client associated in these methods so access to resources are not allowed.

Even I had difficulty understanding these concepts but this is the way I understood them.

Hope this helps,
Mini
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic