Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

SessionContext

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic