in core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java [124:363]
public static void configure(CamelContext camelContext, DefaultConfigurationProperties<?> config) throws Exception {
ExtendedCamelContext ecc = camelContext.getCamelContextExtension();
if (config.getStartupRecorder() != null) {
if ("false".equals(config.getStartupRecorder())) {
ecc.getStartupStepRecorder().setEnabled(false);
} else if ("logging".equals(config.getStartupRecorder())) {
if (!(ecc.getStartupStepRecorder() instanceof LoggingStartupStepRecorder)) {
ecc.setStartupStepRecorder(new LoggingStartupStepRecorder());
}
} else if ("backlog".equals(config.getStartupRecorder())) {
if (!(ecc.getStartupStepRecorder() instanceof BacklogStartupStepRecorder)) {
ecc.setStartupStepRecorder(new BacklogStartupStepRecorder());
}
} else if ("java-flight-recorder".equals(config.getStartupRecorder())) {
if (!ecc.getStartupStepRecorder().getClass().getName().startsWith("org.apache.camel.startup.jfr")) {
throw new IllegalArgumentException(
"Cannot find Camel Java Flight Recorder on classpath. Add camel-jfr to classpath.");
}
}
}
ecc.getStartupStepRecorder().setMaxDepth(config.getStartupRecorderMaxDepth());
ecc.getStartupStepRecorder().setRecording(config.isStartupRecorderRecording());
ecc.getStartupStepRecorder().setStartupRecorderDuration(config.getStartupRecorderDuration());
ecc.getStartupStepRecorder().setRecordingDir(config.getStartupRecorderDir());
ecc.getStartupStepRecorder().setRecordingProfile(config.getStartupRecorderProfile());
PluginHelper.getBeanPostProcessor(ecc).setEnabled(config.isBeanPostProcessorEnabled());
final BeanIntrospection beanIntrospection = PluginHelper.getBeanIntrospection(ecc);
beanIntrospection.setExtendedStatistics(config.isBeanIntrospectionExtendedStatistics());
if (config.getBeanIntrospectionLoggingLevel() != null) {
beanIntrospection.setLoggingLevel(config.getBeanIntrospectionLoggingLevel());
}
beanIntrospection.afterPropertiesConfigured(camelContext);
if ("pooled".equals(config.getExchangeFactory())) {
ecc.setExchangeFactory(new PooledExchangeFactory());
ecc.setProcessorExchangeFactory(new PooledProcessorExchangeFactory());
} else if ("prototype".equals(config.getExchangeFactory())) {
ecc.setExchangeFactory(new PrototypeExchangeFactory());
ecc.setProcessorExchangeFactory(new PrototypeProcessorExchangeFactory());
}
ecc.getExchangeFactory().setCapacity(config.getExchangeFactoryCapacity());
ecc.getProcessorExchangeFactory().setCapacity(config.getExchangeFactoryCapacity());
ecc.getExchangeFactory().setStatisticsEnabled(config.isExchangeFactoryStatisticsEnabled());
ecc.getProcessorExchangeFactory().setStatisticsEnabled(config.isExchangeFactoryStatisticsEnabled());
if (!config.isJmxEnabled()) {
camelContext.disableJMX();
}
if (config.getName() != null) {
ecc.setName(config.getName());
}
if (config.getDescription() != null) {
ecc.setDescription(config.getDescription());
}
if (config.getStartupSummaryLevel() != null) {
camelContext.setStartupSummaryLevel(config.getStartupSummaryLevel());
}
if (config.getShutdownTimeout() > 0) {
camelContext.getShutdownStrategy().setTimeout(config.getShutdownTimeout());
}
camelContext.getShutdownStrategy().setSuppressLoggingOnTimeout(config.isShutdownSuppressLoggingOnTimeout());
camelContext.getShutdownStrategy().setShutdownNowOnTimeout(config.isShutdownNowOnTimeout());
camelContext.getShutdownStrategy().setShutdownRoutesInReverseOrder(config.isShutdownRoutesInReverseOrder());
camelContext.getShutdownStrategy().setLogInflightExchangesOnTimeout(config.isShutdownLogInflightExchangesOnTimeout());
camelContext.getInflightRepository().setInflightBrowseEnabled(config.isInflightRepositoryBrowseEnabled());
if (config.getLogDebugMaxChars() != 0) {
camelContext.getGlobalOptions().put(Exchange.LOG_DEBUG_BODY_MAX_CHARS,
Integer.toString(config.getLogDebugMaxChars()));
}
// stream caching
camelContext.setStreamCaching(config.isStreamCachingEnabled());
camelContext.getStreamCachingStrategy().setAllowClasses(config.getStreamCachingAllowClasses());
camelContext.getStreamCachingStrategy().setDenyClasses(config.getStreamCachingDenyClasses());
camelContext.getStreamCachingStrategy().setSpoolEnabled(config.isStreamCachingSpoolEnabled());
camelContext.getStreamCachingStrategy().setAnySpoolRules(config.isStreamCachingAnySpoolRules());
camelContext.getStreamCachingStrategy().setBufferSize(config.getStreamCachingBufferSize());
camelContext.getStreamCachingStrategy()
.setRemoveSpoolDirectoryWhenStopping(config.isStreamCachingRemoveSpoolDirectoryWhenStopping());
camelContext.getStreamCachingStrategy().setSpoolCipher(config.getStreamCachingSpoolCipher());
if (config.getStreamCachingSpoolDirectory() != null) {
camelContext.getStreamCachingStrategy().setSpoolDirectory(config.getStreamCachingSpoolDirectory());
}
if (config.getStreamCachingSpoolThreshold() != 0) {
camelContext.getStreamCachingStrategy().setSpoolThreshold(config.getStreamCachingSpoolThreshold());
}
if (config.getStreamCachingSpoolUsedHeapMemoryLimit() != null) {
StreamCachingStrategy.SpoolUsedHeapMemoryLimit limit;
if ("Committed".equalsIgnoreCase(config.getStreamCachingSpoolUsedHeapMemoryLimit())) {
limit = StreamCachingStrategy.SpoolUsedHeapMemoryLimit.Committed;
} else if ("Max".equalsIgnoreCase(config.getStreamCachingSpoolUsedHeapMemoryLimit())) {
limit = StreamCachingStrategy.SpoolUsedHeapMemoryLimit.Max;
} else {
throw new IllegalArgumentException(
"Invalid option " + config.getStreamCachingSpoolUsedHeapMemoryLimit()
+ " must either be Committed or Max");
}
camelContext.getStreamCachingStrategy().setSpoolUsedHeapMemoryLimit(limit);
}
if (config.getStreamCachingSpoolUsedHeapMemoryThreshold() != 0) {
camelContext.getStreamCachingStrategy()
.setSpoolUsedHeapMemoryThreshold(config.getStreamCachingSpoolUsedHeapMemoryThreshold());
}
if ("default".equals(config.getUuidGenerator())) {
camelContext.setUuidGenerator(new DefaultUuidGenerator());
} else if ("short".equals(config.getUuidGenerator())) {
camelContext.setUuidGenerator(new ShortUuidGenerator());
} else if ("classic".equals(config.getUuidGenerator())) {
camelContext.setUuidGenerator(new ClassicUuidGenerator());
} else if ("simple".equals(config.getUuidGenerator())) {
camelContext.setUuidGenerator(new SimpleUuidGenerator());
} else if ("off".equals(config.getUuidGenerator())) {
camelContext.setUuidGenerator(new OffUuidGenerator());
LOG.warn("Using OffUuidGenerator (Only intended for development purposes)");
}
if (config.getLogName() != null) {
camelContext.getGlobalOptions().put(Exchange.LOG_EIP_NAME, config.getLogName());
}
if (config.getLogLanguage() != null) {
camelContext.getGlobalOptions().put(Exchange.LOG_EIP_LANGUAGE, config.getLogLanguage());
}
camelContext.setLogMask(config.isLogMask());
camelContext.setLogExhaustedMessageBody(config.isLogExhaustedMessageBody());
camelContext.setAutoStartup(config.isAutoStartup());
camelContext.setAutoStartupExcludePattern(config.getAutoStartupExcludePattern());
camelContext.setAllowUseOriginalMessage(config.isAllowUseOriginalMessage());
camelContext.setCaseInsensitiveHeaders(config.isCaseInsensitiveHeaders());
camelContext.setAutowiredEnabled(config.isAutowiredEnabled());
camelContext.setUseBreadcrumb(config.isUseBreadcrumb());
camelContext.setUseDataType(config.isUseDataType());
camelContext.setDumpRoutes(config.getDumpRoutes());
camelContext.setUseMDCLogging(config.isUseMdcLogging());
camelContext.setMDCLoggingKeysPattern(config.getMdcLoggingKeysPattern());
camelContext.setLoadTypeConverters(config.isLoadTypeConverters());
camelContext.setTypeConverterStatisticsEnabled(config.isTypeConverterStatisticsEnabled());
camelContext.setLoadHealthChecks(config.isLoadHealthChecks());
camelContext.setDevConsole(config.isDevConsoleEnabled());
camelContext.setModeline(config.isModeline());
if (config.isRoutesReloadEnabled()) {
RouteWatcherReloadStrategy reloader = new RouteWatcherReloadStrategy(
config.getRoutesReloadDirectory(), config.isRoutesReloadDirectoryRecursive());
reloader.setPattern(config.getRoutesReloadPattern());
reloader.setRemoveAllRoutes(config.isRoutesReloadRemoveAllRoutes());
camelContext.addService(reloader);
}
if (config.getDumpRoutes() != null) {
DumpRoutesStrategy drs = camelContext.getCamelContextExtension().getContextPlugin(DumpRoutesStrategy.class);
drs.setInclude(config.getDumpRoutesInclude());
drs.setLog(config.isDumpRoutesLog());
drs.setUriAsParameters(config.isDumpRoutesUriAsParameters());
drs.setGeneratedIds(config.isDumpRoutesGeneratedIds());
drs.setResolvePlaceholders(config.isDumpRoutesResolvePlaceholders());
drs.setOutput(config.getDumpRoutesOutput());
}
if (config.isContextReloadEnabled() && camelContext.hasService(ContextReloadStrategy.class) == null) {
ContextReloadStrategy reloader = new DefaultContextReloadStrategy();
camelContext.addService(reloader);
}
if (camelContext.getManagementStrategy().getManagementAgent() != null) {
camelContext.getManagementStrategy().getManagementAgent()
.setEndpointRuntimeStatisticsEnabled(config.isEndpointRuntimeStatisticsEnabled());
camelContext.getManagementStrategy().getManagementAgent()
.setLoadStatisticsEnabled(config.isLoadStatisticsEnabled());
camelContext.getManagementStrategy().getManagementAgent()
.setStatisticsLevel(config.getJmxManagementStatisticsLevel());
camelContext.getManagementStrategy().getManagementAgent()
.setMBeansLevel(config.getJmxManagementMBeansLevel());
camelContext.getManagementStrategy().getManagementAgent()
.setManagementNamePattern(config.getJmxManagementNamePattern());
camelContext.getManagementStrategy().getManagementAgent()
.setUpdateRouteEnabled(config.isJmxUpdateRouteEnabled());
camelContext.getManagementStrategy().getManagementAgent()
.setRegisterRoutesCreateByKamelet(config.isJmxManagementRegisterRoutesCreateByKamelet());
camelContext.getManagementStrategy().getManagementAgent()
.setRegisterRoutesCreateByTemplate(config.isJmxManagementRegisterRoutesCreateByTemplate());
}
if (config.isCamelEventsTimestampEnabled()) {
camelContext.getManagementStrategy().getEventFactory().setTimestampEnabled(true);
}
// global options
if (config.getGlobalOptions() != null) {
Map<String, String> map = camelContext.getGlobalOptions();
if (map == null) {
map = new HashMap<>();
}
map.putAll(config.getGlobalOptions());
camelContext.setGlobalOptions(map);
}
// global endpoint configurations
camelContext.getGlobalEndpointConfiguration().setAutowiredEnabled(config.isAutowiredEnabled());
camelContext.getGlobalEndpointConfiguration().setBridgeErrorHandler(config.isEndpointBridgeErrorHandler());
camelContext.getGlobalEndpointConfiguration().setLazyStartProducer(config.isEndpointLazyStartProducer());
if (config.isMessageHistory()) {
camelContext.setMessageHistory(true);
}
if (config.isSourceLocationEnabled()) {
camelContext.setSourceLocationEnabled(true);
}
camelContext.setTracing(config.isTracing());
camelContext.setTracingStandby(config.isTracingStandby());
camelContext.setTracingPattern(config.getTracingPattern());
camelContext.setTracingLoggingFormat(config.getTracingLoggingFormat());
camelContext.setTracingTemplates(config.isTracingTemplates());
if (config.getThreadNamePattern() != null) {
camelContext.getExecutorServiceManager().setThreadNamePattern(config.getThreadNamePattern());
}
if (config.getCompileWorkDir() != null) {
CompileStrategy cs = ecc.getContextPlugin(CompileStrategy.class);
if (cs == null) {
cs = new DefaultCompileStrategy();
ecc.addContextPlugin(CompileStrategy.class, cs);
}
cs.setWorkDir(config.getCompileWorkDir());
}
if (config.getRouteFilterIncludePattern() != null || config.getRouteFilterExcludePattern() != null) {
camelContext.getCamelContextExtension().getContextPlugin(Model.class).setRouteFilterPattern(
config.getRouteFilterIncludePattern(),
config.getRouteFilterExcludePattern());
}
// check startup conditions before we can continue
StartupConditionStrategy scs = ecc.getContextPlugin(StartupConditionStrategy.class);
scs.checkStartupConditions();
}