users@hk2.java.net

Re: AbstractBinder#addActiveDescriptor vs AbstractBinder#bind for Custom Injection Resolver

From: buko <buko_at_chiubarobot.com>
Date: Wed, 14 Aug 2013 11:57:00 -0400

Can you suggest a short term work around? I imagine to some extent I may
need to duplicate a lot of the addActiveDescriptor work and then plugin the
right classloader...
 On Aug 14, 2013 7:01 AM, "John Wells" <john.wells_at_oracle.com> wrote:

> Actually, I don't think the proper classloader to add is either the
> system nor the loader of the AbstractBinder. Instead I think in the
> classloader attached should be associated with the class itself (it should
> be using the classloader of the given class). I will look into making this
> change, but since this is kind of a big change I'll have to make sure it
> doesn't break something else.
>
> On 8/13/2013 8:38 PM, buko wrote:
>
> Any news on this?
>
> To clarify the question, is it possible to use addActiveDescriptor but
> also make sure the ClassLoader that ends up on the SystemDescriptor is the
> same ClassLoader used to load the AbstractBinder?
>
>
> On Fri, Aug 9, 2013 at 1:35 AM, buko <buko_at_chiubarobot.com> wrote:
>
>> This seems to be due to classloading issues.
>>
>> Using (2) creates a SystemDescriptor with a HK2Loader that uses the same
>> underlying ClassLoader as the AbstractBinder. This ClassLoader can see the
>> custom annotation type. Using (1) creates a SystemDescriptor with no
>> Hk2Loader that seems to be using the system classloader (I think). That
>> Hk2Loader can't see the annotation and so custom injection doesn't happen.
>>
>> This also seems to explain the issue with knownInjectees being empty.
>>
>>
>> On Fri, Aug 9, 2013 at 12:42 AM, buko <buko_at_chiubarobot.com> wrote:
>>
>>> Not sure if this is expected behavior or not but I've noticed that:
>>>
>>> (1) addActiveDescriptor(UserForm.class);
>>>
>>> In an AbstractBinder will *not* do annotation-based custom injection
>>> resolution. The field is left null and the known injectees is empty.
>>>
>>> But:
>>>
>>> (2)
>>> bind(TestForm.class).to(TestForm.class).in(PerLookup.class).qualifiedBy(new
>>> Annotation() {
>>>
>>> @Override
>>> public Class<? extends Annotation> annotationType() {
>>> return Bindable.class;
>>> }
>>> });
>>>
>>> Does do custom injection resolution.
>>>
>>> Is this right? I'd prefer to use (1) for binding stuff since the
>>> qualified syntax is quite annoying but does addActiveDescriptor somehow not
>>> detect/check for all annotations on it, particularly those custom injection
>>> resolvers might be interested in?
>>>
>>
>>
>
>