javaee/javaserverfaces-spec

Web Container injection support should be provided for additional lifecycle artifacts (not just managed beans)

Closed this issue · 41 comments

JSF implementations should treat the following framework components as JEE
components, and pass them through the field-injection hooks as part of any
instantiation process. E.g: Whether or not the framework is instantiating the
object for it's use, or the user is asking the framework for a new instance.

This means that any container provided injection points would automatically be
available in the following artifacts:

  • ManagedBean
  • PhaseListener
  • SystemEventListener
  • Converter
  • Validator
  • ... more?

For extension writers:

  • Support for native container-injection for all artifacts defined in
    section 11.4.6 of the JSR-314 spec.

â-  ActionListener
â-  ApplicationFactory
â-  FacesContextFactory
â-  LifecycleFactory
â-  NavigationHandler
â-  PropertyResolver
â-  RenderKit
â-  RenderKitFactory
â-  ResourceHandler
â-  StateManager
â-  VariableResolver
â-  ViewHandler

Environment

Operating System: Linux
Platform: PC

Affected Versions

[2.0]

Reported by lincolnbaxter

lincolnbaxter said:
Parallel Mojarra and MyFaces issues:

https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1578
https://issues.apache.org/jira/browse/MYFACES-2590

GlassFish defect WRT existing @ManagedBean functionality in Mojarra:

https://glassfish.dev.java.net/issues/show_bug.cgi?id=11655

@edburns said:
target 2.1

@edburns said:
frame

@edburns said:
These are targeted at 2.1.

@edburns said:
triage

@edburns said:
GlassFish 3.1 M6 at the latest.

@edburns said:
Per 20100810 scrum, move to M5.

@edburns said:
Created an attachment (id=265)
Fix in progress. Support for injection of components, behaviors, converters, and validators works.

@edburns said:
Move these to 2.2

@edburns said:
MM> Hello,
MM> may anybody explain "Web Container injection"? Is there a difference to
MM> CDI? If yes, can't it be unified? EJB Injection = Web Container
MM> injection, just depending on the target?

Sure, there is no difference. I guess we can call it CDI.

@edburns said:
Fix in progress. Support for injection of components, behaviors, converters, and validators works.

@edburns said:
Sending jsf-ri/src/main/java/com/sun/faces/application/ApplicationImpl.java
Adding jsf-ri/src/main/java/com/sun/faces/application/ApplicationInstanceFactoryMetadataMap.java
Sending jsf-ri/src/main/java/com/sun/faces/mgbean/BeanBuilder.java
Adding jsf-ri/src/main/java/com/sun/faces/util/MetadataWrapperMap.java
Sending jsf-ri/src/main/java/com/sun/faces/util/Util.java
Sending jsf-ri/systest/build-tests.xml
Sending jsf-ri/systest/build.xml
Sending jsf-ri/systest/src/com/sun/faces/annotation/AnnotatedBehavior.java
Sending jsf-ri/systest/src/com/sun/faces/annotation/AnnotatedConverter.java
Sending jsf-ri/systest/src/com/sun/faces/annotation/AnnotatedValidator.java
Sending jsf-ri/systest/src/com/sun/faces/annotation/AnnotationTestBean.java
Adding jsf-ri/systest/src/com/sun/faces/systest/pre31injection
Adding jsf-ri/systest/src/com/sun/faces/systest/pre31injection/ComponentWithResourceInjection.java
Sending jsf-ri/systest/web/WEB-INF/source1.taglib.xml
Adding jsf-ri/systest/web/pre31injection
Adding jsf-ri/systest/web/pre31injection/injectedComponent.xhtml
Sending jsf-ri/test/com/sun/faces/config/TestManagedBeanFactory.java
Transmitting file data ...............
Committed revision 9296.

@edburns said:
Sending preface.fm
Sending valueReferences.fm
Transmitting file data ..
Committed revision 1029.

@edburns said:
Next step is to support injection of things created because they are specified in the faces-config. Starting with PhaseListeners.

In AbstractConfigProcessor.createInstance(), use the ApplicationInstanceFactoryMetadataMap in the same way you did in ApplicationImpl.newThing().

@edburns said:
Here is an excerpt from the changelog entry for r9296.

SECTION: Modified Files

M valueReferences.fm

  • Modify section "Leveraging Java EE Platform Annotations in Managed Beans"

Rename the section to "Leveraging Java EE Platform Annotations in
Managed Beans or other JSF artifacts"

Update the list of valid annotations:

