cdi
cdi copied to clipboard
Add support for custom view providers
Originally by jaroslaw_przygodzki
It's not immediately obvious (or at least not explicitly stated anywhere in the documentation, as far as I can tell) but in order to ensure correct behavior of CDI integration one must use CDIViewProvider exclusively. Because of how CDIViewProvider works internally creating custom view provider is almost impossible. If CDIViewProvider was refactored (possibly including some changes in Vaadin codebase) developing custom view providers would be possible.
Imported from https://dev.vaadin.com/ issue #16701
Originally by @Legioth
Could you give a concrete example of what you want to achieve? What aspect of CDIViewProvider would you want to customize?
Originally by jaroslaw_przygodzki
I was previosly working with Vaadin in OSGi envrioment and JEE is in many ways an unwelcome change that unfortunately cannot be helped. The particular aspect of CDIViewProvider that I find limiting is static view discovery. I suppose that is has more to do with CDI in general then Vaadin CDI integration, but having the ability to add and remove views at runtime would be useful .
I am not sure if this a case of XY problem.
Originally by @Legioth
For static view discovery, I'd suggest making your own simple ViewProvider that uses regular @Inject for the specific views that you want to use.
Originally by jaroslaw_przygodzki
But then events that the CDIViewProvider fires internally are never fired - making it work involves hacks, copy pasting code and changing VaadinCDIServletService (see CDIViewProvider.getCleanupEvent() and it's usage). Vaadin CDI integration relies on specific CDI events being fired in specific order which can not happen if CDIViewProvider is not used.
Attempting to use Vaadin CDI without any view providers (only to create UI's and inject EJB's, not using custom scopes) is another scenario that lead to incorrect behaviour.
-At the very least I would expect documentation for the plugin to describe this limitations.*
Perhaps related to #14884 ?
Former issue 14884 is now https://github.com/vaadin/cdi/issues/131