You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Sergey Beryozkin <sb...@gmail.com> on 2014/02/09 19:43:25 UTC

Optional support for CDI integration ?

Hi All,
Does it make sense to offer some optional support for CDI directly in 
CXF ? I guess we can expect more and more queries about it going forward,

I'll want to investigate more about it in scope of the JAX-RS 2.0 spec 
work anyway, but I wonder what can be done in CXF in general

Thanks, Sergey

Re: Optional support for CDI integration ?

Posted by Andrey Redko <dr...@gmail.com>.
Hi Sergey,

That sounds exactly what I have in mind and,  following Christian's
comment, we may attach to existing CDI context if available and never
create one.
Thanks.

Best Regards,
    Andriy Redko


On Tue, Feb 11, 2014 at 6:17 AM, Sergey Beryozkin <sb...@gmail.com>wrote:

> Hi Andriy
>
> On 10/02/14 17:53, Andrey Redko wrote:
>
>> Hi guys,
>>
>> I have done some work trying to make CXF and CDI (Weld 2.x) working
>> together and though I failed to make it work, I have got the approximate
>> understanding how it might be implemented.
>>  From my prospective, to get basic @Inject working won't be very hard. The
>> one assumption I have is that we don't have objection to use JNDI as it is
>> the (one of) way to share BeanManager instance.
>> Or we may look on Weld SE to see the possible alternatives to create and
>> share BeanManager instance in non-JEE environments so we can have similar
>> implementation in CXF.
>> Thanks.
>>
>>  I wonder, as far as the basic @Inject is concerned, can we just add Weld
> and may be DeltaSpike. And then somehow load the CDI context from
> CXFNonSpringServlet extension (ex, CXFCdiServlet), similarly to the way
> CXFServlet, which is Spring aware, loads the Spring context...
>
> Looking for the cheapest/fastest way to do it :-)
> Cheers, Sergey
>
>
>  Best Regards,
>>      Andriy Redko
>>
>>
>> On Mon, Feb 10, 2014 at 11:50 AM, Sergey Beryozkin <sberyozkin@gmail.com
>> >wrote:
>>
>>  Hi Christian
>>>
>>> On 10/02/14 16:01, Christian Schneider wrote:
>>>
>>>  Hi Sergey,
>>>>
>>>> CDI support could be quite interesting indeed. I already started
>>>> experimenting with it too.
>>>> See:
>>>> https://github.com/cschneider/Karaf-Tutorial/tree/master/
>>>> tasklist-cdi/tasklist-webservice/src/main/java/net/lr/cxf/cdi
>>>>
>>>>
>>>> I think we have to create a portable CDI extension like the ones in
>>>> apache deltaspike:
>>>> http://deltaspike.apache.org/documentation.html#module-overview
>>>> In my experiments I even used a less advanced aproach and just created a
>>>> custom annotation that is processed by cdi. This is probably not enough
>>>> for good support though.
>>>>
>>>> So I propose we first experiment in some directions and then try to work
>>>> out a first design.
>>>>
>>>>   That looks interesting; if we talk about the two options Andrei
>>>>
>>> mentioned, I guess you'd like to follow the first one, i.e, have a pretty
>>> comprehensive support, right ?
>>> I wonder, what can we do to get a basic @Inject (ion) of CDI beans into
>>> CXF service classes working ? That would do for a start for me :-)
>>>
>>> DeltaSpike looks interesting; I wonder if one can delegate to it in Java
>>> SE...for it to inject the beans
>>>
>>> Cheers, Sergey
>>>
>>>
>>>
>>>  Christian
>>>>
>>>>
>>>> On 09.02.2014 19:43, Sergey Beryozkin wrote:
>>>>
>>>>  Hi All,
>>>>> Does it make sense to offer some optional support for CDI directly in
>>>>> CXF ? I guess we can expect more and more queries about it going
>>>>> forward,
>>>>>
>>>>> I'll want to investigate more about it in scope of the JAX-RS 2.0 spec
>>>>> work anyway, but I wonder what can be done in CXF in general
>>>>>
>>>>> Thanks, Sergey
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>