@javax.inject.Inject
@javax.inject.Named
@javax.inject.Qualifier
@javax.inject.Scope
@javax.inject.Singleton
@javax.enterprise.context.ApplicationScoped
@javax.enterprise.context.ConversationScoped
@javax.enterprise.context.Dependent
@javax.enterprise.context.RequestScoped
@javax.enterprise.context.SessionScoped
@javax.annotation.Resource
@javax.annotation.Resources
@javax.ejb.EJB
@javax.ejb.EJBs
@javax.xml.ws.WebServiceRef
@javax.xml.ws.WebServiceRefs
@javax.persistence.PersistenceContext
@javax.persistence.PersistenceContexts
@javax.persistence.PersistenceUnit
@javax.persistence.PersistenceUnits

Add this text:

In addition to managed beans being injectable in this manner, the
following JSF artifacts are also injectable.

UIComponent
Behavior
Converter
Validator

gerhard_petracek said:
just specifying the support for jsr-330 annotations like @Inject isn't enough because there is no way to get the BeanManager >equivalent< of frameworks which implement jsr-330 but not jsr-299 (like spring and guice do). therefore, we need a SPI for it.

gerhard_petracek said:
injection in ExceptionHandler should be supported as well

@edburns said:
Re: ExceptionHandler: certainly.

Re: SPI for BeanManager. That is a larger question than for the UI layer. In fact, that hole is a symptom of the great divide between the spec leads of 299 and 330. Gerhard, I humbly request that you elevate this to the JavaEE platform JSR. You can join this list directly and send mail to it.

http://java.net/projects/javaee-spec/lists/users/archive

The Expert Group will see the mails sent to the users list.

gerhard_petracek said:
that's for sure the second possibility to solve it, but i would expect that the jsr-330 eg already thought about it (they should have expected it, since the bean-manager was already in place at the time they started jsr-330 and it's pretty obvious that it isn't possible with the current content of jsr-330 to do such an integration). we will see the same issue at all other jsrs which need to specify such an integration. -> i suggest that all spec.leads should discuss it with the eg of the platform jsr. the other possibility would be to support the cdi integration out of the box and all other implementations of jsr-330 have to do it on their own like myfaces-codi is doing it for cdi and jsf < v2.2

however, this issue is blocked until there is a decision about it.

@edburns said:
GP> however, this issue is blocked until there is a decision about it.

You state the truth. I assert the quickest path to unblocking is for someone other than me to bring this up to the platform JSR. Spec leads get excited more by external contribution than internal contribution.

@edburns said:
Sending jsf-ri/src/main/java/com/sun/faces/config/processor/AbstractConfigProcessor.java
Sending jsf-ri/systest/src/com/sun/faces/annotation/AnnotatedComponentsTestCase.java
Adding jsf-ri/systest/src/com/sun/faces/annotation/AnnotatedPhaseListener.java
Sending jsf-ri/systest/web/WEB-INF/faces-config.xml
Sending jsf-ri/systest/web/annotationtest.xhtml
Transmitting file data .....
Committed revision 9323.

Make it so classes loaded from the faces-config.xml are injectable http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-763

SECTION: Modified Files

M jsf-ri/src/main/java/com/sun/faces/config/processor/AbstractConfigProcessor.java
M jsf-ri/systest/src/com/sun/faces/annotation/AnnotatedComponentsTestCase.java

  • Make it so classes loaded from the faces-config.xml are injectable.

M jsf-ri/systest/web/WEB-INF/faces-config.xml
M jsf-ri/systest/web/annotationtest.xhtml
A jsf-ri/systest/src/com/sun/faces/annotation/AnnotatedPhaseListener.java

  • Test that PhaseListener classes loaded from the faces-config are
    injectable.

@edburns said:
Committed to trunk:

Sending common/ant/common.xml
Adding jsf-api/src/main/java/javax/faces/application/ConfigurableNavigationHandlerWrapper.java
Sending jsf-api/src/main/java/javax/faces/event/ActionListenerWrapper.java
Adding jsf-test/#763")
Adding jsf-test/#763")/build.xml
Adding jsf-test/#763")/i_spec_763_war
Adding jsf-test/#763")/i_spec_763_war/pom.xml
Adding jsf-test/#763")/i_spec_763_war/src
Adding jsf-test/#763")/i_spec_763_war/src/main
Adding jsf-test/#763")/i_spec_763_war/src/main/java
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces/regression
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces/regression/i_spec_763_war
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces/regression/i_spec_763_war/FacesConfigActionListener.java
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces/regression/i_spec_763_war/FacesConfigELResolver.java
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces/regression/i_spec_763_war/FacesConfigNavigationHandler.java
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces/regression/i_spec_763_war/FacesConfigResourceHandler.java
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces/regression/i_spec_763_war/FacesConfigStateManager.java
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces/regression/i_spec_763_war/FacesConfigSystemEventListener.java
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces/regression/i_spec_763_war/FacesConfigViewHandler.java
Adding jsf-test/#763")/i_spec_763_war/src/main/resources
Adding jsf-test/#763")/i_spec_763_war/src/main/webapp
Adding jsf-test/#763")/i_spec_763_war/src/main/webapp/WEB-INF
Adding jsf-test/#763")/i_spec_763_war/src/main/webapp/WEB-INF/beans.xml
Adding jsf-test/#763")/i_spec_763_war/src/main/webapp/WEB-INF/faces-config.xml
Adding jsf-test/#763")/i_spec_763_war/src/main/webapp/WEB-INF/web.xml
Adding jsf-test/#763")/i_spec_763_war/src/main/webapp/i_spec_763_war.xhtml
Sending jsf-test/build.xml
Transmitting file data .................
Committed revision 9329.

