1.3.4. 自定义 Camel 上下文配置
如果要在 CamelContextan 中对 CamelContext an 执行一些操作,请在 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 实例将被完全自动配置。如果将多个 CamelContextConfiguration 实例添加到 Spring 上下文,则会执行每个实例。