users@servlet-spec.java.net

[servlet-spec users] Re: [jsr369-experts] Re: Re: [116-CDIRelatedBeansInServletSpec] PROPOSAL

From: arjan tijms <arjan.tijms_at_gmail.com>
Date: Fri, 21 Nov 2014 09:21:45 +0100

Hi

On Fri, Nov 21, 2014 at 4:06 AM, Greg Wilkins <gregw_at_intalio.com> wrote:
>> More over, I'm concerned that by making CDI to servlet mapping a
> responsibility of the servlet container, then we are going to have to do a
> container to CDI adaptation for every CDI implementation out there.

That should really not be a concern. The producers in question are CDI
Bean implementations, which are in the public API and are registered
using a portable extension using only public APIs.

In JSF 2.3 we're using the exact same mechanism, and there's no need
for any CDI implementation specific code.

An example of the portable extension doing the registration:
https://github.com/svn2github/mojarra/blob/master/trunk/jsf-ri/src/main/java/com/sun/faces/FacesCDIExtension.java
An example of a producer (Bean instance):
https://github.com/svn2github/mojarra/blob/master/trunk/jsf-api/src/main/java/javax/faces/context/ExternalContextProducer.java

Two more examples in a user library (OmniFaces):

Extension: https://github.com/omnifaces/omnifaces/blob/master/src/main/java/org/omnifaces/cdi/param/ParamExtension.java
Producer: https://github.com/omnifaces/omnifaces/blob/master/src/main/java/org/omnifaces/cdi/param/DynamicParamValueProducer.java

I explained the concept in some more detail here:
http://jdevelopment.nl/dynamic-cdi-producers

As you can see, there's no really no need for any implementation
specific code anywhere. It all uses the CDI public APIs.

Kind regards,
Arjan