Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 3 weeks ago
CurrentInstance - Custom usage
Hello,
I want to use CurrentInstance to add a threadlocal class instance on my own (I want to be able to use it just like "UI.getCurrent()").
This should happen inside an addon project.
I am not sure on how/when to add the instance to CurrentInstance.
Example:
public class MyTracker {
public static MyTracker getCurrent() {
// here?
MyTracker instance = CurrentInstance.get(MyTracker.class);
if(instance == null) {
// Threadsafety on parallel calls of "getCurrent()" ?
instance = new MyTracker();
CurrentInstance.set(MyTracker.class, instance);
}
return instance;
}
}
Last updated on
You cannot reply to this thread.