In our enterprise application there are Service tier (EJB3.0 including business logic and database access) and Web tier (Servlet/JSP). Seperated ear and war are deployed in JBoss AS 7 in distributed machines.
Service tier contains both Stateful and Stateless EJB.
We have EJB interceptor for methods invoking. For user that logged in from the Web tier the user info is saved in HttpSession (user validation is simply processed by query his account & password in DB).
Now the performance tuning needs to know which user has called those EJB methods, the user info, date info etc. These will be extracted and logged or stored in DB for our anylize.
Now my question is:
How to distinguish the caller's info in EJB tier?
The EJB interceptor can get the EJB method's parameters and when it's called. But we don't know who has called it.
We know it's ugly to combine EJB tier with Web tier. So we won't pass HttpSession/HttpRequest to EJB layer even that may help to get what we need from the Session/Request object.
And there are so many EJB methods that we can not pass an TuningInfo(include request info, user info etc) as parameter from web to every EJB method.
Is it possible to get the caller's info in EJB tier?
Thanks in advance.
If Web layer and EJB layer is on the same JVM, the you can pass the user information via thread local. http://javacodesamples.wordpress.com/2012/07/11/understanding-the-concept-behind-threadlocal/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With