7.5. Using context scanning
You can allow Camel to scan the container context, for example, the Spring ApplicationContext for route builder instances. This allows you to use the Spring <component-scan> feature and have Camel pickup any RouteBuilder instances which was created by Spring in its scan process.
<!-- enable Spring @Component scan -->
<context:component-scan base-package="org.apache.camel.spring.issues.contextscan"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- and then let Camel use those @Component scanned route builders -->
<contextScan/>
</camelContext>
This allows you to just annotate your routes using the Spring @Component and have those routes included by Camel:
@Component
public class MyRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:start")
.to("mock:result");
}
}
You can also use the ANT style for inclusion and exclusion, as mentioned above in the package scan section.