Re: Optional support for CDI integration ?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Andriy
On 10/02/14 17:53, Andrey Redko wrote:
> Hi guys,
>
> I have done some work trying to make CXF and CDI (Weld 2.x) working
> together and though I failed to make it work, I have got the approximate
> understanding how it might be implemented.
>  From my prospective, to get basic @Inject working won't be very hard. The
> one assumption I have is that we don't have objection to use JNDI as it is
> the (one of) way to share BeanManager instance.
> Or we may look on Weld SE to see the possible alternatives to create and
> share BeanManager instance in non-JEE environments so we can have similar
> implementation in CXF.
> Thanks.
>
I wonder, as far as the basic @Inject is concerned, can we just add Weld 
and may be DeltaSpike. And then somehow load the CDI context from 
CXFNonSpringServlet extension (ex, CXFCdiServlet), similarly to the way 
CXFServlet, which is Spring aware, loads the Spring context...

Looking for the cheapest/fastest way to do it :-)
Cheers, Sergey

> Best Regards,
>      Andriy Redko
>
>
> On Mon, Feb 10, 2014 at 11:50 AM, Sergey Beryozkin <sb...@gmail.com>wrote:
>
>> Hi Christian
>>
>> On 10/02/14 16:01, Christian Schneider wrote:
>>
>>> Hi Sergey,
>>>
>>> CDI support could be quite interesting indeed. I already started
>>> experimenting with it too.
>>> See:
>>> https://github.com/cschneider/Karaf-Tutorial/tree/master/
>>> tasklist-cdi/tasklist-webservice/src/main/java/net/lr/cxf/cdi
>>>
>>>
>>> I think we have to create a portable CDI extension like the ones in
>>> apache deltaspike:
>>> http://deltaspike.apache.org/documentation.html#module-overview
>>> In my experiments I even used a less advanced aproach and just created a
>>> custom annotation that is processed by cdi. This is probably not enough
>>> for good support though.
>>>
>>> So I propose we first experiment in some directions and then try to work
>>> out a first design.
>>>
>>>   That looks interesting; if we talk about the two options Andrei
>> mentioned, I guess you'd like to follow the first one, i.e, have a pretty
>> comprehensive support, right ?
>> I wonder, what can we do to get a basic @Inject (ion) of CDI beans into
>> CXF service classes working ? That would do for a start for me :-)
>>
>> DeltaSpike looks interesting; I wonder if one can delegate to it in Java
>> SE...for it to inject the beans
>>
>> Cheers, Sergey
>>
>>
>>
>>> Christian
>>>
>>>
>>> On 09.02.2014 19:43, Sergey Beryozkin wrote:
>>>
>>>> Hi All,
>>>> Does it make sense to offer some optional support for CDI directly in
>>>> CXF ? I guess we can expect more and more queries about it going forward,
>>>>
>>>> I'll want to investigate more about it in scope of the JAX-RS 2.0 spec
>>>> work anyway, but I wonder what can be done in CXF in general
>>>>
>>>> Thanks, Sergey
>>>>
>>>
>>>
>>>
>>
>

Re: Optional support for CDI integration ?

Posted by Andrey Redko <dr...@gmail.com>.
Hi guys,

I have done some work trying to make CXF and CDI (Weld 2.x) working
together and though I failed to make it work, I have got the approximate
understanding how it might be implemented.
>From my prospective, to get basic @Inject working won't be very hard. The
one assumption I have is that we don't have objection to use JNDI as it is
the (one of) way to share BeanManager instance.
Or we may look on Weld SE to see the possible alternatives to create and
share BeanManager instance in non-JEE environments so we can have similar
implementation in CXF.
Thanks.

Best Regards,
    Andriy Redko


On Mon, Feb 10, 2014 at 11:50 AM, Sergey Beryozkin <sb...@gmail.com>wrote:

