Retrieving user name from inside each bean.

Riccardo Bongiovanni

How can I retrive from inside my Bean (Stateless Session and Entity CMP) the user name which I'm serving (the user name of user just logged in my web application)?
I need to know user name because I have a "logger Class" in my enterprise application that automatically generates logs files for tracking transactions for each user that logs in.

Inside an EJB you may retrieve the "Caller" name, that is the login id by invoking:
sessionContext.getCallerIdentity().getName()
where sessionContext is the instance of "SessionContext" (setSessionContext) passed to the Session Bean, or the instance of "EntityContext" (setEntityContext) passed to the Entity Bean.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact