On Tue, Nov 22, 2022 at 4:11 PM Rémy Maucherat <r...@apache.org> wrote: > > Hi, > > Following a post on the user list, I have looked into CDI and > injection processing in Tomcat standalone (or standalone extended by > CDI) and found the following issues:
Ok, so the summary: > a) metadata-complete is done wrong. The spec got retconned some time > ago and metadata-complete only means Servlet spec defining metadata, > such as @WebServlet (= the ones that require scanning all classes just > in case). So in practice inside DefaultInstanceManager the > ignoreAnnotations flag shouldn't be used at all and it should simply > be removed. I am ok on only doing this in 11 ;) Done in 11. When a migration doc is added, ignoreAnnotations on Context should be mentioned as the new metadata-complete. > b) CDI is not intertwined with the DefaultInstanceManager. Basically > as the user said, injections should be done *before* @PostConstruct, > and it . There's a (minor) problem with the DefaultInstanceManager > API, a method needs to be protected and then integrations will then be > able to hack inside the DefaultInstanceManager. You can see this here > in the OWB integration: > https://github.com/apache/tomcat/blob/main/modules/owb/src/main/java/org/apache/webbeans/web/tomcat/OpenWebBeansInstanceManager.java#L102 > (basically, first call newInstance, because there's no other way, then > inject, but newInstance will have already invoked @PostConstruct). To > fix this, I plan to add an Injector interface to > DefaultInstanceManager since this is pretty much the only way to do > this cleanly in Tomcat standalone (taking over the whole > DefaultInstanceManager is clearly not the best idea). The current solution "works" with a few gotchas, so we'll simply keep that instead. Rémy > The impact of fixing these for users should be non-existent: it is > really a Tomcat standalone only thing impacting users with some very > precise EE needs. A full EE integration will simply take over the > whole annotation processing and instance manager from Tomcat, and > hopefully do The Right Thing already. > > Although this is not super critical, I plan to address these issues in > the OWB integration (after adding the needed API change in Tomcat's > DefaultInstanceManager). > > Comments ? > > Rémy --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org