users@jax-rs-spec.java.net

[jax-rs-spec users] Re: Proposal: Make CDI constructor injection mandatory

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Mon, 20 Feb 2017 10:45:27 +0100

Hi Gunner,

thanks for your input.

Similar issue is on my list. The problem with constructor injection is
that JAX-RS also mandates special selection of the constructor, see
chapter 3.1.2.

If we would state something like: "When resources are managed by other
injection framework, it's up to the framework to select proper constructor."

When we do that, it should be easier to remove optional constructor
injection rule in 10.2.7.

We want to push the EDR rather sooner than later, so adding this to my
"3.1.2" task in my TODO list for now.

Thanks and regards,
Pavel


On 17/02/2017 20:17, Gunnar Morling wrote:
> Hi,
>
> When using CDI beans as REST-ful resources, the JAX-RS 2.0 spec only
> mandates field and property injection, whereas constructor injection
> is optional (section 10.2.7).
>
> I'd like to propose to make support for constructor injection
> mandatory in JAX-RS 2.1. I was quite surprised when I learned about
> this limitation (I first thought it'd be a bug in our container
> implementation), and I think others may find it unexpected, too. Also
> there are good reasons for preferring constructor injection (e.g.
> fields can be final), so support for it is desirable.
>
> Thanks a lot for your consideration,
>
> --Gunnar