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 inclusion. 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 question. Best Regards, Madhav 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="http://www.springframework.org/schema/beans" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:osgi="http://www.springframework.org/schema/osgi" > xsi:schemaLocation=" > http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans.xsd > http://www.springframework.org/schema/osgi > http://www.springframework.org/schema/osgi/spring-osgi.xsd"> > > <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: http://camel.465427.n5.nabble.com/Proper-method-of-looking-up-osgi-service-from-camel-component-tp3402863p3403037.html Sent from the Camel - Users mailing list archive at Nabble.com.