Hello Together,

i want to create dynamic datasources on runtime. I found some examples to do
this. But this code:

PropertyPlaceholderDelegateRegistry registry =
(PropertyPlaceholderDelegateRegistry) getContext().getRegistry();
JndiRegistry jndiRegistry = (JndiRegistry ) registry.getRegistry();
jndiRegistry.bind("myDS", ds);

don't work in Camel 2.15 anymore. I get a 
java.lang.ClassCastException:
org.apache.camel.spring.spi.ApplicationContextRegistry cannot be cast to
org.apache.camel.impl.JndiRegistry

Have any of you an idea how I can solve it?

I'm in a RouteBuilder:

RouteBuilder builder = new RouteBuilder() {
        public void configure() {
                CamelContext context = getContext();

                // I create the Datasource
                String url = "jdbc:PROT://localhost:PORT/NS";
                BasicDataSource ds = new BasicDataSource();
                ds.setDriverClassName("com.jdbc.DBDriver");
                ds.setUsername("USER");
                ds.setPassword("PASS");
                ds.setUrl(url);

                // Here I must register the DS, but how? This don't work:
                PropertyPlaceholderDelegateRegistry registry =
(PropertyPlaceholderDelegateRegistry) getContext().getRegistry();
                JndiRegistry jndiRegistry = (JndiRegistry ) 
registry.getRegistry();
                jndiRegistry.bind("myDataSource", ds);

                // Here I build my route
                from("direct:xyz")
                        .to("jdbc:myDataSource")
        }
}

Thank you for help



--
View this message in context: 
http://camel.465427.n5.nabble.com/Dynamic-datasource-with-Camel-2-15-x-tp5772178.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to