camel-jdbc and osgi namingservice questions
sekaijin Mar 8, 2012 3:49 AMGood morning.
I use ServiceMix to deploy routes built dynamically.
on my platform I have defined lot of datasources.
they are not defined in the bundles containing my routes because they are shared by several bundles.
For bundles containing a road I use blueprint.
But my roads must be built dynamically, they can be written in xml.
So I spend a routeBuilder and I use the DSL camel to build them.
<blueprint xmlns="...">
<camelContext id="myContext" trace="false" xmlns="http://camel.apache.org/schema/blueprint">
<package>foo.my.package</package>
</camelContext>
</blueprint>
My RouteBuilders then read the parameters and construct a road.
public class MyRouteBuilder extends RouteBuilder
String inUrl;
String DataSourceName;
public RouteBuilder()
super();
inUrl = getParameter("input.url");
DataSourceName = getDataSourceNameFor("somme.info");
...
}
public void configure() {
RouteDefinition r = from(inUrl);
if ("sommeValue".equals(sommeParameter) {}
r.bean(MyBean.class);
...
r.to("jdbc:" + DataSourceName)
...
When a route needs a datasource, reading parameters gives the name of the datasource. So I can easily pass the url to the endpoint to define correctly the route.
but there is one thing I do not quite understand.
in the camel doc when using DSL to set an endpoint jdbc, it is written the datasource to be recorded in a JNDIregister.
the example code simply gives
JndiRegistry reg =super.createRegistry();
reg.bind("testdb", ds);
return reg;
but no information about a class you do that.
In an OSGI, a NamingService which are already registered my datasources.
Camel-jdbc he uses the NamingService of OSGI?
I need to set a JNDI register?
How to define it?
I can not find clear information about this subject.
Thank you for your help
A+JYT
PS: Sorry for my approximative english
Edited by: sekaijin on Mar 8, 2012 9:49 AM