> Hi Christian
>
> On 10/02/14 16:01, Christian Schneider wrote:
>
>> Hi Sergey,
>>
>> CDI support could be quite interesting indeed. I already started
>> experimenting with it too.
>> See:
>> https://github.com/cschneider/Karaf-Tutorial/tree/master/
>> tasklist-cdi/tasklist-webservice/src/main/java/net/lr/cxf/cdi
>>
>>
>> I think we have to create a portable CDI extension like the ones in
>> apache deltaspike:
>> http://deltaspike.apache.org/documentation.html#module-overview
>> In my experiments I even used a less advanced aproach and just created a
>> custom annotation that is processed by cdi. This is probably not enough
>> for good support though.
>>
>> So I propose we first experiment in some directions and then try to work
>> out a first design.
>>
>>  That looks interesting; if we talk about the two options Andrei
> mentioned, I guess you'd like to follow the first one, i.e, have a pretty
> comprehensive support, right ?
> I wonder, what can we do to get a basic @Inject (ion) of CDI beans into
> CXF service classes working ? That would do for a start for me :-)
>
> DeltaSpike looks interesting; I wonder if one can delegate to it in Java
> SE...for it to inject the beans
>
> Cheers, Sergey
>
>
>
>> Christian
>>
>>
>> On 09.02.2014 19:43, Sergey Beryozkin wrote:
>>
>>> Hi All,
>>> Does it make sense to offer some optional support for CDI directly in
>>> CXF ? I guess we can expect more and more queries about it going forward,
>>>
>>> I'll want to investigate more about it in scope of the JAX-RS 2.0 spec
>>> work anyway, but I wonder what can be done in CXF in general
>>>
>>> Thanks, Sergey
>>>
>>
>>
>>
>

Re: Optional support for CDI integration ?

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 10/02/14 19:33, Christian Schneider wrote:
> On 10.02.2014 17:50, Sergey Beryozkin wrote:
>> That looks interesting; if we talk about the two options Andrei
>> mentioned, I guess you'd like to follow the first one, i.e, have a
>> pretty comprehensive support, right ?
>> I wonder, what can we do to get a basic @Inject (ion) of CDI beans
>> into CXF service classes working ? That would do for a start for me :-)
>>
> Not really. I think we should not try to recreate CDI for cxf. Instead
> we should attach CXF into a real CDI context using a portable extension.
> Not really sure though how to do this. I mentioned deltaspike as they
> offer such extensions. So we probably need to create something similar.
>
> What I would like to avoid though is that CDI reaches into every cxf
> module like it is the case for spring and blueprint.
> If we assume we have about 20 cxf modules with extensions for blueprint
> and spring this means we already have 40 "adapters".
>
> If we add 3 more frameworks like this there will be 100 "adapters". So I
> think we rather need to find a less intrusive way to integrate cxf into
> additional frameworks. One such way would be to rely more on standard
> java classes for configuration and use annotations and xml namespaces
> rather sparsely.
>
Right, I was not really going ahead with the specific proposal to update 
all the modules and such again to support CDI. We have the namespace 
support for Blueprint & Spring and it does help the users which is 
important, but I agree, lets try to find a less intrusive way of doing 
the basic CDI injection working, you are right.

This is what I meant: what can we do to get a basic @Inject (ion) of CDI 
beans into CXF service classes working. I'd like to propose to tackle a 
basic issue as POC, have a WS or RS service instance injected with some 
other bean (via @Inject)...

Thanks, Sergey

> Christian
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: Optional support for CDI integration ?

Posted by Christian Schneider <ch...@die-schneider.net>.
On 10.02.2014 17:50, Sergey Beryozkin wrote:
> That looks interesting; if we talk about the two options Andrei 
> mentioned, I guess you'd like to follow the first one, i.e, have a 
> pretty comprehensive support, right ?
> I wonder, what can we do to get a basic @Inject (ion) of CDI beans 
> into CXF service classes working ? That would do for a start for me :-)
>
Not really. I think we should not try to recreate CDI for cxf. Instead 
we should attach CXF into a real CDI context using a portable extension.
Not really sure though how to do this. I mentioned deltaspike as they 
offer such extensions. So we probably need to create something similar.

