You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by Charlie Mordant <cm...@gmail.com> on 2014/01/12 15:16:49 UTC

Injecting Pax-CDI beans into blueprint bean declaration

Hi!

I'm trying to create a CXF-RS server based on a Pax-CDI bean.

This bean is necessarily a CDI one because I'm using Hibernate Validator
CDI extension to validate it:
@Named
@Path ("/")
public class MyBean {
@POST
@Consumes(XML)
public void addSomething(@Valid Something something) {/*do stuff*/}
}}

I was used to declare my RS services server in the blueprint file:

<jaxrs:server id="beanServiceCXF" address="/beanService">

<jaxrs:serviceBeans>

 <ref component-id="myBean" />

 </jaxrs:serviceBeans>

 <jaxrs:providers>

 <ref component-id="jaxbProvider" />

 <ref component-id="jsonProvider" />

 <bean id="validationException"

  class="helpers.cxf.exception.handling.jaxrs.mapper.ExceptionXmlMapper" />

 </jaxrs:providers>

</jaxrs:server>

<cxf:bus>

 <cxf:features>

 <cxf:logging />

 </cxf:features>

</cxf:bus>


Unfortunately, I'm not able to inject this CDI Bean as a blueprint
reference (a workaround could be to export this CDI bean as an OSGI service
and reference it on another bundle that exposes the web service but it's a
little overengineered): is there a way to do this? for example accessing to
the bundle Blueprint component registry and adding this CDI bean?


Thank you in advance,

Charlie

Re: Injecting Pax-CDI beans into blueprint bean declaration

Posted by Charlie Mordant <cm...@gmail.com>.
Hi,
No, I didn't tried (but for sure I will!).
I thought my bundle won't start after all BP beans are resolved, so I
thought I can't publish a nested/internal OSGIService.

Thank you,


2014/1/12 Jean-Baptiste Onofré <jb...@nanthrax.net>

> Hi Charlie,
>
> Did you try to create a kind of wrapper CDI bean, expose it as a service
> (using <service/>) and use it in a nested RS bean ?
>
> Regards
> JB
>
>
> On 01/12/2014 03:16 PM, Charlie Mordant wrote:
>
>> Hi!
>>
>> I'm trying to create a CXF-RS server based on a Pax-CDI bean.
>>
>> This bean is necessarily a CDI one because I'm using Hibernate Validator
>> CDI extension to validate it:
>> @Named
>> @Path ("/")
>> public class MyBean {
>> @POST
>> @Consumes(XML)
>> public void addSomething(@Valid Something something) {/*do stuff*/}
>> }}
>>
>> I was used to declare my RS services server in the blueprint file:
>>
>> <jaxrs:serverid="beanServiceCXF"address="/beanService">
>>
>> <jaxrs:serviceBeans>
>>
>> <refcomponent-id="myBean"/>
>>
>>
>> </jaxrs:serviceBeans>
>>
>> <jaxrs:providers>
>>
>> <refcomponent-id="jaxbProvider"/>
>>
>> <refcomponent-id="jsonProvider"/>
>>
>> <beanid="validationException"
>>
>>
>> class="helpers.cxf.exception.handling.jaxrs.mapper.ExceptionXmlMapper"/>
>>
>> </jaxrs:providers>
>>
>> </jaxrs:server>
>>
>> <cxf:bus>
>>
>> <cxf:features>
>>
>> <cxf:logging/>
>>
>> </cxf:features>
>>
>> </cxf:bus>
>>
>>
>>
>> Unfortunately, I'm not able to inject this CDI Bean as a blueprint
>> reference (a workaround could be to export this CDI bean as an OSGI
>> service and reference it on another bundle that exposes the web service
>> but it's a little overengineered): is there a way to do this? for
>> example accessing to the bundle Blueprint component registry and adding
>> this CDI bean?
>>
>>
>> Thank you in advance,
>>
>> Charlie
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>



-- 
Cordialement,

Charlie Mordant

Re: Injecting Pax-CDI beans into blueprint bean declaration

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Charlie,

Did you try to create a kind of wrapper CDI bean, expose it as a service 
(using <service/>) and use it in a nested RS bean ?

Regards
JB

On 01/12/2014 03:16 PM, Charlie Mordant wrote:
> Hi!
>
> I'm trying to create a CXF-RS server based on a Pax-CDI bean.
>
> This bean is necessarily a CDI one because I'm using Hibernate Validator
> CDI extension to validate it:
> @Named
> @Path ("/")
> public class MyBean {
> @POST
> @Consumes(XML)
> public void addSomething(@Valid Something something) {/*do stuff*/}
> }}
>
> I was used to declare my RS services server in the blueprint file:
>
> <jaxrs:serverid="beanServiceCXF"address="/beanService">
>
> <jaxrs:serviceBeans>
>
> <refcomponent-id="myBean"/>
>
> </jaxrs:serviceBeans>
>
> <jaxrs:providers>
>
> <refcomponent-id="jaxbProvider"/>
>
> <refcomponent-id="jsonProvider"/>
>
> <beanid="validationException"
>
> class="helpers.cxf.exception.handling.jaxrs.mapper.ExceptionXmlMapper"/>
>
> </jaxrs:providers>
>
> </jaxrs:server>
>
> <cxf:bus>
>
> <cxf:features>
>
> <cxf:logging/>
>
> </cxf:features>
>
> </cxf:bus>
>
>
>
> Unfortunately, I'm not able to inject this CDI Bean as a blueprint
> reference (a workaround could be to export this CDI bean as an OSGI
> service and reference it on another bundle that exposes the web service
> but it's a little overengineered): is there a way to do this? for
> example accessing to the bundle Blueprint component registry and adding
> this CDI bean?
>
>
> Thank you in advance,
>
> Charlie
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com