THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Note that this library is totally optional; you could just wire Camel together yourself with Java Config.
...
Common cases
The most common case of using JavaConfig with Camel would be to create configuration with defined list of routes to be used by router.
Code Block | ||||
---|---|---|---|---|
| ||||
@Configuration
public class MyRouteConfiguration extends CamelConfiguration {
@Autowire
private MyRouteBuilder myRouteBuilder;
@Autowire
private MyAnotherRouteBuilder myAnotherRouteBuilder;
@Override
public List<RouteBuilder> routes() {
return Arrays.asList(myRouteBuilder, myAnotherRouteBuilder);
}
}
|
Starting from Camel 2.13.0 you can skip the routes() definition, and fall back to the RouteBuilder instances located in the Spring context.
Code Block | ||||
---|---|---|---|---|
| ||||
@Configuration
@ComponentScan("com.example.routes")
public class MyRouteConfiguration extends CamelConfiguration {
}
|
Other examples
The following example using Java Config is actually a Spring Testing based unit test.
...