What I would like to avoid though is that CDI reaches into every cxf 
module like it is the case for spring and blueprint.
If we assume we have about 20 cxf modules with extensions for blueprint 
and spring this means we already have 40 "adapters".

If we add 3 more frameworks like this there will be 100 "adapters". So I 
think we rather need to find a less intrusive way to integrate cxf into 
additional frameworks. One such way would be to rely more on standard 
java classes for configuration and use annotations and xml namespaces 
rather sparsely.

Christian


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Re: Optional support for CDI integration ?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Christian
On 10/02/14 16:01, Christian Schneider wrote:
> Hi Sergey,
>
> CDI support could be quite interesting indeed. I already started
> experimenting with it too.
> See:
> https://github.com/cschneider/Karaf-Tutorial/tree/master/tasklist-cdi/tasklist-webservice/src/main/java/net/lr/cxf/cdi
>
>
> I think we have to create a portable CDI extension like the ones in
> apache deltaspike:
> http://deltaspike.apache.org/documentation.html#module-overview
> In my experiments I even used a less advanced aproach and just created a
> custom annotation that is processed by cdi. This is probably not enough
> for good support though.
>
> So I propose we first experiment in some directions and then try to work
> out a first design.
>
That looks interesting; if we talk about the two options Andrei 
mentioned, I guess you'd like to follow the first one, i.e, have a 
pretty comprehensive support, right ?
I wonder, what can we do to get a basic @Inject (ion) of CDI beans into 
CXF service classes working ? That would do for a start for me :-)

DeltaSpike looks interesting; I wonder if one can delegate to it in Java 
SE...for it to inject the beans

Cheers, Sergey

>
> Christian
>
>
> On 09.02.2014 19:43, Sergey Beryozkin wrote:
>> Hi All,
>> Does it make sense to offer some optional support for CDI directly in
>> CXF ? I guess we can expect more and more queries about it going forward,
>>
>> I'll want to investigate more about it in scope of the JAX-RS 2.0 spec
>> work anyway, but I wonder what can be done in CXF in general
>>
>> Thanks, Sergey
>
>


Re: Optional support for CDI integration ?

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Sergey,

CDI support could be quite interesting indeed. I already started 
experimenting with it too.
See: 
https://github.com/cschneider/Karaf-Tutorial/tree/master/tasklist-cdi/tasklist-webservice/src/main/java/net/lr/cxf/cdi

I think we have to create a portable CDI extension like the ones in 
apache deltaspike: 
http://deltaspike.apache.org/documentation.html#module-overview
In my experiments I even used a less advanced aproach and just created a 
custom annotation that is processed by cdi. This is probably not enough 
for good support though.

So I propose we first experiment in some directions and then try to work 
out a first design.


Christian


On 09.02.2014 19:43, Sergey Beryozkin wrote:
> Hi All,
> Does it make sense to offer some optional support for CDI directly in 
> CXF ? I guess we can expect more and more queries about it going forward,
>
> I'll want to investigate more about it in scope of the JAX-RS 2.0 spec 
> work anyway, but I wonder what can be done in CXF in general
>
> Thanks, Sergey


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Re: Optional support for CDI integration ?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Alessio
On 10/02/14 13:28, Alessio Soldano wrote:
> Sergey,
> I haven't look at the details and I'm not an expert of CDI at all, but
> my gut feeling is that any additional support of CDI injection directly
> by CXF could possibly clash with similar features already available in
> containers integrating CXF and targetting full JavaEE compliance. So, if
> an additional CDI support is being added, it should probably be possible
> to turn it off (though a configuration option, or such).
> Just my 2cents

+1; I think it can be interesting for people working with say Karaf or 
standalone Tomcat and Jetty containers, I'd consider introducing an 
optional module specifically dedicated to some basic CDI bridging, so 
that it does not interfere in any way with the containers doing CDI, 
such as JBoss, TomEE, GlassFish, etc

