• 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

SessionContext

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In an EJB, how is a SessionContext useful?

Thanks a lot.
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the SessionContext reference, the bean interacts with the container throughout the lifecycle of the bean.

Thanks,
Mahesh
 
Nupur Gupta
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mahesh... yes I know it interacts... but how? I mean, what are the useful things that are done... i mean i looked up the sessioncontext api, and it didnt look very functional....
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nupur,
Let me explain you why any implementation of EJBContext (i.e. sessioncontext or entitycontext) is important. As Mahesh told you that'bean instance interacts with the container throughout the lifecycle'.
1. Using this object you commit/rollback you Tx
2. You can get the PK (if it is entity bean)
3. Using that you get UserTranscationObject which is used to handle User
Manager Tx.
4. You can get the user Principal object which tells you credential user has
given to i.e. some time if you want that some method of your ejb shd be
called when user has some role/credentials that you use that object.
{when you want to do this thinh via code}
5. You can get the reference of your EJBObject/Local Object.
6. you can also use that object to check whether user has cretain role
before user call any method ?

Hope that I am able to give the answer.

Cheers,
Sunil Dixit
 
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EJBContext:
Every bean obtains an EJBContext object, which is a reference directly to the container. The EJB can request information about its environment like the status of a transaction, a remote reference to itself (an EJB cannot use �this� to reference itself) etc.
 
Aaron Raja
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me say this in simple way !!!
EJBContext--> Every bean obtains an EJBContext object, which is a reference directly to the container. It provides methods for interacting with the container so that the bean can request information about its environment like the identity of the caller, security, status of a transaction, obtains remote reference to itself etc. e.g. isUserInRole(), getUserPrincipal(), isRollbackOnly(), etc
The EJB can request information about its environment like the status of a transaction, a remote reference to itself (an EJB cannot use �this� to reference itself) etc.
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic