users@jersey.java.net

[Jersey] Re: Injecting List<MediaType> via _at_Context

From: Martynas Jusevičius <martynas_at_graphity.org>
Date: Wed, 17 Jun 2015 00:52:02 +0200

Sorry I was talking about the 1.x version! Am I the last one using it?..

@Context seems to work there, I just wasn't sure how to inject Lists.
But I worked around it by having a wrapper class and it turned out
even better.

On Tue, Jun 16, 2015 at 9:34 PM, Marek Potociar
<marek.potociar_at_oracle.com> wrote:
> I’m not sure I know the definitive answer, but let me give you just a bit of a warning:
>
> @Context should be ONLY used to inject the JAX-RS API components explicitly stated in the JAX-RS spec (section 5.2 in JAX-RS 1.x and section 9.2 in JAX-RS 2.0) - injecting anything else, even if it may work today is essentially an API leak and should be avoided. Please use @Inject instead for arbitrary injection.
>
> Marek
>
>> On 11 Jun 2015, at 07:49, Martynas Jusevičius <martynas_at_graphity.org> wrote:
>>
>> Hey,
>>
>> is it possible to inject typed lists using @Context?
>>
>> I've implemented a custom provider that extends
>> PerRequestTypeInjectableProvider<Context, List<MediaType>>. I am not
>> sure however what to pass to its constructor. If I use List.class, the
>> provider is not picked up.
>>
>> Any thoughts? Thanks.
>>
>> Martynas
>