You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "John D. Ament" <jo...@apache.org> on 2016/02/22 13:40:32 UTC

CDI Injection support

Hi all,

I was looking at the changes that went into Camel 2.17 with CDI injection
support.  It seems that injection support doesn't work consistently when
done not using an annotated member.

I tried a few different ways:

@Inject
@Any
private Instance<Endpoint> endpointInstance;

...

endpointInstance.select(MockEndpoint.class, new
UriLiteral("mock:outgoing")).get()

Which consistently gives back (in Weld 1.1.x, 2.x, OWB 1.2.x and OWB 1.6.x)
an error that no beans are defined, even though I have that endpoint
defined.

Now, if I try the CDI 1.1 way of using the utility class to look up the
instance, it works fine in Weld 2.x but not OWB 1.6.x.  As far as I know,
this setup should work in both, and since I know I use pattern in other
apps I don't think its a case of a bug in the impl.  I was wondering if any
camel gurus could comment on it?

https://github.com/johnament/camel/commit/05dd5f6f8cda541fedfc68c6f199e014defe3f09

John

Re: CDI Injection support

Posted by Antonin Stefanutti <an...@stefanutti.fr>.
Hi John,

Thanks for the info. I didn’t see you created CAMEL-9630.

Antonin

> On 24 Feb 2016, at 01:20, John D. Ament <jo...@gmail.com> wrote:
> 
> Hi Antonin,
> 
> Looks like you pushed up already what I was working on (when I found this
> issue): https://issues.apache.org/jira/browse/CAMEL-9630
> I'll move that over to you.
> 
> Thanks!
> 
> John
> 
> On Tue, Feb 23, 2016 at 9:00 AM Antonin Stefanutti <an...@stefanutti.fr>
> wrote:
> 
>> Hi John,
>> 
>> For #1, I’ve just pushed [1] to improve the support for programmatic
>> lookup of Camel resources.
>> 
>> For #2, I’ve opened issue OWB-1122 [2] in OpenWebBeans JIRA.
>> 
>> At that occasion, I've refactored a bit the qualifier literals for
>> @ContextName and @Uri in order to match the style of those that will be
>> provided in CDI 2.0 [3].
>> 
>> [1]:
>> https://github.com/apache/camel/commit/93631c85f4250b3843a7ada987c99aeed909a11d
>> [2]: https://issues.apache.org/jira/browse/OWB-1122
>> [3]: https://issues.jboss.org/browse/CDI-485
>> 
>> Do not hesitate if you any have other points.
>> 
>> Thanks,
>> Antonin
>> 
>>> On 22 Feb 2016, at 17:44, Antonin Stefanutti <an...@stefanutti.fr>
>> wrote:
>>> 
>>> It returns the qualifiers for the Instance injection point declaration,
>> not the ones added with select programmatically! I’ve tested it with OWB
>> version 1.6.2.
>>> 
>>> Weld returns the complete set of qualifiers as opposed to OWB.
>>> 
>>>> On 22 Feb 2016, at 17:36, John D. Ament <jo...@apache.org> wrote:
>>>> 
>>>> Hi Antonin!
>>>> 
>>>> For #2, that's weird.  What do you see in the output?
>>>> 
>>>> John
>>>> On Feb 22, 2016 11:24, "Antonin Stefanutti" <an...@stefanutti.fr>
>> wrote:
>>>> 
>>>>> Hi John,
>>>>> 
>>>>> Good to hear from you here! Thanks for the thorough testing, that’s a
>> good
>>>>> catch.
>>>>> 
>>>>> So I’ve looked into it and apparently the problem is two folds:
>>>>> - The implementations do not assume the @Any qualifier by default for
>>>>> programmatic lookup as they do for static injection.
>>>>> - OpenWebBeans does not return the correct set of refined qualifiers
>> when
>>>>> calling InjectionPoint.getQualifiers in producer methods for Instance
>> with
>>>>> selected qualifiers.
>>>>> 
>>>>> I have a fix for the former. I’ll polish it a bit and commit it ASAP.
>> For
>>>>> the later, I’ll report an issue in OWB JIRA and reactivate the test
>> case
>>>>> once it gets fixed.
>>>>> 
>>>>> Antonin
>>>>> 
>>>>>> On 22 Feb 2016, at 13:40, John D. Ament <jo...@apache.org>
>> wrote:
>>>>>> 
>>>>>> Hi all,
>>>>>> 
>>>>>> I was looking at the changes that went into Camel 2.17 with CDI
>> injection
>>>>>> support.  It seems that injection support doesn't work consistently
>> when
>>>>>> done not using an annotated member.
>>>>>> 
>>>>>> I tried a few different ways:
>>>>>> 
>>>>>> @Inject
>>>>>> @Any
>>>>>> private Instance<Endpoint> endpointInstance;
>>>>>> 
>>>>>> ...
>>>>>> 
>>>>>> endpointInstance.select(MockEndpoint.class, new
>>>>>> UriLiteral("mock:outgoing")).get()
>>>>>> 
>>>>>> Which consistently gives back (in Weld 1.1.x, 2.x, OWB 1.2.x and OWB
>>>>> 1.6.x)
>>>>>> an error that no beans are defined, even though I have that endpoint
>>>>>> defined.
>>>>>> 
>>>>>> Now, if I try the CDI 1.1 way of using the utility class to look up
>> the
>>>>>> instance, it works fine in Weld 2.x but not OWB 1.6.x.  As far as I
>> know,
>>>>>> this setup should work in both, and since I know I use pattern in
>> other
>>>>>> apps I don't think its a case of a bug in the impl.  I was wondering
>> if
>>>>> any
>>>>>> camel gurus could comment on it?
>>>>>> 
>>>>>> 
>>>>> 
>> https://github.com/johnament/camel/commit/05dd5f6f8cda541fedfc68c6f199e014defe3f09
>>>>>> 
>>>>>> John
>>>>> 
>>>>> 
>>> 
>> 
>> 


