weld/core — pull request #140 by mstruk (2011-10-22 16:52:28+00:00)
Title: Addressing cross-context dispatch issue

When using Weld within portlets, all the invocations are dispatched via includes, which has a side effect that requestInitialized / requestDestroyed events are never fired withing the context of portlet web application, and therefore never received by WeldListener.

portal.war:
- requestStarted() - NOT received by WeldListener in portlet.war
- dispatch include to portlet.war

portlet.war
- process JSF phase
- Weld PhaseListener
- CRASH! - no active request

The proposed fix is a filter, to be installed in portlet app, that makes sure that request context has been initialized, by providing requestInitialized / requestDestroyed events. It is careful to only signal requestInitialized if request context has not yet been initialized, and to only signal requestDestroyed if it was this filter that performed init on current thread.