camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From unmarshall <>
Subject Re: Proper method of looking up osgi service from camel component
Date Mon, 28 Feb 2011 10:15:00 GMT
Hi Willem,

Thanks for your response. I am aware of this approach as Cxf follows the
same approach. The problem is that i have defined a custom XML extension
representing the component the same way Cxf does (<cxf:cxfEndpoint>)

Now I can have a XML which will have just this osgi:reference and ask the
user to include this resource using <beans:import>

The reason which stopped me from this approach:
I do not quite like the idea of having the onus on the user of the component
to set the property with an osgi reference. It should be automatically
injected as it is an internal implementation aspect which should not be
exposed to the user.

In case of Cxf it is fine as the user only needs to include the required xml
resource files from META-INF/* directories. The user does not have to inject
anything into the cxf endpoint bean definition as a result of this resource

The upside of this approach is that the code is decoupled from the osgi API,
but there is a down side as well and that is the reason i asked this

Best Regards,

Willem.Jiang wrote:
> Hi,
> Here is another way to help your custom camel component not be polluted 
> by OSGi APIs.
> If you custom camel component has the dependency of the OSGi service, 
> you just need to create a get/set method of that services interface in 
> your custom component.
> Then you can inject the services into the camel component by use the 
> spring DM like this. and your camel component doesn't need to get touch 
> with any of the OSGi API like this.
> <beans xmlns=""
>         xmlns:xsi=""
>         xmlns:osgi=""
>         xsi:schemaLocation="
>      <bean id="custom"
>            class="com.example.CustomerCamelComponent">
>          <property name="Services" ref="myServices"/>
>      </bean>
>      <osgi:reference id="myServices"
>                      interface="com.example.osgi.Services" />
>      <!-- you can add your camel route here -->
> </beans>
> Willem

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message