开发者

How can i achieve active(current) UserContext in some classes?

开发者 https://www.devze.com 2023-03-24 01:28 出处:网络
I have a problem. I hope somebody can help me. I want create UserContext when Servlet HttpListener SessionInitialize Method running.

I have a problem. I hope somebody can help me.

I want create UserContext when Servlet HttpListener SessionInitialize Method running. And after i want to call UserContext in Java Class.

Example :

protected static Map userMap开发者_运维技巧List=new HashMap();

this Map keep my application users contexts.

But i don't know how can i achieve active(current) UserContext in some classes?

Other Example in JSF:

FacesContext Thanks,


use ThreadLocal class to store thread specific values. so when you get the new request [which really a new thread], you can dump that in the ThreadLocal object after that, any class running on the same thread can just call ThreadLocal.get.

check its api @ http://download.oracle.com/javase/1.4.2/docs/api/java/lang/ThreadLocal.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号