1.2.6. 自定义 Camel 上下文配置
如果要在 CamelContext bean 上由 Camel 自动配置创建的一些操作,请在 Spring 上下文中注册 CamelContextConfiguration 实例:
@Configuration
public class MyAppConfig {
@Bean
CamelContextConfiguration contextConfiguration() {
return new CamelContextConfiguration() {
@Override
void beforeApplicationStart(CamelContext context) {
// your custom configuration goes here
}
};
}
}
在启动 Spring 上下文 之前,ApplicationStart 的方法才会被调用,因此传递给这个回调的 CamelContext 实例完全自动配置。如果在 Spring 上下文中添加多个 CamelContextConfiguration 实例,则执行每个实例。