i am looking for a way to track the begin and end of a transaction to set a reference to a ThreadLocal variable.
Vaadin 6 offered the transaction listener. It allowed me to do initialization when a transaction was started and clean up if it was ended.
What exactly do you want to do with it? The normal use case was that you wanted to store the application reference into a place that you can access it statically, like MyApplication.get();. If this is what you are looking for, there is now UI.getCurrent(); built in into Vaadin without the need of transaction listeners.
I would like to store one of my own objects to a ThreadLocal variable.
Then i can access it everywhere from the code as long as i am in an active request.
How about if we want to set logging MDC values unique to each request thread? Certainly we can’t use the session object in that case: Log4J’s MDC knows nothing about Vaadin.
In general, there may be thread locals that are not under our control, so we can’t resort to a Session. I suppose we could hijack Vaadin’s servlet, but then this feels more and more like a regression.
Another use case is one in which we enable maintenance mode in an application and we want our users to immediately get a different screen. We used to decide this on transactionStart. How can we decide it in Vaadin 7?