Re: CDI Injection support

Posted by "John D. Ament" <jo...@gmail.com>.
Hi Antonin,

Looks like you pushed up already what I was working on (when I found this
issue): https://issues.apache.org/jira/browse/CAMEL-9630
I'll move that over to you.

Thanks!

John

On Tue, Feb 23, 2016 at 9:00 AM Antonin Stefanutti <an...@stefanutti.fr>
wrote:

> Hi John,
>
> For #1, I’ve just pushed [1] to improve the support for programmatic
> lookup of Camel resources.
>
> For #2, I’ve opened issue OWB-1122 [2] in OpenWebBeans JIRA.
>
> At that occasion, I've refactored a bit the qualifier literals for
> @ContextName and @Uri in order to match the style of those that will be
> provided in CDI 2.0 [3].
>
> [1]:
> https://github.com/apache/camel/commit/93631c85f4250b3843a7ada987c99aeed909a11d
> [2]: https://issues.apache.org/jira/browse/OWB-1122
> [3]: https://issues.jboss.org/browse/CDI-485
>
> Do not hesitate if you any have other points.
>
> Thanks,
> Antonin
>
> > On 22 Feb 2016, at 17:44, Antonin Stefanutti <an...@stefanutti.fr>
> wrote:
> >
> > It returns the qualifiers for the Instance injection point declaration,
> not the ones added with select programmatically! I’ve tested it with OWB
> version 1.6.2.
> >
> > Weld returns the complete set of qualifiers as opposed to OWB.
> >
> >> On 22 Feb 2016, at 17:36, John D. Ament <jo...@apache.org> wrote:
> >>
> >> Hi Antonin!
> >>
> >> For #2, that's weird.  What do you see in the output?
> >>
> >> John
> >> On Feb 22, 2016 11:24, "Antonin Stefanutti" <an...@stefanutti.fr>
> wrote:
> >>
> >>> Hi John,
> >>>
> >>> Good to hear from you here! Thanks for the thorough testing, that’s a
> good
> >>> catch.
> >>>
> >>> So I’ve looked into it and apparently the problem is two folds:
> >>> - The implementations do not assume the @Any qualifier by default for
> >>> programmatic lookup as they do for static injection.
> >>> - OpenWebBeans does not return the correct set of refined qualifiers
> when
> >>> calling InjectionPoint.getQualifiers in producer methods for Instance
> with
> >>> selected qualifiers.
> >>>
> >>> I have a fix for the former. I’ll polish it a bit and commit it ASAP.
> For
> >>> the later, I’ll report an issue in OWB JIRA and reactivate the test
> case
> >>> once it gets fixed.
> >>>
> >>> Antonin
> >>>
> >>>> On 22 Feb 2016, at 13:40, John D. Ament <jo...@apache.org>
> wrote:
> >>>>
> >>>> Hi all,
> >>>>
> >>>> I was looking at the changes that went into Camel 2.17 with CDI
> injection
> >>>> support.  It seems that injection support doesn't work consistently
> when
> >>>> done not using an annotated member.
> >>>>
> >>>> I tried a few different ways:
> >>>>
> >>>> @Inject
> >>>> @Any
> >>>> private Instance<Endpoint> endpointInstance;
> >>>>
> >>>> ...
> >>>>
> >>>> endpointInstance.select(MockEndpoint.class, new
> >>>> UriLiteral("mock:outgoing")).get()
> >>>>
> >>>> Which consistently gives back (in Weld 1.1.x, 2.x, OWB 1.2.x and OWB
> >>> 1.6.x)
> >>>> an error that no beans are defined, even though I have that endpoint
> >>>> defined.
> >>>>
> >>>> Now, if I try the CDI 1.1 way of using the utility class to look up
> the
> >>>> instance, it works fine in Weld 2.x but not OWB 1.6.x.  As far as I
> know,
> >>>> this setup should work in both, and since I know I use pattern in
> other
> >>>> apps I don't think its a case of a bug in the impl.  I was wondering
> if
> >>> any
> >>>> camel gurus could comment on it?
> >>>>
> >>>>
> >>>
> https://github.com/johnament/camel/commit/05dd5f6f8cda541fedfc68c6f199e014defe3f09
> >>>>
> >>>> John
> >>>
> >>>
> >
>
>

