Apologies in advance if this is not the correct place to put this.
No one else may even want this feature. But we needed it, so I thought I'd add it here for refinement and incase anybody does need it for the same or other reasons.
Background:
I am using JDO to retrieve my objects, however I don't detach these objects from the graph. So I need a way of openening up a PersistenceManager within the thread and then closing that persistence manager when the event is finished.
This is fine in a normal webapp and easy to do with a HttpServletFilter, but it a filter won't work with thinwire because the actual event code runs in another thread that is not the servlet thread.
Also to ensure a consistent manager factory, we need access to the servlet context.
Our Solution [read Hack]:
1) Add a WebApplication.getServletContext() instance method. This way you always have access to the context via: Application.current().getServletContext()
2) Add a WebComponentEventListener event chain which gets called within the running thread, before the event code gets executed, it passes a chain object, so you simply do your before code, call chain.next(), and then do your cleanup code.
3) Each WebComponentEvent has a getHttpServletRequest() method.
It's probably not the brightest solution, but it may fill someones need, and could maybe be improved on.
Patch for Pre/Post Event Listeners