Qute requestScoped bean resolution. #32422
-
If I have a requestScoped bean, that returns a CompletionStage, then this code will fail
in the above, area.customerList, returns a completion stage, that provides a list of customers (since this operation to initially fetch the list of customers is expensive. Further calls to area.customerList, returns the same, now completed, completionStage). However, this means when {#for customer in cdi:area.customerList}, is evaluated, this is running in a different thread, to the request thread, and the cdi:area requestScoped bean is no longer found. I can fix this pretty easy, by adding this to the top, and then referring to areabean when I want my list of customers. But, this is just a work around - if there were #included templates further down, which also made use of the area bean, i would be forced to pass this areabean in, rather than allow that included template to resolve the bean itself. Personally, I think that this could be better - Qute should only ever resolve CDI beans, in the request thread (The thread that called TemplateInstance.render()) , maybe by resolving all beans in the template, and its included subtemplates upfront, OR, by making sure that the requestScope is inherited by any threads that are spawned during the processing of the template, to avoid blocking. Opinions? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 15 replies
-
/cc @mkouba (qute) |
Beta Was this translation helpful? Give feedback.
-
There you go.. If you visit /test , you get the error. Incidentally. in TestResource, I am doing the below. So, the render() method must block until the page is fully rendered, and so the Requestcontext must still exist at this point.
|
Beta Was this translation helpful? Give feedback.
There you go.. If you visit /test , you get the error.
TestRequestScopeQute.zip
Incidentally. in TestResource, I am doing the below. So, the render() method must block until the page is fully rendered, and so the Requestcontext must still exist at this point.