Committed to spec trunk:

Sending valueReferences.fm
Transmitting file data .
Committed revision 1030.

@edburns said:
In progress list:

ManagedBean
Component
Behavior
Validator
PhaseListener
SystemEventListener

For extension writers:

Support for native container-injection for all artifacts defined in
section 11.4.6 of the JSR-314 spec.

ActionListener
ApplicationFactory
FacesContextFactory
LifecycleFactory
NavigationHandler
RenderKitFactory
ResourceHandler
StateManager
ViewHandler
ELResolver

I have decided not to do the following since they are deprecated:

PropertyResolver
VariableResolver

I have decided not to do the following because the factory that creates these things is injectable, so if you wanted to inject one of these things, you'd just "pass through" the injection.

RenderKit

@edburns said:
Snapshot. This implements the rest of the artifact types that need to be injectable.

@edburns said:
I need to commit the changes to the spec document.

@edburns said:
Committed spec changes:

Sending valueReferences.fm
Transmitting file data .
Committed revision 1042.

  • Committed sorting of table 5-3

javax.el.ELResolver
javax.faces.application.ApplicationFactory
javax.faces.application.NavigationHandler
javax.faces.application.ResourceHandler
javax.faces.application.StateManager
javax.faces.component.UIComponent
javax.faces.component.behavior.Behavior
javax.faces.component.visit.VisitContextFactory
javax.faces.context.ExceptionHandlerFactory
javax.faces.context.ExternalContextFactory
javax.faces.context.FacesContextFactory
javax.faces.context.PartialViewContextFactory
javax.faces.convert.Converter
javax.faces.event.ActionListener
javax.faces.event.SystemEventListener
javax.faces.lifecycle.LifecycleFactory
javax.faces.lifecycle.PhaseListener
javax.faces.render.RenderKitFactory
javax.faces.validator.Validator
javax.faces.view.ViewDeclarationFactory
javax.faces.view.facelets.FaceletCacheFactory
javax.faces.view.facelets.FaceletFactory
javax.faces.view.facelets.TagHandlerDelegateFactory

Sending common/ant/common.xml
Sending jsf-api/build.xml
Sending jsf-api/src/main/java/javax/faces/FactoryFinder.java
Sending jsf-test/#763")/build.xml
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces/regression/i_spec_763_war/FacesConfigApplicationFactory.java
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces/regression/i_spec_763_war/FacesConfigPhaseListener.java
Adding jsf-test/#763")/i_spec_763_war/src/main/java/com/sun/faces/regression/i_spec_763_war/NewApplication.java
Sending jsf-test/#763")/i_spec_763_war/src/main/webapp/WEB-INF/faces-config.xml
Sending jsf-test/#763")/i_spec_763_war/src/main/webapp/i_spec_763_war.xhtml
Transmitting file data .........
Committed revision 9442.

@edburns said:
Why is "Resolve" different than "Close"?

@edburns said:
Sending jsf-api/src/main/java/javax/faces/FactoryFinder.java
Sending jsf-ri/test/com/sun/faces/renderkit/TestRenderKit.java
Transmitting file data ..
Committed revision 9561.

@edburns said:
My implementation for this feature somehow breaks the JSR-299 TCK.

@edburns said:
The exception I am seeing is:

java.lang.ClassCastException: org.jboss.jsr299.tck.impl.JSR299PropertiesBasedConfigurationBuilder cannot be cast to org.jboss.testharness.api.ConfigurationBuilder

I see this on GlassFish 3.1.2. I haven't even tried the trunk yet.

@edburns said:
Asked Siva and several others if this was still failing. If I don't hear back from him by 20121031, I'll go ahead and close this.

@edburns said:
No response regarding JSR299 TCK breakage, closing.

File: 763-mods.zip
Attached By: @edburns

This issue was imported from java.net JIRA JAVASERVERFACES_SPEC_PUBLIC-763

Marked as fixed on Wednesday, October 31st 2012, 9:36:32 am