rejimathews commented on issue #814: Can camel-k accept camel context definition? URL: https://github.com/apache/camel-k/issues/814#issuecomment-513854621 > Yeah works only in camel 3 as it has a writable registry Thanks !! Something like this worked for me. Thanks @WillemJiang for the clue! import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.CompositeRegistry; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.impl.SimpleRegistry; import org.apache.commons.dbcp.BasicDataSource; public class EmbeddedRoute extends RouteBuilder { @Override public void configure() throws Exception { SimpleRegistry simpleRegistry = new SimpleRegistry(); BasicDataSource mysqlDataSource = new BasicDataSource(); mysqlDataSource.setUrl("jdbc:mysql://10.213.96.182/roma"); mysqlDataSource.setUsername("********"); mysqlDataSource.setPassword("***********"); mysqlDataSource.setDriverClassName("com.mysql.jdbc.Driver"); CamelContext camelContext = getContext(); CompositeRegistry compositeRegistry = getCompositeRegistry(); compositeRegistry.addRegistry(getContext().getRegistry()); compositeRegistry.addRegistry(simpleRegistry); ((DefaultCamelContext)camelContext).setRegistry(compositeRegistry); simpleRegistry.put("mysqlDataSource", mysqlDataSource); } private CompositeRegistry getCompositeRegistry() { CompositeRegistry registry = new CompositeRegistry(); return registry; } }
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
