Actually, I hope that support for arbitrary @Context-based injection is going to be removed soon. A standard JSR330 @Inject should be used in those cases instead.
One reason for the removal is that JAX-RS is very specific about what can be injected via @Context as well as it mandates proxiability of the @Context-injected components. Another reason is that long-term I'd like us to move from the "JAX-RS proprietary" @Context based injection towards the generally accepted standard DI/CDI @Inject based model.
Marek
On Jan 31, 2013, at 6:06 PM, Pavel Bucek <pavel.bucek_at_oracle.com> wrote:
> Depends on how you register it, you should be able to use @Context ...
>
> // request scope binding with specified custom annotation
> bindAsContract(MyInjectablePerRequest.class).qualifiedBy(new MyAnnotationImpl()).in(RequestScoped.class);
>
> Pavel
>
>
> On 1/31/13 6:02 PM, algermissen1971 wrote:
>> Hi Pavel,
>>
>> On 31.01.2013, at 09:51, Pavel Bucek <pavel.bucek_at_oracle.com> wrote:
>>
>>> See CustomInjectablesResourceConfigTest ; https://github.com/jersey/jersey/blob/master/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomInjectablesResourceConfigTest.java
>> I see you are using @Inject there. What I am looking for is a JAX-RS only injection, to not be dependent on other frameworks. (Not sure yet, what the target environment is capable of)
>>
>> Or will the registered class be available using @Context, too?
>>
>> Jan
>>
>>>
>>> On 1/31/13 9:47 AM, algermissen1971 wrote:
>>>> On 31.01.2013, at 09:32, algermissen1971 <algermissen1971_at_mac.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I am looking for a way to inject my own Singletons using @Context. In Jersey 1.x there was SingletonTypeInjectableProvider. But it seems 2.x dropped that.
>>>>>
>>>>> Or is that in a package that is not covered by the Jersey 2 API Docs and I need to look elsewhere?
>>>> Aha - I see you now use HK2. Then ... is there maybe an example describing how to write my own context providers based on Jersey's basics?
>>>>
>>>> Jan
>>>>
>>>>> Jan
>>>>
>>
>>
>