Acessing Vaadin UI from within a class Extending HttpServlet

Hi Im trying to access the vaadin ui to add a notification or error window when something occurs within an httpservlet class.I know httpservlets are on their own threads and vaadin ui uses a threadlocal pattern which means I can only access the ui from the thread that created it.I also know that I cant make a static reference but the problem is it will be shared across multiple users.I tried to catch the request/response using a listener but same issue there with not being able to access the ui from another thread .I also wouldent mind writing to the response/request in the servlet and catching it somewhere else, but I cant seem to get that working either. Any suggestions would be greatly appreciated!Im using vaadin 7.6.

I would suggest another approach for you. Instead of trying to access UI directly from servlet originated thread, you should dispatch global event (linge Singleton in Guava EventBus) and catch it in UI.

In theory you could register UI’s (from UI) to your class (where you would hold them as hashmap of weak references), but it is a pattern I would really like to avoid, since despite of weak references it is prone to memory leakages, etc.

Thank you will give this a try!

So I managed to get the event working using a singleton eventbus post. However adding a window to the ui is working but its not refelecting in the ui immediately how can i force this window to be added immediately after an update from the background thread.