camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joakim Bjørnstad <joak...@gmail.com>
Subject Re: Dynamic datasource with Camel 2.15.x
Date Tue, 06 Oct 2015 12:10:00 GMT
Well now this isn't a Camel question but rather a Spring one.

Anyways, I suggest checking out Spring @Value annotation and
PropertyPlaceholderConfigurer. With this you can leverage Camel's
BridgePropertyPlaceholderConfigurer to configure your routes as well.

http://camel.apache.org/using-propertyplaceholder.html

Spring Boot has some nice documentation on how to do externalized
config: http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

And no, you should not do it like the latter.

On Tue, Oct 6, 2015 at 11:38 AM, burner
<bjoernpaulsen1980@googlemail.com> wrote:
> Hello Joakim,
>
> yes, I am use Spring.
>
> your Idea look good. But how can I use parameters in your solution?
>
> @Configuration
> public class InfrastructureConfig {
>
>     String username = "";
>     String password = "";
>     String url = "";
>
>     @Bean
>     public DataSource dataSource() {
>         String url = this.url;
>         BasicDataSource ds = new BasicDataSource();
>         ds.setDriverClassName("com.jdbc.DBDriver");
>         ds.setUsername(this.username);
>         ds.setPassword(this.password);
>         ds.setUrl(url);
>         return ds;
>     }
>
>     // getter and setter ....
>
> }
>
> I don't think this is possibile like this, or?
>
> ApplicationContextRegistry registry =
> getContext().getRegistry(ApplicationContextRegistry.class);
> DataSource dataSource = registry.lookup("dataSource", DataSource.class);
> dataSource.setUrl("XYZ");
> dataSource.setUsername("XYZ");
> dataSource.setUPassword("XYZ");
>
> ?dataSource=#myDataSource
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Dynamic-datasource-with-Camel-2-15-x-tp5772178p5772328.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Kind regards
Joakim Bjørnstad

Mime
View raw message