Implement spec issue 1455: support ctor injection for Table 5-3 artifacts
We have an existing automated test that validates that field and setter injection works for many of the artifacts in table 5-3. I set a breakpoint in the ctor in one of those artifacts, a StateManager. Here is the stack trace:
FacesConfigStateManager.<init>:52
Hidden Source Calls
Constructor.newInstance:423
AbstractConfigProcessor.createInstance:327
ApplicationConfigProcessor.setStateManager:636
ApplicationConfigProcessor.process:346
AbstractConfigProcessor.invokeNext:155
LifecycleConfigProcessor.process:138
AbstractConfigProcessor.invokeNext:155
FactoryConfigProcessor.process:246
ConfigManager.initialize:443
ConfigureListener.contextInitialized:237
Hidden Source Calls
AccessController.doPrivileged
Subject.doAs:360
Hidden Source Calls
AccessController.doPrivileged
Subject.doAs:360
Hidden Source Calls
Thread.run:748
There is no CDI in the construction of the artifact. We just use straight up reflection. The code would have to be reworked to use CDI to create the artifacts, if I'm not mistaken as to how CDI works.
I didn't look at this issue extensively, but as a quick comment there are basically two main modes for realising CDI injection:
- Making the artefact fully a CDI managed bean. This is done for only a limited set of artefacts, which can be seen here: https://github.com/javaserverfaces/mojarra/blob/master/impl/src/main/java/com/sun/faces/cdi/CdiUtils.java#L103 (they are all the createXYZ methods)
- Creating the bean in whatever other way and then using the CDI bean manager to inject the object.
In the second case only injection is done, but all other CDI things (like automatic enablement of interceptors and the like) is not being done, and the full lifecycle of the bean is under (in this case) JSF's control.