users@hk2.java.net

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

From: buko <buko_at_chiubarobot.com>
Date: Tue, 13 Aug 2013 20:38:29 -0400

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?
>>
>
>