Thanks, Sergey

>
> Alessio
>
> On 10/02/14 13:23, Sergey Beryozkin wrote:
>> Hi Andrei
>> On 10/02/14 08:49, Andrei Shakirin wrote:
>>> Hi Sergei,
>>>
>>> Do you mean the full support of JSR-299 including stereotypes,
>>> qualifiers, alternatives or just support of @Inject annotation for
>>> some CXF security, message, context objects?
>>> The first seems to be a bit involved, however the second sounds
>>> reasonable for me.
>>>
>> Yes I agree, I think we should let the containers deal with most of
>> it, but limit it to supporting @Inject.
>>
>> In fact, I'd probably consider supporting it initially at the level
>> shown at
>>
>> https://github.com/abhijitsarkar/groovy/blob/master/movie-manager/movie-manager-web/src/main/groovy/name/abhijitsarkar/moviemanager/web/MovieResource.groovy
>>
>>
>> (The same will apply for JAX-WS).
>>
>> The link above shows what JAX-RS 2.0 spec expects too from
>> CDI-compliant implementations. The spec also mentions that @Inject may
>> be supported for injecting JAX-RS annotated properties (example,
>> instead of @Context UriInfo -> @Inject UriInfo) but should warn about
>> the non-portability - I'd be OK with Tom EE supporting all of it
>> (meaning the injection of contexts too) for JAX-WS/JAX-RS, but I guess
>> it is up for the discussion.
>>
>> I wonder, if some basic/straight-forward link can be supported in CXF
>> to support the injection of beans into service classes via @Inject so
>> that people can just add CDI RI dep and have it working ?
>>
>> Thanks, Sergey
>>
>>
>>
>>
>>
>>
>>
>>> Regards,
>>> Andrei.
>>>
>>>> -----Original Message-----
>>>> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
>>>> Sent: Sonntag, 9. Februar 2014 19:43
>>>> To: CXF Dev
>>>> Subject: Optional support for CDI integration ?
>>>>
>>>> Hi All,
>>>> Does it make sense to offer some optional support for CDI directly
>>>> in CXF ? I
>>>> guess we can expect more and more queries about it going forward,
>>>>
>>>> I'll want to investigate more about it in scope of the JAX-RS 2.0
>>>> spec work
>>>> anyway, but I wonder what can be done in CXF in general
>>>>
>>>> Thanks, Sergey
>>
>>
>
>


Re: Optional support for CDI integration ?

Posted by Alessio Soldano <as...@redhat.com>.
Sergey,
I haven't look at the details and I'm not an expert of CDI at all, but 
my gut feeling is that any additional support of CDI injection directly 
by CXF could possibly clash with similar features already available in 
containers integrating CXF and targetting full JavaEE compliance. So, if 
an additional CDI support is being added, it should probably be possible 
to turn it off (though a configuration option, or such).
Just my 2cents

Alessio

