FAQ
Hi,

I helping friend of mine to setup Camel with Spring JavaConfig
project. What we would like to achieve is to create configuration
which scans the classpath and autowires the RouteBuilders into the
CamelContext. This is pretty common pattern for Spring 3.x
JavaConfig-based applications. In the existing version of JavaConfig
component I needed to autowire the RouteBuilders into collection and
then pass it to the overridden CamelConfiguration#routes() [1] method.

@Configuration
@ComponentScan("com.example.app")
public class ApplicationConfiguration extends CamelConfiguration {

     @Autowired
     private List<RouteBuilder> routes;

     @Override
     public List<RouteBuilder> routes() {
         return routes;
     }

}

As I like the convention of configuration approach and because this
kind of autowiring is pretty common pattern for Spring 3.x
JavaConfig-based applications I changed [2]
CamelConfiguration#routes() definition from abstract to default one
returning all the RouteBuilders reigstered in the Spring
ApplicationContext. This way the existing code overriding the
CamelConfiguration#routes() method will still work as before, however
now you may relay on the classpath scanning to do the job without the
boilerplate needed.

@Configuration
@ComponentScan("com.example.app")
public class ApplicationConfiguration extends CamelConfiguration {

   // No overridden routes() - autodetect RouteBuilders

}

I'll update the documentation to describe the new feature.

Cheers.

[1] http://camel.apache.org/maven/camel-2.12.0/camel-spring-javaconfig/apidocs/org/apache/camel/spring/javaconfig/CamelConfiguration.html
[2] 8a93ae7

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriescamel
postedOct 17, '13 at 9:07a
activeOct 17, '13 at 9:07a
posts1
users1
websitecamel.apache.org

1 user in discussion

Henryk Konsek: 1 post

People

Translate

site design / logo © 2018 Grokbase