Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Substitute for ThreadLocal in Vaadin 7
I am currently migrating a large project from Vaadin 6 to Vaadin 7. As the framework was completely redesigned (or seems to), the ThreadLocal interface is not available anymore.
The problem I have is that I have a class AppModel, which is responsible for storing the session data for all the users.
But that doesn't work anymore, due to the lack of ThreadLocal.
My question now is: How can I store user-dependent session data in this class?
For example: AppModel stores the user names of all logged in users. So, User1 has his own user name, User2 has his own user name, and so on.
Thanks in advance
ThreadLocal is a class from the Java Class Library and has nothing to do with Vaadin itself -> http://docs.oracle.com/javase/7/docs/api/java/lang/ThreadLocal.html
For User-specific data it will normally be sufficient to save it as instance-variable in the UI-class.
In which UI class?
The search function of Eclipse returns more than 10,000 matches for the term "AppModel".
Subtracting the number of "import" lines, there are still about 9,500 uses of AppModel in about 200-300 different classes and methods. Each of those methods gets information about the user from AppModel and does something with them, like logging the specific user out, verifying the user's identity for permission checks and so on.
How is it possible to replace all of those methods?
Do I even have to find another solution or does ThreadLocal work in Vaadin 7?
I do see no reason why it shouldn't. UI.getCurrent() etc are implemented just that way too.
Okay, thanks. I will try to fix it then.