users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Re: Dynamic Binding Example

From: Jan Algermissen <jan.algermissen_at_nordsc.com>
Date: Wed, 7 Nov 2012 12:06:00 +0100

On Nov 7, 2012, at 11:28 AM, Marek Potociar <marek.potociar_at_oracle.com> wrote:

>
> On Nov 5, 2012, at 7:08 PM, Bill Burke <bburke_at_redhat.com> wrote:
>
>>
>>
>> On 11/4/2012 3:27 PM, Marek Potociar wrote:
>>>
>>> On Nov 3, 2012, at 3:11 PM, Jan Algermissen <jan.algermissen_at_nordsc.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> in 6.5.3 in the dynamic binding example there is the line
>>>>
>>>> configurable.register(new LoggingFilter());
>>>>
>>>>
>>>> I find it a bit odd that on the one hand, the runtime usually (set aside other DI scopes) will instantiate one instance for every provider. On the other hand, for dynamic binding new instances seem to have to be created.
>>>
>>> I wonder where did you get the assumption that "for dynamic binding new instances seem to have to be created"? That's simply not true. Check the Configurable (renamed to Configuration recently) API.


The docs below is what I looked at and it caused the impression that the runtime should instantiate (for that registration() call) a dedicated instance. IOW, that there will be a single instance for each call or at least for each configurable.


Jan

"Configurable register(Class<?> providerClass)
Register a provider or a feature class to be instantiated and used in the scope of the configurable instance. The registered class is registered as a provider of all the recognized JAX-RS or implementation-specific extension contracts including Feature contract.
As opposed to the instances registered via register(Object) method, classes registered using this method are instantiated and properly injected by the JAX-RS implementation provider. In case of a conflict between a registered feature and/or provider instance and instantiated registered class, the registered instance takes precedence and the registered class will not be instantiated in such case.
"