Re: CDI Injection support

Posted by Antonin Stefanutti <an...@stefanutti.fr>.
Hi John,

For #1, I’ve just pushed [1] to improve the support for programmatic lookup of Camel resources.

For #2, I’ve opened issue OWB-1122 [2] in OpenWebBeans JIRA.

At that occasion, I've refactored a bit the qualifier literals for @ContextName and @Uri in order to match the style of those that will be provided in CDI 2.0 [3].

[1]: https://github.com/apache/camel/commit/93631c85f4250b3843a7ada987c99aeed909a11d
[2]: https://issues.apache.org/jira/browse/OWB-1122
[3]: https://issues.jboss.org/browse/CDI-485

Do not hesitate if you any have other points.

Thanks,
Antonin

> On 22 Feb 2016, at 17:44, Antonin Stefanutti <an...@stefanutti.fr> wrote:
> 
> It returns the qualifiers for the Instance injection point declaration, not the ones added with select programmatically! I’ve tested it with OWB version 1.6.2.
> 
> Weld returns the complete set of qualifiers as opposed to OWB.
> 
>> On 22 Feb 2016, at 17:36, John D. Ament <jo...@apache.org> wrote:
>> 
>> Hi Antonin!
>> 
>> For #2, that's weird.  What do you see in the output?
>> 
>> John
>> On Feb 22, 2016 11:24, "Antonin Stefanutti" <an...@stefanutti.fr> wrote:
>> 
>>> Hi John,
>>> 
>>> Good to hear from you here! Thanks for the thorough testing, that’s a good
>>> catch.
>>> 
>>> So I’ve looked into it and apparently the problem is two folds:
>>> - The implementations do not assume the @Any qualifier by default for
>>> programmatic lookup as they do for static injection.
>>> - OpenWebBeans does not return the correct set of refined qualifiers when
>>> calling InjectionPoint.getQualifiers in producer methods for Instance with
>>> selected qualifiers.
>>> 
>>> I have a fix for the former. I’ll polish it a bit and commit it ASAP. For
>>> the later, I’ll report an issue in OWB JIRA and reactivate the test case
>>> once it gets fixed.
>>> 
>>> Antonin
>>> 
>>>> On 22 Feb 2016, at 13:40, John D. Ament <jo...@apache.org> wrote:
>>>> 
>>>> Hi all,
>>>> 
>>>> I was looking at the changes that went into Camel 2.17 with CDI injection
>>>> support.  It seems that injection support doesn't work consistently when
>>>> done not using an annotated member.
>>>> 
>>>> I tried a few different ways:
>>>> 
>>>> @Inject
>>>> @Any
>>>> private Instance<Endpoint> endpointInstance;
>>>> 
>>>> ...
>>>> 
>>>> endpointInstance.select(MockEndpoint.class, new
>>>> UriLiteral("mock:outgoing")).get()
>>>> 
>>>> Which consistently gives back (in Weld 1.1.x, 2.x, OWB 1.2.x and OWB
>>> 1.6.x)
>>>> an error that no beans are defined, even though I have that endpoint
>>>> defined.
>>>> 
>>>> Now, if I try the CDI 1.1 way of using the utility class to look up the
>>>> instance, it works fine in Weld 2.x but not OWB 1.6.x.  As far as I know,
>>>> this setup should work in both, and since I know I use pattern in other
>>>> apps I don't think its a case of a bug in the impl.  I was wondering if
>>> any
>>>> camel gurus could comment on it?
>>>> 
>>>> 
>>> https://github.com/johnament/camel/commit/05dd5f6f8cda541fedfc68c6f199e014defe3f09
>>>> 
>>>> John
>>> 
>>> 
> 


