Hi…
I really miss static (per-user) variables like in Swing.
Any ideas, if it is possible to tweak classloaders to provide such behaviours?
Hi…
I really miss static (per-user) variables like in Swing.
Any ideas, if it is possible to tweak classloaders to provide such behaviours?
Maybe you can consider using
ThreadLocal
as an alternative?
This is an old trick: ThreadLocal variable gives you a static-like access, but are actaully bound to the current executing thread. Even in multi-user environments (like webservers) the processing for a single user is made (mostly) in a single thread. So, by correctly initializing ThreadLocals in the beginning of each http request you can access the data in a static way during the rest of the request. In practice this means per-user statics.
This pattern has been succesfully used with Vaadin also:
See this wiki-article here.
Exactly!
Thanks!