in core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java [100:158]
public static CamelContext doConfigureCamelContext(ApplicationContext applicationContext,
CamelContext camelContext,
CamelConfigurationProperties config) throws Exception {
// setup startup recorder before building context
configureStartupRecorder(camelContext, config);
camelContext.build();
// initialize properties component eager
PropertiesComponent pc = applicationContext.getBeanProvider(PropertiesComponent.class).getIfAvailable();
if (pc != null) {
pc.setCamelContext(camelContext);
camelContext.setPropertiesComponent(pc);
}
final Map<String, BeanRepository> repositories = applicationContext.getBeansOfType(BeanRepository.class);
if (!repositories.isEmpty()) {
List<BeanRepository> reps = new ArrayList<>();
// include default bean repository as well
reps.add(new ApplicationContextBeanRepository(applicationContext));
// and then any custom
reps.addAll(repositories.values());
// sort by ordered
OrderComparator.sort(reps);
// and plugin as new registry
camelContext.getCamelContextExtension().setRegistry(new DefaultRegistry(reps));
}
if (ObjectHelper.isNotEmpty(config.getFileConfigurations())) {
Environment env = applicationContext.getEnvironment();
if (env instanceof ConfigurableEnvironment) {
MutablePropertySources sources = ((ConfigurableEnvironment) env).getPropertySources();
if (!sources.contains("camel-file-configuration")) {
sources.addFirst(new FilePropertySource("camel-file-configuration", applicationContext, config.getFileConfigurations()));
}
}
}
// setup cli connector eager
configureCliConnector(applicationContext, camelContext);
camelContext.getCamelContextExtension().addContextPlugin(PackageScanClassResolver.class, new FatJarPackageScanClassResolver());
camelContext.getCamelContextExtension().addContextPlugin(PackageScanResourceResolver.class, new FatJarPackageScanResourceResolver());
if (config.getRouteFilterIncludePattern() != null || config.getRouteFilterExcludePattern() != null) {
LOG.info("Route filtering pattern: include={}, exclude={}", config.getRouteFilterIncludePattern(), config.getRouteFilterExcludePattern());
camelContext.getCamelContextExtension().getContextPlugin(Model.class).setRouteFilterPattern(config.getRouteFilterIncludePattern(), config.getRouteFilterExcludePattern());
}
// configure the common/default options
DefaultConfigurationConfigurer.configure(camelContext, config);
// lookup and configure SPI beans
DefaultConfigurationConfigurer.afterConfigure(camelContext);
// and call after all properties are set
DefaultConfigurationConfigurer.afterPropertiesSet(camelContext);
return camelContext;
}