Re: CDI Injection support

Posted by Antonin Stefanutti <an...@stefanutti.fr>.
It returns the qualifiers for the Instance injection point declaration, not the ones added with select programmatically! I’ve tested it with OWB version 1.6.2.

Weld returns the complete set of qualifiers as opposed to OWB.

> On 22 Feb 2016, at 17:36, John D. Ament <jo...@apache.org> wrote:
> 
> Hi Antonin!
> 
> For #2, that's weird.  What do you see in the output?
> 
> John
> On Feb 22, 2016 11:24, "Antonin Stefanutti" <an...@stefanutti.fr> wrote:
> 
>> Hi John,
>> 
>> Good to hear from you here! Thanks for the thorough testing, that’s a good
>> catch.
>> 
>> So I’ve looked into it and apparently the problem is two folds:
>> - The implementations do not assume the @Any qualifier by default for
>> programmatic lookup as they do for static injection.
>> - OpenWebBeans does not return the correct set of refined qualifiers when
>> calling InjectionPoint.getQualifiers in producer methods for Instance with
>> selected qualifiers.
>> 
>> I have a fix for the former. I’ll polish it a bit and commit it ASAP. For
>> the later, I’ll report an issue in OWB JIRA and reactivate the test case
>> once it gets fixed.
>> 
>> Antonin
>> 
>>> On 22 Feb 2016, at 13:40, John D. Ament <jo...@apache.org> wrote:
>>> 
>>> Hi all,
>>> 
>>> I was looking at the changes that went into Camel 2.17 with CDI injection
>>> support.  It seems that injection support doesn't work consistently when
>>> done not using an annotated member.
>>> 
>>> I tried a few different ways:
>>> 
>>> @Inject
>>> @Any
>>> private Instance<Endpoint> endpointInstance;
>>> 
>>> ...
>>> 
>>> endpointInstance.select(MockEndpoint.class, new
>>> UriLiteral("mock:outgoing")).get()
>>> 
>>> Which consistently gives back (in Weld 1.1.x, 2.x, OWB 1.2.x and OWB
>> 1.6.x)
>>> an error that no beans are defined, even though I have that endpoint
>>> defined.
>>> 
>>> Now, if I try the CDI 1.1 way of using the utility class to look up the
>>> instance, it works fine in Weld 2.x but not OWB 1.6.x.  As far as I know,
>>> this setup should work in both, and since I know I use pattern in other
>>> apps I don't think its a case of a bug in the impl.  I was wondering if
>> any
>>> camel gurus could comment on it?
>>> 
>>> 
>> https://github.com/johnament/camel/commit/05dd5f6f8cda541fedfc68c6f199e014defe3f09
>>> 
>>> John
>> 
>> 


