vaadin / framework

Vaadin 6, 7, 8 is a Java framework for modern Java web applications.
http://vaadin.com/
Other
1.78k stars 729 forks source link

Fire events when starting and ending session access. #4220

Open vaadin-bot opened 11 years ago

vaadin-bot commented 11 years ago

Originally by @Legioth


Frameworks like JPA are often used with a transaction-per-request pattern where a new transaction is started at the beginning of every request and then committed or rolled back the request after the request has been handled.

In Vaadin 6, this was usually implemented using TransactionListener or HttpServletRequestListener. Vaadin 7 removed support for those features and it was instead recommend to use a servlet filter (see e.g. #10983). The introduction of server push and UI.access(Runnable) in Vaadin 7.1 furthermore means that the same HTTP request might (asynchronously) touch multiple sessions that should probably each have their own transaction. The push support also encourages patterns where a session is accessed outside the context of a HTTP request, e.g. from a custom worker thread.

All in all, it seems that the concept of transaction-per-request can no longer work sensibly with Vaadin applications. Transactions should instead be bound to session access; starting a transaction when locking the UI and ending the transaction when unlocking.

To support this, events should be fired whenever VaadinSession is locked or unlocked. Some thoughts about the implementation:


Imported from https://dev.vaadin.com/ issue #12256

vaadin-bot commented 11 years ago

Originally by @jdahlstrom


Would these be "lock-acquire listeners" or "access listeners"? These are logically distinct, as queued access invocations are run in the same critical section. If the former, would the listeners be run when reentrantly acquiring the lock, or only at the actual boundaries of the critical section?

vaadin-bot commented 11 years ago

Originally by @Legioth


At least the JPA would just get more complicated if events would be fired for reentrant access. I don't know any other use case that would benefit from doing so either.

Queued access invocations are contributing to the same response or push message, so it would probably make sense to just draw the boundary at the critical section, i.e. "lock-acquire listeners". For the naming I would still like to stay away from using the word "lock" because it makes this sound too complicated. My suggestions would be:

stale[bot] commented 6 years ago

Hello there!

It looks like this issue hasn't progressed lately. There are so many issues that we just can't deal them all within a reasonable timeframe.

There are a couple of things you could help to get things rolling on this issue (this is an automated message, so expect that some of these are already in use):

Thanks again for your contributions! Even though we haven't been able to get this issue fixed, we hope you to report your findings and enhancement ideas in the future too!