users@jersey.java.net

Re: [Jersey] Appeal to jersey developers for better+reliable javax.inject/cdi/weld support

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 23 Apr 2010 12:17:06 +0200

On Apr 23, 2010, at 11:40 AM, Morten wrote:

> --- Den tors 22/4/10 skrev Paul Sandoz <Paul.Sandoz_at_Sun.COM>:
>> Because enabling CDI changes the programming model. It
>> means that adding a beans.xml may result in deployment
>> failure for existing JAX-RS code. So i took the conservative
>> approach of "keep on trucking" and your resource classes
>> will behave in exactly the same way unless you explicitly
>> declare otherwise.
>
> Ok. I can see you made the right choice to support existing code
> bases.
>
> But for new CDI projects, it complicate things and does not feel
> "natural". Maybe we should have a setting in web.xml
> "disable_jerseys_own_legacy_dependency_management=true"
> (note a tiny bit of personal bias in naming :-))
>

That option would be useful but note this is really about JAX-RS 1.1
conformance to support the JAX-RS 1.1 programming model in EE 6. And
we know there are certain cases that CDI cannot support, essentially
CDI restricts that programming model. So more accurately the setting
should be called "enable_jersey_cdi_programming_model". The fact that
Jersey has it's own DI mechanism as well is really an orthogonal
implementation detail that actually does not get in the way of
supporting such a CDI-based programming model. It should be possible
to support such a feature if the right CDI magic can be invoked.

If we had been thinking a little more about this in the EG we could
have specified something about this, but at the time it was damn hard
to realize these issues because there lacked a CDI implementation to
play with to understand the consequences (299 was a moving target).


>> The point about what i wrote above is it may not be totally
>> possible because CDI may not always be configured (no
>> beans.xml) and @ManagedBean is required to be supported by
>> JAX-RS in EE 6.
>
> I would actually propose to change Jesey to REQUIRE an external
> javax.inject or CDI capable implementation to work. So that a jersey
> project would not even compile unless weld, spring guice or
> something else is installed. Then this point would go away.
>

Yes, that could be an option. I would really @Inject support in in SE
7 with a Guice-like module and binding approach :-)

Paul.