Re: CDI Injection support

Posted by "John D. Ament" <jo...@apache.org>.
Hi Antonin!

For #2, that's weird.  What do you see in the output?

John
On Feb 22, 2016 11:24, "Antonin Stefanutti" <an...@stefanutti.fr> wrote:

> Hi John,
>
> Good to hear from you here! Thanks for the thorough testing, that’s a good
> catch.
>
> So I’ve looked into it and apparently the problem is two folds:
> - The implementations do not assume the @Any qualifier by default for
> programmatic lookup as they do for static injection.
> - OpenWebBeans does not return the correct set of refined qualifiers when
> calling InjectionPoint.getQualifiers in producer methods for Instance with
> selected qualifiers.
>
> I have a fix for the former. I’ll polish it a bit and commit it ASAP. For
> the later, I’ll report an issue in OWB JIRA and reactivate the test case
> once it gets fixed.
>
> Antonin
>
> > On 22 Feb 2016, at 13:40, John D. Ament <jo...@apache.org> wrote:
> >
> > Hi all,
> >
> > I was looking at the changes that went into Camel 2.17 with CDI injection
> > support.  It seems that injection support doesn't work consistently when
> > done not using an annotated member.
> >
> > I tried a few different ways:
> >
> > @Inject
> > @Any
> > private Instance<Endpoint> endpointInstance;
> >
> > ...
> >
> > endpointInstance.select(MockEndpoint.class, new
> > UriLiteral("mock:outgoing")).get()
> >
> > Which consistently gives back (in Weld 1.1.x, 2.x, OWB 1.2.x and OWB
> 1.6.x)
> > an error that no beans are defined, even though I have that endpoint
> > defined.
> >
> > Now, if I try the CDI 1.1 way of using the utility class to look up the
> > instance, it works fine in Weld 2.x but not OWB 1.6.x.  As far as I know,
> > this setup should work in both, and since I know I use pattern in other
> > apps I don't think its a case of a bug in the impl.  I was wondering if
> any
> > camel gurus could comment on it?
> >
> >
> https://github.com/johnament/camel/commit/05dd5f6f8cda541fedfc68c6f199e014defe3f09
> >
> > John
>
>

Re: CDI Injection support

Posted by Antonin Stefanutti <an...@stefanutti.fr>.
Hi John,

Good to hear from you here! Thanks for the thorough testing, that’s a good catch.

So I’ve looked into it and apparently the problem is two folds:
- The implementations do not assume the @Any qualifier by default for programmatic lookup as they do for static injection.
- OpenWebBeans does not return the correct set of refined qualifiers when calling InjectionPoint.getQualifiers in producer methods for Instance with selected qualifiers.

I have a fix for the former. I’ll polish it a bit and commit it ASAP. For the later, I’ll report an issue in OWB JIRA and reactivate the test case once it gets fixed.

Antonin

> On 22 Feb 2016, at 13:40, John D. Ament <jo...@apache.org> wrote:
> 
> Hi all,
> 
> I was looking at the changes that went into Camel 2.17 with CDI injection
> support.  It seems that injection support doesn't work consistently when
> done not using an annotated member.
> 
> I tried a few different ways:
> 
> @Inject
> @Any
> private Instance<Endpoint> endpointInstance;
> 
> ...
> 
> endpointInstance.select(MockEndpoint.class, new
> UriLiteral("mock:outgoing")).get()
> 
> Which consistently gives back (in Weld 1.1.x, 2.x, OWB 1.2.x and OWB 1.6.x)
> an error that no beans are defined, even though I have that endpoint
> defined.
> 
> Now, if I try the CDI 1.1 way of using the utility class to look up the
> instance, it works fine in Weld 2.x but not OWB 1.6.x.  As far as I know,
> this setup should work in both, and since I know I use pattern in other
> apps I don't think its a case of a bug in the impl.  I was wondering if any
> camel gurus could comment on it?
> 
> https://github.com/johnament/camel/commit/05dd5f6f8cda541fedfc68c6f199e014defe3f09
> 
> John