camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Soto <alex.s...@envieta.com>
Subject Re: Custom data format, OSGi, Blueprint, Rest DSL, Bundle is waiting for dependencies
Date Tue, 12 Mar 2019 17:43:16 GMT
I have solved this problem by adding file: 

	/META-INF/services/org/apache/camel/dataformat/JacksonDFWithDynamicViews

With content:

	class=org.xx.JacksonDFWithDynamicViews

Camel will find and register the Data Schema, but there is a caveat. The bundle needs to have
visibility of package “org.apache.camel.spi”. Found this by looking in Camel “org.apache.camel.impl.osgi.Activator”
class, which has this:


 protected void registerDataFormats(Bundle bundle, List<BaseService> resolvers) {
        if (canSee(bundle, DataFormat.class)) {

In my case, it was not working, because my custom Data Format is extending JacksonDataFormat,
the bundle did not import package “org.apache.camel.spi”, so Camel was ignoring it.  Forcing
the bundle to import “org.apache.camel.spi”. Since I am using BND, I added:

Import-Package: \
	org.apache.camel.spi, \
	*

And now the Data Format is properly registered.



Best regards,
Alex soto




> On Mar 12, 2019, at 10:44 AM, Alex Soto <alex.soto@envieta.com> wrote:
> 
> Hello,
> 
> I am trying to use a custom Data Format with Camel Rest DSL in an OSGi container (Karaf)
but the bundle fails to initialize with error:
> 
> 
> Bundle XXXX is waiting for dependencies [(&(dataformat=JacksonDFWithDynamicViews)(objectClass=org.apache.camel.spi.DataFormatResolver))]
> 
> 
> I am instantiating the data format class as a Blueprint bean:
> 
> 
>     <bean id="jacksonDF" class="org.xx.JacksonDFWithDynamicViews"/>
> 
> 
> Then, in my Camel Context I register the custom data format:
> 
>       <dataFormats>
> 	    <custom ref="jacksonDF" id="JacksonDFWithDynamicViews"/>
>       </dataFormats>
> 
> Which I then reference in the Rest DSL configuration:
> 
> <restConfiguration 
> 	component="servlet"
> 	bindingMode="json"
> 	jsonDataFormat="JacksonDFWithDynamicViews"
> 	contextPath="{{context.path}}{{api.root.path}}" 
> 	port="{{port}}"
> 	enableCORS="false">
> 
> 
> 
> Any idea of what is going on here?
> 
> Best regards,
> Alex soto
> 
> 
> 
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message