On 10/02/14 13:23, Sergey Beryozkin wrote:
> Hi Andrei
> On 10/02/14 08:49, Andrei Shakirin wrote:
>> Hi Sergei,
>>
>> Do you mean the full support of JSR-299 including stereotypes, 
>> qualifiers, alternatives or just support of @Inject annotation for 
>> some CXF security, message, context objects?
>> The first seems to be a bit involved, however the second sounds 
>> reasonable for me.
>>
> Yes I agree, I think we should let the containers deal with most of 
> it, but limit it to supporting @Inject.
>
> In fact, I'd probably consider supporting it initially at the level 
> shown at
>
> https://github.com/abhijitsarkar/groovy/blob/master/movie-manager/movie-manager-web/src/main/groovy/name/abhijitsarkar/moviemanager/web/MovieResource.groovy 
>
>
> (The same will apply for JAX-WS).
>
> The link above shows what JAX-RS 2.0 spec expects too from 
> CDI-compliant implementations. The spec also mentions that @Inject may 
> be supported for injecting JAX-RS annotated properties (example, 
> instead of @Context UriInfo -> @Inject UriInfo) but should warn about 
> the non-portability - I'd be OK with Tom EE supporting all of it 
> (meaning the injection of contexts too) for JAX-WS/JAX-RS, but I guess 
> it is up for the discussion.
>
> I wonder, if some basic/straight-forward link can be supported in CXF 
> to support the injection of beans into service classes via @Inject so 
> that people can just add CDI RI dep and have it working ?
>
> Thanks, Sergey
>
>
>
>
>
>
>
>> Regards,
>> Andrei.
>>
>>> -----Original Message-----
>>> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
>>> Sent: Sonntag, 9. Februar 2014 19:43
>>> To: CXF Dev
>>> Subject: Optional support for CDI integration ?
>>>
>>> Hi All,
>>> Does it make sense to offer some optional support for CDI directly 
>>> in CXF ? I
>>> guess we can expect more and more queries about it going forward,
>>>
>>> I'll want to investigate more about it in scope of the JAX-RS 2.0 
>>> spec work
>>> anyway, but I wonder what can be done in CXF in general
>>>
>>> Thanks, Sergey
>
>


-- 
Alessio Soldano
Web Service Lead, JBoss


Re: Optional support for CDI integration ?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Andrei
On 10/02/14 08:49, Andrei Shakirin wrote:
> Hi Sergei,
>
> Do you mean the full support of JSR-299 including stereotypes, qualifiers, alternatives or just support of @Inject annotation for some CXF security, message, context objects?
> The first seems to be a bit involved, however the second sounds reasonable for me.
>
Yes I agree, I think we should let the containers deal with most of it, 
but limit it to supporting @Inject.

In fact, I'd probably consider supporting it initially at the level shown at

https://github.com/abhijitsarkar/groovy/blob/master/movie-manager/movie-manager-web/src/main/groovy/name/abhijitsarkar/moviemanager/web/MovieResource.groovy

(The same will apply for JAX-WS).

The link above shows what JAX-RS 2.0 spec expects too from CDI-compliant 
implementations. The spec also mentions that @Inject may be supported 
for injecting JAX-RS annotated properties (example, instead of @Context 
UriInfo -> @Inject UriInfo) but should warn about the non-portability - 
I'd be OK with Tom EE supporting all of it (meaning the injection of 
contexts too) for JAX-WS/JAX-RS, but I guess it is up for the discussion.

I wonder, if some basic/straight-forward link can be supported in CXF to 
support the injection of beans into service classes via @Inject so that 
people can just add CDI RI dep and have it working ?

Thanks, Sergey







> Regards,
> Andrei.
>
>> -----Original Message-----
>> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
>> Sent: Sonntag, 9. Februar 2014 19:43
>> To: CXF Dev
>> Subject: Optional support for CDI integration ?
>>
>> Hi All,
>> Does it make sense to offer some optional support for CDI directly in CXF ? I
>> guess we can expect more and more queries about it going forward,
>>
>> I'll want to investigate more about it in scope of the JAX-RS 2.0 spec work
>> anyway, but I wonder what can be done in CXF in general
>>
>> Thanks, Sergey


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

RE: Optional support for CDI integration ?

Posted by Andrei Shakirin <as...@talend.com>.
Hi Sergei,

Do you mean the full support of JSR-299 including stereotypes, qualifiers, alternatives or just support of @Inject annotation for some CXF security, message, context objects?
The first seems to be a bit involved, however the second sounds reasonable for me.

Regards,
Andrei.

> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Sonntag, 9. Februar 2014 19:43
> To: CXF Dev
> Subject: Optional support for CDI integration ?
> 
> Hi All,
> Does it make sense to offer some optional support for CDI directly in CXF ? I
> guess we can expect more and more queries about it going forward,
> 
> I'll want to investigate more about it in scope of the JAX-RS 2.0 spec work
> anyway, but I wonder what can be done in CXF in general
> 
> Thanks, Sergey