This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 4229a764699e572fdef4f61b1826e4725a9dd9c7 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue Jun 11 08:42:28 2019 +0200 CAMEL-13627: camel-main - Reuse options for main and camel-spring-boot --- components/camel-spring-boot/pom.xml | 4 + .../src/main/docs/spring-boot.adoc | 17 +- .../camel/spring/boot/CamelAutoConfiguration.java | 4 +- .../spring/boot/CamelConfigurationProperties.java | 548 +--------- ...es.java => DefaultConfigurationProperties.java} | 577 ++++------- .../camel/main/MainConfigurationProperties.java | 1086 +------------------- .../java/org/apache/camel/main/MainSupport.java | 14 +- 7 files changed, 226 insertions(+), 2024 deletions(-) diff --git a/components/camel-spring-boot/pom.xml b/components/camel-spring-boot/pom.xml index 4567685..3bd7b24 100644 --- a/components/camel-spring-boot/pom.xml +++ b/components/camel-spring-boot/pom.xml @@ -73,6 +73,10 @@ <groupId>org.apache.camel</groupId> <artifactId>camel-cloud</artifactId> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-main</artifactId> + </dependency> <!-- JMX is enabled by default --> <dependency> <groupId>org.apache.camel</groupId> diff --git a/components/camel-spring-boot/src/main/docs/spring-boot.adoc b/components/camel-spring-boot/src/main/docs/spring-boot.adoc index 1f4f2ce..15d6120 100644 --- a/components/camel-spring-boot/src/main/docs/spring-boot.adoc +++ b/components/camel-spring-boot/src/main/docs/spring-boot.adoc @@ -91,7 +91,7 @@ When using Spring Boot make sure to use the following Maven dependency to have s ---- -The component supports 141 options, which are listed below. +The component supports 126 options, which are listed below. @@ -187,22 +187,7 @@ The component supports 141 options, which are listed below. | *camel.springboot.stream-caching-spool-used-heap-memory-threshold* | Sets a percentage (1-99) of used heap memory threshold to activate stream caching spooling to disk. | 0 | Integer | *camel.springboot.stream-caching-statistics-enabled* | Sets whether stream caching statistics is enabled. | false | Boolean | *camel.springboot.thread-name-pattern* | Sets the thread name pattern used for creating the full thread name. The default pattern is: Camel (#camelId#) thread ##counter# - #name# Where #camelId# is the name of the CamelContext. and #counter# is a unique incrementing counter. and #name# is the regular thread name. You can also use #longName# which is the long thread name which can includes endpoint parameters etc. | | String -| *camel.springboot.trace-formatter-show-body* | Tracer should output message body | true | Boolean -| *camel.springboot.trace-formatter-show-bread-crumb* | Tracer should output breadcrumb | true | Boolean -| *camel.springboot.trace-formatter-show-exception* | Tracer should output exception | true | Boolean -| *camel.springboot.trace-formatter-show-exchange-id* | Tracer should output exchange id | false | Boolean -| *camel.springboot.trace-formatter-show-exchange-pattern* | Tracer should output message exchange pattern (MEP) | true | Boolean -| *camel.springboot.trace-formatter-show-headers* | Tracer should output message headers | true | Boolean -| *camel.springboot.trace-formatter-show-node* | Tracer should output EIP node | true | Boolean -| *camel.springboot.trace-formatter-show-properties* | Tracer should output exchange properties | false | Boolean -| *camel.springboot.trace-formatter-show-route-id* | Tracer should output route id | true | Boolean -| *camel.springboot.trace-formatter-show-short-exchange-id* | Tracer should output short exchange id | false | Boolean -| *camel.springboot.tracer-formatter-bread-crumb-length* | Tracer maximum length of breadcrumb ids | | Integer -| *camel.springboot.tracer-formatter-max-chars* | Tracer maximum characters in total | 10000 | Integer -| *camel.springboot.tracer-formatter-node-length* | Tracer maximum length of node | | Integer -| *camel.springboot.tracer-formatter-show-body-type* | Tracer should output message body type | true | Boolean | *camel.springboot.tracing* | Sets whether tracing is enabled or not. Default is false. | false | Boolean -| *camel.springboot.type-conversion* | Enables enhanced Camel/Spring type conversion. | true | Boolean | *camel.springboot.use-breadcrumb* | Set whether breadcrumb is enabled. The default value is false. | false | Boolean | *camel.springboot.use-data-type* | Whether to enable using data type on Camel messages. Data type are automatic turned on if one ore more routes has been explicit configured with input and output types. Otherwise data type is default off. | false | Boolean | *camel.springboot.use-mdc-logging* | To turn on MDC logging | false | Boolean diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java index 5085eff..74864a5 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java @@ -220,7 +220,7 @@ public class CamelAutoConfiguration { camelContext.setTracing(config.isTracing()); if (config.getXmlRoutesReloadDirectory() != null) { - ReloadStrategy reload = new FileWatcherReloadStrategy(config.getXmlRoutesReloadDirectory()); + ReloadStrategy reload = new FileWatcherReloadStrategy(config.getXmlRoutesReloadDirectory(), config.isXmlRoutesReloadDirectoryRecursively()); camelContext.setReloadStrategy(reload); } @@ -248,7 +248,7 @@ public class CamelAutoConfiguration { @ConditionalOnMissingBean(RoutesCollector.class) RoutesCollector routesCollector(ApplicationContext applicationContext, CamelConfigurationProperties config) { Collection<CamelContextConfiguration> configurations = applicationContext.getBeansOfType(CamelContextConfiguration.class).values(); - return new RoutesCollector(applicationContext, new ArrayList<>(configurations), config); + return new RoutesCollector(applicationContext, new ArrayList(configurations), config); } /** diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java index d50b189..5131805 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java @@ -17,10 +17,14 @@ package org.apache.camel.spring.boot; import org.apache.camel.ManagementStatisticsLevel; +import org.apache.camel.main.DefaultConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties(prefix = "camel.springboot") -public class CamelConfigurationProperties { +public class CamelConfigurationProperties extends DefaultConfigurationProperties<CamelConfigurationProperties> { + + // IMPORTANT: Must include the options from DefaultConfigurationProperties as spring boot apt compiler + // needs to grab the documentation from the javadoc on the field. // Properties @@ -86,11 +90,6 @@ public class CamelConfigurationProperties { private int consumerTemplateCacheSize = 1000; /** - * Enables enhanced Camel/Spring type conversion. - */ - private boolean typeConversion = true; - - /** * Whether to load custom type converters by scanning classpath. * This is used for backwards compatibility with Camel 2.x. * Its recommended to migrate to use fast type converter loading @@ -150,15 +149,23 @@ public class CamelConfigurationProperties { private String xmlRests = "classpath:camel-rest/*.xml"; /** - * To watch the directory for file changes which triggers - * a live reload of the Camel routes on-the-fly. + * Sets the directory name to watch XML file changes to trigger live reload of Camel XML routes. * * For example configure this to point to the source code where the Camel XML files are located * such as: src/main/resources/camel/ + * + * Notice you cannot set this value and a custom ReloadStrategy as well. */ private String xmlRoutesReloadDirectory; /** + * Sets the flag to watch directory of XML file changes recursively to trigger live reload of Camel routes. + * + * Notice you cannot set this value and a custom ReloadStrategy as well. + */ + private String xmlRoutesReloadDirectoryRecursive; + + /** * Directory to load additional configuration files that contains * configuration values that takes precedence over any other configuration. * This can be used to refer to files that may have secret configuration that @@ -409,76 +416,6 @@ public class CamelConfigurationProperties { private boolean jmxCreateConnector; /** - * Tracer should output message body - */ - private boolean traceFormatterShowBody = true; - - /** - * Tracer should output message body type - */ - private boolean tracerFormatterShowBodyType = true; - - /** - * Tracer should output breadcrumb - */ - private boolean traceFormatterShowBreadCrumb = true; - - /** - * Tracer should output exchange id - */ - private boolean traceFormatterShowExchangeId; - - /** - * Tracer should output message headers - */ - private boolean traceFormatterShowHeaders = true; - - /** - * Tracer should output exchange properties - */ - private boolean traceFormatterShowProperties; - - /** - * Tracer should output EIP node - */ - private boolean traceFormatterShowNode = true; - - /** - * Tracer should output message exchange pattern (MEP) - */ - private boolean traceFormatterShowExchangePattern = true; - - /** - * Tracer should output exception - */ - private boolean traceFormatterShowException = true; - - /** - * Tracer should output route id - */ - private boolean traceFormatterShowRouteId = true; - - /** - * Tracer maximum length of breadcrumb ids - */ - private Integer tracerFormatterBreadCrumbLength; - - /** - * Tracer should output short exchange id - */ - private boolean traceFormatterShowShortExchangeId; - - /** - * Tracer maximum length of node - */ - private Integer tracerFormatterNodeLength; - - /** - * Tracer maximum characters in total - */ - private Integer tracerFormatterMaxChars = 10000; - - /** * To turn on MDC logging */ private boolean useMdcLogging; @@ -498,22 +435,6 @@ public class CamelConfigurationProperties { // Getters & setters - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getShutdownTimeout() { - return shutdownTimeout; - } - - public void setShutdownTimeout(int shutdownTimeout) { - this.shutdownTimeout = shutdownTimeout; - } - public boolean isWarnOnEarlyShutdown() { return warnOnEarlyShutdown; } @@ -522,70 +443,6 @@ public class CamelConfigurationProperties { this.warnOnEarlyShutdown = warnOnEarlyShutdown; } - public boolean isShutdownSuppressLoggingOnTimeout() { - return shutdownSuppressLoggingOnTimeout; - } - - public void setShutdownSuppressLoggingOnTimeout(boolean shutdownSuppressLoggingOnTimeout) { - this.shutdownSuppressLoggingOnTimeout = shutdownSuppressLoggingOnTimeout; - } - - public boolean isShutdownNowOnTimeout() { - return shutdownNowOnTimeout; - } - - public void setShutdownNowOnTimeout(boolean shutdownNowOnTimeout) { - this.shutdownNowOnTimeout = shutdownNowOnTimeout; - } - - public boolean isShutdownRoutesInReverseOrder() { - return shutdownRoutesInReverseOrder; - } - - public void setShutdownRoutesInReverseOrder(boolean shutdownRoutesInReverseOrder) { - this.shutdownRoutesInReverseOrder = shutdownRoutesInReverseOrder; - } - - public boolean isShutdownLogInflightExchangesOnTimeout() { - return shutdownLogInflightExchangesOnTimeout; - } - - public void setShutdownLogInflightExchangesOnTimeout(boolean shutdownLogInflightExchangesOnTimeout) { - this.shutdownLogInflightExchangesOnTimeout = shutdownLogInflightExchangesOnTimeout; - } - - public boolean isJmxEnabled() { - return jmxEnabled; - } - - public void setJmxEnabled(boolean jmxEnabled) { - this.jmxEnabled = jmxEnabled; - } - - public int getProducerTemplateCacheSize() { - return producerTemplateCacheSize; - } - - public void setProducerTemplateCacheSize(int producerTemplateCacheSize) { - this.producerTemplateCacheSize = producerTemplateCacheSize; - } - - public int getConsumerTemplateCacheSize() { - return consumerTemplateCacheSize; - } - - public void setConsumerTemplateCacheSize(int consumerTemplateCacheSize) { - this.consumerTemplateCacheSize = consumerTemplateCacheSize; - } - - public boolean isTypeConversion() { - return typeConversion; - } - - public void setTypeConversion(boolean typeConversion) { - this.typeConversion = typeConversion; - } - public boolean isLoadTypeConverters() { return loadTypeConverters; } @@ -626,14 +483,6 @@ public class CamelConfigurationProperties { this.xmlRests = xmlRests; } - public String getXmlRoutesReloadDirectory() { - return xmlRoutesReloadDirectory; - } - - public void setXmlRoutesReloadDirectory(String xmlRoutesReloadDirectory) { - this.xmlRoutesReloadDirectory = xmlRoutesReloadDirectory; - } - public boolean isMainRunController() { return mainRunController; } @@ -642,358 +491,6 @@ public class CamelConfigurationProperties { this.mainRunController = mainRunController; } - public int getDurationMaxSeconds() { - return durationMaxSeconds; - } - - public void setDurationMaxSeconds(int durationMaxSeconds) { - this.durationMaxSeconds = durationMaxSeconds; - } - - public int getDurationMaxIdleSeconds() { - return durationMaxIdleSeconds; - } - - public void setDurationMaxIdleSeconds(int durationMaxIdleSeconds) { - this.durationMaxIdleSeconds = durationMaxIdleSeconds; - } - - public int getDurationMaxMessages() { - return durationMaxMessages; - } - - public void setDurationMaxMessages(int durationMaxMessages) { - this.durationMaxMessages = durationMaxMessages; - } - - public int getLogDebugMaxChars() { - return logDebugMaxChars; - } - - public void setLogDebugMaxChars(int logDebugMaxChars) { - this.logDebugMaxChars = logDebugMaxChars; - } - - public boolean isStreamCachingEnabled() { - return streamCachingEnabled; - } - - public void setStreamCachingEnabled(boolean streamCachingEnabled) { - this.streamCachingEnabled = streamCachingEnabled; - } - - public String getStreamCachingSpoolDirectory() { - return streamCachingSpoolDirectory; - } - - public void setStreamCachingSpoolDirectory(String streamCachingSpoolDirectory) { - this.streamCachingSpoolDirectory = streamCachingSpoolDirectory; - } - - public String getStreamCachingSpoolCipher() { - return streamCachingSpoolCipher; - } - - public void setStreamCachingSpoolCipher(String streamCachingSpoolCipher) { - this.streamCachingSpoolCipher = streamCachingSpoolCipher; - } - - public long getStreamCachingSpoolThreshold() { - return streamCachingSpoolThreshold; - } - - public void setStreamCachingSpoolThreshold(long streamCachingSpoolThreshold) { - this.streamCachingSpoolThreshold = streamCachingSpoolThreshold; - } - - public int getStreamCachingSpoolUsedHeapMemoryThreshold() { - return streamCachingSpoolUsedHeapMemoryThreshold; - } - - public void setStreamCachingSpoolUsedHeapMemoryThreshold(int streamCachingSpoolUsedHeapMemoryThreshold) { - this.streamCachingSpoolUsedHeapMemoryThreshold = streamCachingSpoolUsedHeapMemoryThreshold; - } - - public String getStreamCachingSpoolUsedHeapMemoryLimit() { - return streamCachingSpoolUsedHeapMemoryLimit; - } - - public void setStreamCachingSpoolUsedHeapMemoryLimit(String streamCachingSpoolUsedHeapMemoryLimit) { - this.streamCachingSpoolUsedHeapMemoryLimit = streamCachingSpoolUsedHeapMemoryLimit; - } - - public boolean isStreamCachingAnySpoolRules() { - return streamCachingAnySpoolRules; - } - - public void setStreamCachingAnySpoolRules(boolean streamCachingAnySpoolRules) { - this.streamCachingAnySpoolRules = streamCachingAnySpoolRules; - } - - public int getStreamCachingBufferSize() { - return streamCachingBufferSize; - } - - public void setStreamCachingBufferSize(int streamCachingBufferSize) { - this.streamCachingBufferSize = streamCachingBufferSize; - } - - public boolean isStreamCachingRemoveSpoolDirectoryWhenStopping() { - return streamCachingRemoveSpoolDirectoryWhenStopping; - } - - public void setStreamCachingRemoveSpoolDirectoryWhenStopping(boolean streamCachingRemoveSpoolDirectoryWhenStopping) { - this.streamCachingRemoveSpoolDirectoryWhenStopping = streamCachingRemoveSpoolDirectoryWhenStopping; - } - - public boolean isStreamCachingStatisticsEnabled() { - return streamCachingStatisticsEnabled; - } - - public void setStreamCachingStatisticsEnabled(boolean streamCachingStatisticsEnabled) { - this.streamCachingStatisticsEnabled = streamCachingStatisticsEnabled; - } - - public boolean isTracing() { - return tracing; - } - - public void setTracing(boolean tracing) { - this.tracing = tracing; - } - - public boolean isMessageHistory() { - return messageHistory; - } - - public void setMessageHistory(boolean messageHistory) { - this.messageHistory = messageHistory; - } - - public boolean isLogMask() { - return logMask; - } - - public void setLogMask(boolean logMask) { - this.logMask = logMask; - } - - public boolean isLogExhaustedMessageBody() { - return logExhaustedMessageBody; - } - - public void setLogExhaustedMessageBody(boolean logExhaustedMessageBody) { - this.logExhaustedMessageBody = logExhaustedMessageBody; - } - - public boolean isHandleFault() { - return handleFault; - } - - public void setHandleFault(boolean handleFault) { - this.handleFault = handleFault; - } - - public boolean isAutoStartup() { - return autoStartup; - } - - public void setAutoStartup(boolean autoStartup) { - this.autoStartup = autoStartup; - } - - public boolean isAllowUseOriginalMessage() { - return allowUseOriginalMessage; - } - - public void setAllowUseOriginalMessage(boolean allowUseOriginalMessage) { - this.allowUseOriginalMessage = allowUseOriginalMessage; - } - - public boolean isEndpointRuntimeStatisticsEnabled() { - return endpointRuntimeStatisticsEnabled; - } - - public void setEndpointRuntimeStatisticsEnabled(boolean endpointRuntimeStatisticsEnabled) { - this.endpointRuntimeStatisticsEnabled = endpointRuntimeStatisticsEnabled; - } - - public boolean isUseDataType() { - return useDataType; - } - - public void setUseDataType(boolean useDataType) { - this.useDataType = useDataType; - } - - public boolean isUseBreadcrumb() { - return useBreadcrumb; - } - - public void setUseBreadcrumb(boolean useBreadcrumb) { - this.useBreadcrumb = useBreadcrumb; - } - - public ManagementStatisticsLevel getJmxManagementStatisticsLevel() { - return jmxManagementStatisticsLevel; - } - - public void setJmxManagementStatisticsLevel(ManagementStatisticsLevel jmxManagementStatisticsLevel) { - this.jmxManagementStatisticsLevel = jmxManagementStatisticsLevel; - } - - public String getJmxManagementNamePattern() { - return jmxManagementNamePattern; - } - - public void setJmxManagementNamePattern(String jmxManagementNamePattern) { - this.jmxManagementNamePattern = jmxManagementNamePattern; - } - - public boolean isJmxCreateConnector() { - return jmxCreateConnector; - } - - public void setJmxCreateConnector(boolean jmxCreateConnector) { - this.jmxCreateConnector = jmxCreateConnector; - } - - public String getFileConfigurations() { - return fileConfigurations; - } - - public void setFileConfigurations(String fileConfigurations) { - this.fileConfigurations = fileConfigurations; - } - - public String getRouteFilterIncludePattern() { - return routeFilterIncludePattern; - } - - public void setRouteFilterIncludePattern(String routeFilterIncludePattern) { - this.routeFilterIncludePattern = routeFilterIncludePattern; - } - - public String getRouteFilterExcludePattern() { - return routeFilterExcludePattern; - } - - public void setRouteFilterExcludePattern(String routeFilterExcludePattern) { - this.routeFilterExcludePattern = routeFilterExcludePattern; - } - - public boolean isTraceFormatterShowBody() { - return traceFormatterShowBody; - } - - public void setTraceFormatterShowBody(boolean traceFormatterShowBody) { - this.traceFormatterShowBody = traceFormatterShowBody; - } - - public boolean isTracerFormatterShowBodyType() { - return tracerFormatterShowBodyType; - } - - public void setTracerFormatterShowBodyType(boolean tracerFormatterShowBodyType) { - this.tracerFormatterShowBodyType = tracerFormatterShowBodyType; - } - - public boolean isTraceFormatterShowBreadCrumb() { - return traceFormatterShowBreadCrumb; - } - - public void setTraceFormatterShowBreadCrumb(boolean traceFormatterShowBreadCrumb) { - this.traceFormatterShowBreadCrumb = traceFormatterShowBreadCrumb; - } - - public boolean isTraceFormatterShowExchangeId() { - return traceFormatterShowExchangeId; - } - - public void setTraceFormatterShowExchangeId(boolean traceFormatterShowExchangeId) { - this.traceFormatterShowExchangeId = traceFormatterShowExchangeId; - } - - public boolean isTraceFormatterShowHeaders() { - return traceFormatterShowHeaders; - } - - public void setTraceFormatterShowHeaders(boolean traceFormatterShowHeaders) { - this.traceFormatterShowHeaders = traceFormatterShowHeaders; - } - - public boolean isTraceFormatterShowProperties() { - return traceFormatterShowProperties; - } - - public void setTraceFormatterShowProperties(boolean traceFormatterShowProperties) { - this.traceFormatterShowProperties = traceFormatterShowProperties; - } - - public boolean isTraceFormatterShowNode() { - return traceFormatterShowNode; - } - - public void setTraceFormatterShowNode(boolean traceFormatterShowNode) { - this.traceFormatterShowNode = traceFormatterShowNode; - } - - public boolean isTraceFormatterShowExchangePattern() { - return traceFormatterShowExchangePattern; - } - - public void setTraceFormatterShowExchangePattern(boolean traceFormatterShowExchangePattern) { - this.traceFormatterShowExchangePattern = traceFormatterShowExchangePattern; - } - - public boolean isTraceFormatterShowException() { - return traceFormatterShowException; - } - - public void setTraceFormatterShowException(boolean traceFormatterShowException) { - this.traceFormatterShowException = traceFormatterShowException; - } - - public boolean isTraceFormatterShowRouteId() { - return traceFormatterShowRouteId; - } - - public void setTraceFormatterShowRouteId(boolean traceFormatterShowRouteId) { - this.traceFormatterShowRouteId = traceFormatterShowRouteId; - } - - public Integer getTracerFormatterBreadCrumbLength() { - return tracerFormatterBreadCrumbLength; - } - - public void setTracerFormatterBreadCrumbLength(Integer tracerFormatterBreadCrumbLength) { - this.tracerFormatterBreadCrumbLength = tracerFormatterBreadCrumbLength; - } - - public boolean isTraceFormatterShowShortExchangeId() { - return traceFormatterShowShortExchangeId; - } - - public void setTraceFormatterShowShortExchangeId(boolean traceFormatterShowShortExchangeId) { - this.traceFormatterShowShortExchangeId = traceFormatterShowShortExchangeId; - } - - public Integer getTracerFormatterNodeLength() { - return tracerFormatterNodeLength; - } - - public void setTracerFormatterNodeLength(Integer tracerFormatterNodeLength) { - this.tracerFormatterNodeLength = tracerFormatterNodeLength; - } - - public Integer getTracerFormatterMaxChars() { - return tracerFormatterMaxChars; - } - - public void setTracerFormatterMaxChars(Integer tracerFormatterMaxChars) { - this.tracerFormatterMaxChars = tracerFormatterMaxChars; - } - public boolean isIncludeNonSingletons() { return includeNonSingletons; } @@ -1002,19 +499,4 @@ public class CamelConfigurationProperties { this.includeNonSingletons = includeNonSingletons; } - public boolean isUseMdcLogging() { - return useMdcLogging; - } - - public void setUseMdcLogging(boolean useMdcLogging) { - this.useMdcLogging = useMdcLogging; - } - - public String getThreadNamePattern() { - return threadNamePattern; - } - - public void setThreadNamePattern(String threadNamePattern) { - this.threadNamePattern = threadNamePattern; - } } diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java similarity index 70% copy from core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java copy to core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java index d8b0489..81fd5d0 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java @@ -21,29 +21,25 @@ import org.apache.camel.spi.ReloadStrategy; import org.apache.camel.support.PatternHelper; /** - * Global configuration for Camel Main to setup context name, stream caching and other global configurations. + * Common set of configuration options used by Camel Main, Camel Spring Boot and other runtimes. */ -public class MainConfigurationProperties { +public abstract class DefaultConfigurationProperties<T> { - private boolean autoConfigurationEnabled = true; - private boolean autowireComponentProperties = true; - private boolean autowireComponentPropertiesDeep; private String name; + private int durationMaxSeconds; + private int durationMaxIdleSeconds; + private int durationMaxMessages; private int shutdownTimeout = 300; private boolean shutdownSuppressLoggingOnTimeout; private boolean shutdownNowOnTimeout = true; private boolean shutdownRoutesInReverseOrder = true; private boolean shutdownLogInflightExchangesOnTimeout = true; + private String fileConfigurations; + private String xmlRoutesReloadDirectory; + private boolean xmlRoutesReloadDirectoryRecursively; private boolean jmxEnabled = true; private int producerTemplateCacheSize = 1000; private int consumerTemplateCacheSize = 1000; - private String fileConfigurations; - private long duration = -1; - private int durationMaxSeconds; - private int durationMaxIdleSeconds; - private int durationMaxMessages; - private boolean hangupInterceptorEnabled = true; - private int durationHitExitCode; private int logDebugMaxChars; private boolean streamCachingEnabled; private String streamCachingSpoolDirectory; @@ -70,81 +66,57 @@ public class MainConfigurationProperties { private boolean jmxCreateConnector; private boolean useMdcLogging; private String threadNamePattern; - private String fileWatchDirectory; - private boolean fileWatchDirectoryRecursively; - private ReloadStrategy reloadStrategy; private String routeFilterIncludePattern; private String routeFilterExcludePattern; // getter and setters // -------------------------------------------------------------- - public boolean isAutoConfigurationEnabled() { - return autoConfigurationEnabled; + public String getName() { + return name; } /** - * Whether auto configuration of components/dataformats/languages is enabled or not. - * When enabled the configuration parameters are loaded from the properties component - * and configured as defaults (similar to spring-boot auto-configuration). You can prefix - * the parameters in the properties file with: - * - camel.component.name.option1=value1 - * - camel.component.name.option2=value2 - * - camel.dataformat.name.option1=value1 - * - camel.dataformat.name.option2=value2 - * - camel.language.name.option1=value1 - * - camel.language.name.option2=value2 - * Where name is the name of the component, dataformat or language such as seda,direct,jaxb. - * <p/> - * The auto configuration also works for any options on components - * that is a complex type (not standard Java type) and there has been an explicit single - * bean instance registered to the Camel registry via the {@link org.apache.camel.spi.Registry#bind(String, Object)} method - * or by using the {@link org.apache.camel.BindToRegistry} annotation style. - * <p/> - * This option is default enabled. + * Sets the name of the CamelContext. */ - public void setAutoConfigurationEnabled(boolean autoConfigurationEnabled) { - this.autoConfigurationEnabled = autoConfigurationEnabled; + public void setName(String name) { + this.name = name; } - public boolean isAutowireComponentProperties() { - return autowireComponentProperties; + public int getDurationMaxSeconds() { + return durationMaxSeconds; } /** - * Whether autowiring components with properties that are of same type, which has been added to the Camel registry, as a singleton instance. - * This is used for convention over configuration to inject DataSource, AmazonLogin instances to the components. - * <p/> - * This option is default enabled. + * To specify for how long time in seconds to keep running the JVM before automatic terminating the JVM. + * You can use this to run Camel for a short while. */ - public void setAutowireComponentProperties(boolean autowireComponentProperties) { - this.autowireComponentProperties = autowireComponentProperties; + public void setDurationMaxSeconds(int durationMaxSeconds) { + this.durationMaxSeconds = durationMaxSeconds; } - public boolean isAutowireComponentPropertiesDeep() { - return autowireComponentPropertiesDeep; + public int getDurationMaxIdleSeconds() { + return durationMaxIdleSeconds; } /** - * Whether autowiring components (with deep nesting by attempting to walk as deep down the object graph by creating new empty objects on the way if needed) - * with properties that are of same type, which has been added to the Camel registry, as a singleton instance. - * This is used for convention over configuration to inject DataSource, AmazonLogin instances to the components. - * <p/> - * This option is default disabled. + * To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. + * You can use this to run Camel for a short while. */ - public void setAutowireComponentPropertiesDeep(boolean autowireComponentPropertiesDeep) { - this.autowireComponentPropertiesDeep = autowireComponentPropertiesDeep; + public void setDurationMaxIdleSeconds(int durationMaxIdleSeconds) { + this.durationMaxIdleSeconds = durationMaxIdleSeconds; } - public String getName() { - return name; + public int getDurationMaxMessages() { + return durationMaxMessages; } /** - * Sets the name of the CamelContext. + * To specify how many messages to process by Camel before automatic terminating the JVM. + * You can use this to run Camel for a short while. */ - public void setName(String name) { - this.name = name; + public void setDurationMaxMessages(int durationMaxMessages) { + this.durationMaxMessages = durationMaxMessages; } public int getShutdownTimeout() { @@ -212,90 +184,83 @@ public class MainConfigurationProperties { this.shutdownLogInflightExchangesOnTimeout = shutdownLogInflightExchangesOnTimeout; } - public boolean isJmxEnabled() { - return jmxEnabled; - } - - /** - * Enable JMX in your Camel application. - */ - public void setJmxEnabled(boolean jmxEnabled) { - this.jmxEnabled = jmxEnabled; - } - - public int getProducerTemplateCacheSize() { - return producerTemplateCacheSize; + public String getFileConfigurations() { + return fileConfigurations; } /** - * Producer template endpoints cache size. + * Directory to load additional configuration files that contains + * configuration values that takes precedence over any other configuration. + * This can be used to refer to files that may have secret configuration that + * has been mounted on the file system for containers. + * + * You can specify a pattern to load from sub directories and a name pattern such as /var/app/secret/*.properties, + * multiple directories can be separated by comma. */ - public void setProducerTemplateCacheSize(int producerTemplateCacheSize) { - this.producerTemplateCacheSize = producerTemplateCacheSize; + public void setFileConfigurations(String fileConfigurations) { + this.fileConfigurations = fileConfigurations; } - public int getConsumerTemplateCacheSize() { - return consumerTemplateCacheSize; + public String getXmlRoutesReloadDirectory() { + return xmlRoutesReloadDirectory; } /** - * Consumer template endpoints cache size. + * Sets the directory name to watch XML file changes to trigger live reload of Camel XML routes. + * + * For example configure this to point to the source code where the Camel XML files are located + * such as: src/main/resources/camel/ + * + * Notice you cannot set this value and a custom {@link ReloadStrategy} as well. */ - public void setConsumerTemplateCacheSize(int consumerTemplateCacheSize) { - this.consumerTemplateCacheSize = consumerTemplateCacheSize; + public void setXmlRoutesReloadDirectory(String xmlRoutesReloadDirectory) { + this.xmlRoutesReloadDirectory = xmlRoutesReloadDirectory; } - public String getFileConfigurations() { - return fileConfigurations; + public boolean isXmlRoutesReloadDirectoryRecursively() { + return xmlRoutesReloadDirectoryRecursively; } /** - * Directory to load additional configuration files that contains - * configuration values that takes precedence over any other configuration. - * This can be used to refer to files that may have secret configuration that - * has been mounted on the file system for containers. + * Sets the flag to watch directory of XML file changes recursively to trigger live reload of Camel routes. * - * You can specify a pattern to load from sub directories and a name pattern such as /var/app/secret/*.properties, - * multiple directories can be separated by comma. + * Notice you cannot set this value and a custom ReloadStrategy as well. */ - public void setFileConfigurations(String fileConfigurations) { - this.fileConfigurations = fileConfigurations; + public void setXmlRoutesReloadDirectoryRecursively(boolean xmlRoutesReloadDirectoryRecursively) { + this.xmlRoutesReloadDirectoryRecursively = xmlRoutesReloadDirectoryRecursively; } - public int getDurationMaxSeconds() { - return durationMaxSeconds; + public boolean isJmxEnabled() { + return jmxEnabled; } /** - * To specify for how long time in seconds to keep running the JVM before automatic terminating the JVM. - * You can use this to run Camel for a short while. + * Enable JMX in your Camel application. */ - public void setDurationMaxSeconds(int durationMaxSeconds) { - this.durationMaxSeconds = durationMaxSeconds; + public void setJmxEnabled(boolean jmxEnabled) { + this.jmxEnabled = jmxEnabled; } - public int getDurationMaxIdleSeconds() { - return durationMaxIdleSeconds; + public int getProducerTemplateCacheSize() { + return producerTemplateCacheSize; } /** - * To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. - * You can use this to run Camel for a short while. + * Producer template endpoints cache size. */ - public void setDurationMaxIdleSeconds(int durationMaxIdleSeconds) { - this.durationMaxIdleSeconds = durationMaxIdleSeconds; + public void setProducerTemplateCacheSize(int producerTemplateCacheSize) { + this.producerTemplateCacheSize = producerTemplateCacheSize; } - public int getDurationMaxMessages() { - return durationMaxMessages; + public int getConsumerTemplateCacheSize() { + return consumerTemplateCacheSize; } /** - * To specify how many messages to process by Camel before automatic terminating the JVM. - * You can use this to run Camel for a short while. + * Consumer template endpoints cache size. */ - public void setDurationMaxMessages(int durationMaxMessages) { - this.durationMaxMessages = durationMaxMessages; + public void setConsumerTemplateCacheSize(int consumerTemplateCacheSize) { + this.consumerTemplateCacheSize = consumerTemplateCacheSize; } public int getLogDebugMaxChars() { @@ -644,79 +609,6 @@ public class MainConfigurationProperties { this.threadNamePattern = threadNamePattern; } - public long getDuration() { - return duration; - } - - /** - * Sets the duration (in seconds) to run the application until it - * should be terminated. Defaults to -1. Any value <= 0 will run forever. - */ - public void setDuration(long duration) { - this.duration = duration; - } - - public boolean isHangupInterceptorEnabled() { - return hangupInterceptorEnabled; - } - - /** - * Whether to use graceful hangup when Camel is stopping or when the JVM terminates. - */ - public void setHangupInterceptorEnabled(boolean hangupInterceptorEnabled) { - this.hangupInterceptorEnabled = hangupInterceptorEnabled; - } - - public int getDurationHitExitCode() { - return durationHitExitCode; - } - - /** - * Sets the exit code for the application if duration was hit - */ - public void setDurationHitExitCode(int durationHitExitCode) { - this.durationHitExitCode = durationHitExitCode; - } - - public String getFileWatchDirectory() { - return fileWatchDirectory; - } - - /** - * Sets the directory name to watch XML file changes to trigger live reload of Camel routes. - * <p/> - * Notice you cannot set this value and a custom {@link ReloadStrategy} as well. - */ - public void setFileWatchDirectory(String fileWatchDirectory) { - this.fileWatchDirectory = fileWatchDirectory; - } - - public boolean isFileWatchDirectoryRecursively() { - return fileWatchDirectoryRecursively; - } - - /** - * Sets the flag to watch directory of XML file changes recursively to trigger live reload of Camel routes. - * <p/> - * Notice you cannot set this value and a custom {@link ReloadStrategy} as well. - */ - public void setFileWatchDirectoryRecursively(boolean fileWatchDirectoryRecursively) { - this.fileWatchDirectoryRecursively = fileWatchDirectoryRecursively; - } - - public ReloadStrategy getReloadStrategy() { - return reloadStrategy; - } - - /** - * Sets a custom {@link ReloadStrategy} to be used. - * <p/> - * Notice you cannot set this value and the fileWatchDirectory as well. - */ - public void setReloadStrategy(ReloadStrategy reloadStrategy) { - this.reloadStrategy = reloadStrategy; - } - public String getRouteFilterIncludePattern() { return routeFilterIncludePattern; } @@ -771,67 +663,46 @@ public class MainConfigurationProperties { // -------------------------------------------------------------- /** - * Whether auto configuration of components/dataformats/languages is enabled or not. - * When enabled the configuration parameters are loaded from the properties component - * and configured as defaults (similar to spring-boot auto-configuration). You can prefix - * the parameters in the properties file with: - * - camel.component.name.option1=value1 - * - camel.component.name.option2=value2 - * - camel.dataformat.name.option1=value1 - * - camel.dataformat.name.option2=value2 - * - camel.language.name.option1=value1 - * - camel.language.name.option2=value2 - * Where name is the name of the component, dataformat or language such as seda,direct,jaxb. - * <p/> - * The auto configuration also works for any options on components - * that is a complex type (not standard Java type) and there has been an explicit single - * bean instance registered to the Camel registry via the {@link org.apache.camel.spi.Registry#bind(String, Object)} method - * or by using the {@link org.apache.camel.BindToRegistry} annotation style. - * <p/> - * This option is default enabled. + * Sets the name of the CamelContext. */ - public MainConfigurationProperties withAutoConfigurationEnabled(boolean autoConfigurationEnabled) { - this.autoConfigurationEnabled = autoConfigurationEnabled; - return this; + public T withName(String name) { + this.name = name; + return (T) this; } /** - * Whether autowiring components with properties that are of same type, which has been added to the Camel registry, as a singleton instance. - * This is used for convention over configuration to inject DataSource, AmazonLogin instances to the components. - * <p/> - * This option is default enabled. + * To specify for how long time in seconds to keep running the JVM before automatic terminating the JVM. + * You can use this to run Camel for a short while. */ - public MainConfigurationProperties withAutowireComponentProperties(boolean autowireComponentProperties) { - this.autowireComponentProperties = autowireComponentProperties; - return this; + public T withDurationMaxSeconds(int durationMaxSeconds) { + this.durationMaxSeconds = durationMaxSeconds; + return (T) this; } /** - * Whether autowiring components (with deep nesting by attempting to walk as deep down the object graph by creating new empty objects on the way if needed) - * with properties that are of same type, which has been added to the Camel registry, as a singleton instance. - * This is used for convention over configuration to inject DataSource, AmazonLogin instances to the components. - * <p/> - * This option is default disabled. + * To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. + * You can use this to run Camel for a short while. */ - public MainConfigurationProperties withAutowireComponentPropertiesDeep(boolean autowireComponentPropertiesDeep) { - this.autowireComponentPropertiesDeep = autowireComponentPropertiesDeep; - return this; + public T withDurationMaxIdleSeconds(int durationMaxIdleSeconds) { + this.durationMaxIdleSeconds = durationMaxIdleSeconds; + return (T) this; } /** - * Sets the name of the CamelContext. + * To specify how many messages to process by Camel before automatic terminating the JVM. + * You can use this to run Camel for a short while. */ - public MainConfigurationProperties withName(String name) { - this.name = name; - return this; + public T withDurationMaxMessages(int durationMaxMessages) { + this.durationMaxMessages = durationMaxMessages; + return (T) this; } /** * Timeout in seconds to graceful shutdown Camel. */ - public MainConfigurationProperties withShutdownTimeout(int shutdownTimeout) { + public T withShutdownTimeout(int shutdownTimeout) { this.shutdownTimeout = shutdownTimeout; - return this; + return (T) this; } /** @@ -842,9 +713,9 @@ public class MainConfigurationProperties { * from 3rd party libraries and whatnot, which Camel cannot control. * This option is default false. */ - public MainConfigurationProperties withShutdownSuppressLoggingOnTimeout(boolean shutdownSuppressLoggingOnTimeout) { + public T withShutdownSuppressLoggingOnTimeout(boolean shutdownSuppressLoggingOnTimeout) { this.shutdownSuppressLoggingOnTimeout = shutdownSuppressLoggingOnTimeout; - return this; + return (T) this; } /** @@ -854,91 +725,87 @@ public class MainConfigurationProperties { * You should have good reasons to set this option to false as it means that the routes * keep running and is halted abruptly when CamelContext has been shutdown. */ - public MainConfigurationProperties withShutdownNowOnTimeout(boolean shutdownNowOnTimeout) { + public T withShutdownNowOnTimeout(boolean shutdownNowOnTimeout) { this.shutdownNowOnTimeout = shutdownNowOnTimeout; - return this; + return (T) this; } /** * Sets whether routes should be shutdown in reverse or the same order as they where started. */ - public MainConfigurationProperties withShutdownRoutesInReverseOrder(boolean shutdownRoutesInReverseOrder) { + public T withShutdownRoutesInReverseOrder(boolean shutdownRoutesInReverseOrder) { this.shutdownRoutesInReverseOrder = shutdownRoutesInReverseOrder; - return this; + return (T) this; } /** * Sets whether to log information about the inflight Exchanges which are still running * during a shutdown which didn't complete without the given timeout. */ - public MainConfigurationProperties withShutdownLogInflightExchangesOnTimeout(boolean shutdownLogInflightExchangesOnTimeout) { + public T withShutdownLogInflightExchangesOnTimeout(boolean shutdownLogInflightExchangesOnTimeout) { this.shutdownLogInflightExchangesOnTimeout = shutdownLogInflightExchangesOnTimeout; - return this; + return (T) this; } /** - * Enable JMX in your Camel application. - */ - public MainConfigurationProperties withJmxEnabled(boolean jmxEnabled) { - this.jmxEnabled = jmxEnabled; - return this; - } - - /** - * Producer template endpoints cache size. + * Directory to load additional configuration files that contains + * configuration values that takes precedence over any other configuration. + * This can be used to refer to files that may have secret configuration that + * has been mounted on the file system for containers. + * + * You can specify a pattern to load from sub directories and a name pattern such as /var/app/secret/*.properties, + * multiple directories can be separated by comma. */ - public MainConfigurationProperties withProducerTemplateCacheSize(int producerTemplateCacheSize) { - this.producerTemplateCacheSize = producerTemplateCacheSize; - return this; + public T withFileConfigurations(String fileConfigurations) { + this.fileConfigurations = fileConfigurations; + return (T) this; } /** - * Consumer template endpoints cache size. + * Sets the directory name to watch XML file changes to trigger live reload of Camel XML routes. + * + * For example configure this to point to the source code where the Camel XML files are located + * such as: src/main/resources/camel/ + * + * Notice you cannot set this value and a custom ReloadStrategy as well. */ - public MainConfigurationProperties withConsumerTemplateCacheSize(int consumerTemplateCacheSize) { - this.consumerTemplateCacheSize = consumerTemplateCacheSize; - return this; + public T withXmlRoutesReloadDirectory(String xmlRoutesReloadDirectory) { + this.xmlRoutesReloadDirectory = xmlRoutesReloadDirectory; + return (T) this; } /** - * Directory to load additional configuration files that contains - * configuration values that takes precedence over any other configuration. - * This can be used to refer to files that may have secret configuration that - * has been mounted on the file system for containers. + * Sets the flag to watch directory of XML file changes recursively to trigger live reload of Camel routes. * - * You can specify a pattern to load from sub directories and a name pattern such as /var/app/secret/*.properties, - * multiple directories can be separated by comma. + * Notice you cannot set this value and a custom ReloadStrategy as well. */ - public MainConfigurationProperties withFileConfigurations(String fileConfigurations) { - this.fileConfigurations = fileConfigurations; - return this; + public T withXmlRoutesReloadDirectoryRecursively(boolean xmlRoutesReloadDirectoryRecursively) { + this.xmlRoutesReloadDirectoryRecursively = xmlRoutesReloadDirectoryRecursively; + return (T) this; } /** - * To specify for how long time in seconds to keep running the JVM before automatic terminating the JVM. - * You can use this to run Camel for a short while. + * Enable JMX in your Camel application. */ - public MainConfigurationProperties withDurationMaxSeconds(int durationMaxSeconds) { - this.durationMaxSeconds = durationMaxSeconds; - return this; + public T withJmxEnabled(boolean jmxEnabled) { + this.jmxEnabled = jmxEnabled; + return (T) this; } /** - * To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. - * You can use this to run Camel for a short while. + * Producer template endpoints cache size. */ - public MainConfigurationProperties withDurationMaxIdleSeconds(int durationMaxIdleSeconds) { - this.durationMaxIdleSeconds = durationMaxIdleSeconds; - return this; + public T withProducerTemplateCacheSize(int producerTemplateCacheSize) { + this.producerTemplateCacheSize = producerTemplateCacheSize; + return (T) this; } /** - * To specify how many messages to process by Camel before automatic terminating the JVM. - * You can use this to run Camel for a short while. + * Consumer template endpoints cache size. */ - public MainConfigurationProperties withDurationMaxMessages(int durationMaxMessages) { - this.durationMaxMessages = durationMaxMessages; - return this; + public T withConsumerTemplateCacheSize(int consumerTemplateCacheSize) { + this.consumerTemplateCacheSize = consumerTemplateCacheSize; + return (T) this; } /** @@ -946,9 +813,9 @@ public class MainConfigurationProperties { * is longer than the limit, the log message is clipped. Use -1 to have unlimited length. * Use for example 1000 to log at most 1000 characters. */ - public MainConfigurationProperties withLogDebugMaxChars(int logDebugMaxChars) { + public T withLogDebugMaxChars(int logDebugMaxChars) { this.logDebugMaxChars = logDebugMaxChars; - return this; + return (T) this; } /** @@ -956,9 +823,9 @@ public class MainConfigurationProperties { * * Default is false. */ - public MainConfigurationProperties withStreamCachingEnabled(boolean streamCachingEnabled) { + public T withStreamCachingEnabled(boolean streamCachingEnabled) { this.streamCachingEnabled = streamCachingEnabled; - return this; + return (T) this; } /** @@ -967,18 +834,18 @@ public class MainConfigurationProperties { * If no spool directory has been explicit configured, then a temporary directory * is created in the java.io.tmpdir directory. */ - public MainConfigurationProperties withStreamCachingSpoolDirectory(String streamCachingSpoolDirectory) { + public T withStreamCachingSpoolDirectory(String streamCachingSpoolDirectory) { this.streamCachingSpoolDirectory = streamCachingSpoolDirectory; - return this; + return (T) this; } /** * Sets a stream caching cipher name to use when spooling to disk to write with encryption. * By default the data is not encrypted. */ - public MainConfigurationProperties withStreamCachingSpoolCipher(String streamCachingSpoolCipher) { + public T withStreamCachingSpoolCipher(String streamCachingSpoolCipher) { this.streamCachingSpoolCipher = streamCachingSpoolCipher; - return this; + return (T) this; } /** @@ -986,25 +853,25 @@ public class MainConfigurationProperties { * The default threshold is 128kb. * Use -1 to disable overflow to disk. */ - public MainConfigurationProperties withStreamCachingSpoolThreshold(long streamCachingSpoolThreshold) { + public T withStreamCachingSpoolThreshold(long streamCachingSpoolThreshold) { this.streamCachingSpoolThreshold = streamCachingSpoolThreshold; - return this; + return (T) this; } /** * Sets a percentage (1-99) of used heap memory threshold to activate stream caching spooling to disk. */ - public MainConfigurationProperties withStreamCachingSpoolUsedHeapMemoryThreshold(int streamCachingSpoolUsedHeapMemoryThreshold) { + public T withStreamCachingSpoolUsedHeapMemoryThreshold(int streamCachingSpoolUsedHeapMemoryThreshold) { this.streamCachingSpoolUsedHeapMemoryThreshold = streamCachingSpoolUsedHeapMemoryThreshold; - return this; + return (T) this; } /** * Sets what the upper bounds should be when streamCachingSpoolUsedHeapMemoryThreshold is in use. */ - public MainConfigurationProperties withStreamCachingSpoolUsedHeapMemoryLimit(String streamCachingSpoolUsedHeapMemoryLimit) { + public T withStreamCachingSpoolUsedHeapMemoryLimit(String streamCachingSpoolUsedHeapMemoryLimit) { this.streamCachingSpoolUsedHeapMemoryLimit = streamCachingSpoolUsedHeapMemoryLimit; - return this; + return (T) this; } /** @@ -1015,9 +882,9 @@ public class MainConfigurationProperties { * * The default value is false which means that all the rules must return true. */ - public MainConfigurationProperties withStreamCachingAnySpoolRules(boolean streamCachingAnySpoolRules) { + public T withStreamCachingAnySpoolRules(boolean streamCachingAnySpoolRules) { this.streamCachingAnySpoolRules = streamCachingAnySpoolRules; - return this; + return (T) this; } /** @@ -1025,26 +892,26 @@ public class MainConfigurationProperties { * * The default size is 4096. */ - public MainConfigurationProperties withStreamCachingBufferSize(int streamCachingBufferSize) { + public T withStreamCachingBufferSize(int streamCachingBufferSize) { this.streamCachingBufferSize = streamCachingBufferSize; - return this; + return (T) this; } /** * Whether to remove stream caching temporary directory when stopping. * This option is default true. */ - public MainConfigurationProperties withStreamCachingRemoveSpoolDirectoryWhenStopping(boolean streamCachingRemoveSpoolDirectoryWhenStopping) { + public T withStreamCachingRemoveSpoolDirectoryWhenStopping(boolean streamCachingRemoveSpoolDirectoryWhenStopping) { this.streamCachingRemoveSpoolDirectoryWhenStopping = streamCachingRemoveSpoolDirectoryWhenStopping; - return this; + return (T) this; } /** * Sets whether stream caching statistics is enabled. */ - public MainConfigurationProperties withStreamCachingStatisticsEnabled(boolean streamCachingStatisticsEnabled) { + public T withStreamCachingStatisticsEnabled(boolean streamCachingStatisticsEnabled) { this.streamCachingStatisticsEnabled = streamCachingStatisticsEnabled; - return this; + return (T) this; } /** @@ -1052,9 +919,9 @@ public class MainConfigurationProperties { * * Default is false. */ - public MainConfigurationProperties withTracing(boolean tracing) { + public T withTracing(boolean tracing) { this.tracing = tracing; - return this; + return (T) this; } /** @@ -1062,9 +929,9 @@ public class MainConfigurationProperties { * * Default is true. */ - public MainConfigurationProperties withMessageHistory(boolean messageHistory) { + public T withMessageHistory(boolean messageHistory) { this.messageHistory = messageHistory; - return this; + return (T) this; } /** @@ -1072,9 +939,9 @@ public class MainConfigurationProperties { * * Default is false. */ - public MainConfigurationProperties withLogMask(boolean logMask) { + public T withLogMask(boolean logMask) { this.logMask = logMask; - return this; + return (T) this; } /** @@ -1082,9 +949,9 @@ public class MainConfigurationProperties { * * Default is false. */ - public MainConfigurationProperties withLogExhaustedMessageBody(boolean logExhaustedMessageBody) { + public T withLogExhaustedMessageBody(boolean logExhaustedMessageBody) { this.logExhaustedMessageBody = logExhaustedMessageBody; - return this; + return (T) this; } /** @@ -1092,9 +959,9 @@ public class MainConfigurationProperties { * * Default is false. */ - public MainConfigurationProperties withHandleFault(boolean handleFault) { + public T withHandleFault(boolean handleFault) { this.handleFault = handleFault; - return this; + return (T) this; } /** @@ -1107,9 +974,9 @@ public class MainConfigurationProperties { * * Default is true to always start up. */ - public MainConfigurationProperties withAutoStartup(boolean autoStartup) { + public T withAutoStartup(boolean autoStartup) { this.autoStartup = autoStartup; - return this; + return (T) this; } /** @@ -1119,9 +986,9 @@ public class MainConfigurationProperties { * * Default is false. */ - public MainConfigurationProperties withAllowUseOriginalMessage(boolean allowUseOriginalMessage) { + public T withAllowUseOriginalMessage(boolean allowUseOriginalMessage) { this.allowUseOriginalMessage = allowUseOriginalMessage; - return this; + return (T) this; } /** @@ -1129,9 +996,9 @@ public class MainConfigurationProperties { * * The default value is false. */ - public MainConfigurationProperties withEndpointRuntimeStatisticsEnabled(boolean endpointRuntimeStatisticsEnabled) { + public T withEndpointRuntimeStatisticsEnabled(boolean endpointRuntimeStatisticsEnabled) { this.endpointRuntimeStatisticsEnabled = endpointRuntimeStatisticsEnabled; - return this; + return (T) this; } /** @@ -1140,18 +1007,18 @@ public class MainConfigurationProperties { * Data type are automatic turned on if one ore more routes has been explicit configured with input and output types. * Otherwise data type is default off. */ - public MainConfigurationProperties withUseDataType(boolean useDataType) { + public T withUseDataType(boolean useDataType) { this.useDataType = useDataType; - return this; + return (T) this; } /** * Set whether breadcrumb is enabled. * The default value is false. */ - public MainConfigurationProperties withUseBreadcrumb(boolean useBreadcrumb) { + public T withUseBreadcrumb(boolean useBreadcrumb) { this.useBreadcrumb = useBreadcrumb; - return this; + return (T) this; } /** @@ -1160,9 +1027,9 @@ public class MainConfigurationProperties { * * The default value is Default. */ - public MainConfigurationProperties withJmxManagementStatisticsLevel(ManagementStatisticsLevel jmxManagementStatisticsLevel) { + public T withJmxManagementStatisticsLevel(ManagementStatisticsLevel jmxManagementStatisticsLevel) { this.jmxManagementStatisticsLevel = jmxManagementStatisticsLevel; - return this; + return (T) this; } /** @@ -1170,9 +1037,9 @@ public class MainConfigurationProperties { * * The default pattern is #name# */ - public MainConfigurationProperties withJmxManagementNamePattern(String jmxManagementNamePattern) { + public T withJmxManagementNamePattern(String jmxManagementNamePattern) { this.jmxManagementNamePattern = jmxManagementNamePattern; - return this; + return (T) this; } /** @@ -1180,17 +1047,17 @@ public class MainConfigurationProperties { * * The default value is false. */ - public MainConfigurationProperties withJmxCreateConnector(boolean jmxCreateConnector) { + public T withJmxCreateConnector(boolean jmxCreateConnector) { this.jmxCreateConnector = jmxCreateConnector; - return this; + return (T) this; } /** * To turn on MDC logging */ - public MainConfigurationProperties withUseMdcLogging(boolean useMdcLogging) { + public T withUseMdcLogging(boolean useMdcLogging) { this.useMdcLogging = useMdcLogging; - return this; + return (T) this; } /** @@ -1204,68 +1071,12 @@ public class MainConfigurationProperties { * * You can also use #longName# which is the long thread name which can includes endpoint parameters etc. */ - public MainConfigurationProperties withThreadNamePattern(String threadNamePattern) { + public T withThreadNamePattern(String threadNamePattern) { this.threadNamePattern = threadNamePattern; - return this; - } - - /** - * Sets the duration (in seconds) to run the application until it - * should be terminated. Defaults to -1. Any value <= 0 will run forever. - */ - public MainConfigurationProperties withDuration(long duration) { - this.duration = duration; - return this; + return (T) this; } /** - * Whether to use graceful hangup when Camel is stopping or when the JVM terminates. - */ - public MainConfigurationProperties withHangupInterceptorEnabled(boolean hangupInterceptorEnabled) { - this.hangupInterceptorEnabled = hangupInterceptorEnabled; - return this; - } - - /** - * Sets the exit code for the application if duration was hit - */ - public MainConfigurationProperties withDurationHitExitCode(int durationHitExitCode) { - this.durationHitExitCode = durationHitExitCode; - return this; - } - - /** - * Sets the directory name to watch XML file changes to trigger live reload of Camel routes. - * <p/> - * Notice you cannot set this value and a custom {@link ReloadStrategy} as well. - */ - public MainConfigurationProperties withFileWatchDirectory(String fileWatchDirectory) { - this.fileWatchDirectory = fileWatchDirectory; - return this; - } - - /** - * Sets the flag to watch directory of XML file changes recursively to trigger live reload of Camel routes. - * <p/> - * Notice you cannot set this value and a custom {@link ReloadStrategy} as well. - */ - public MainConfigurationProperties withFileWatchDirectoryRecursively(boolean fileWatchDirectoryRecursively) { - this.fileWatchDirectoryRecursively = fileWatchDirectoryRecursively; - return this; - } - - /** - * Sets a custom {@link ReloadStrategy} to be used. - * <p/> - * Notice you cannot set this value and the fileWatchDirectory as well. - */ - public MainConfigurationProperties withReloadStrategy(ReloadStrategy reloadStrategy) { - this.reloadStrategy = reloadStrategy; - return this; - } - - - /** * Used for filtering routes routes matching the given pattern, which follows the following rules: * * - Match by route id @@ -1280,9 +1091,9 @@ public class MainConfigurationProperties { * * Exclude takes precedence over include. */ - public MainConfigurationProperties withRouteFilterIncludePattern(String routeFilterIncludePattern) { + public T withRouteFilterIncludePattern(String routeFilterIncludePattern) { this.routeFilterIncludePattern = routeFilterIncludePattern; - return this; + return (T) this; } /** @@ -1300,8 +1111,8 @@ public class MainConfigurationProperties { * * Exclude takes precedence over include. */ - public MainConfigurationProperties withRouteFilterExcludePattern(String routeFilterExcludePattern) { + public T withRouteFilterExcludePattern(String routeFilterExcludePattern) { this.routeFilterExcludePattern = routeFilterExcludePattern; - return this; + return (T) this; } } diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java index d8b0489..88a7077 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java @@ -16,65 +16,20 @@ */ package org.apache.camel.main; -import org.apache.camel.ManagementStatisticsLevel; import org.apache.camel.spi.ReloadStrategy; -import org.apache.camel.support.PatternHelper; /** * Global configuration for Camel Main to setup context name, stream caching and other global configurations. */ -public class MainConfigurationProperties { +public class MainConfigurationProperties extends DefaultConfigurationProperties<MainConfigurationProperties> { private boolean autoConfigurationEnabled = true; private boolean autowireComponentProperties = true; private boolean autowireComponentPropertiesDeep; - private String name; - private int shutdownTimeout = 300; - private boolean shutdownSuppressLoggingOnTimeout; - private boolean shutdownNowOnTimeout = true; - private boolean shutdownRoutesInReverseOrder = true; - private boolean shutdownLogInflightExchangesOnTimeout = true; - private boolean jmxEnabled = true; - private int producerTemplateCacheSize = 1000; - private int consumerTemplateCacheSize = 1000; - private String fileConfigurations; private long duration = -1; - private int durationMaxSeconds; - private int durationMaxIdleSeconds; - private int durationMaxMessages; - private boolean hangupInterceptorEnabled = true; private int durationHitExitCode; - private int logDebugMaxChars; - private boolean streamCachingEnabled; - private String streamCachingSpoolDirectory; - private String streamCachingSpoolCipher; - private long streamCachingSpoolThreshold; - private int streamCachingSpoolUsedHeapMemoryThreshold; - private String streamCachingSpoolUsedHeapMemoryLimit; - private boolean streamCachingAnySpoolRules; - private int streamCachingBufferSize; - private boolean streamCachingRemoveSpoolDirectoryWhenStopping = true; - private boolean streamCachingStatisticsEnabled; - private boolean tracing; - private boolean messageHistory = true; - private boolean logMask; - private boolean logExhaustedMessageBody; - private boolean handleFault; - private boolean autoStartup = true; - private boolean allowUseOriginalMessage; - private boolean endpointRuntimeStatisticsEnabled; - private boolean useDataType; - private boolean useBreadcrumb; - private ManagementStatisticsLevel jmxManagementStatisticsLevel = ManagementStatisticsLevel.Default; - private String jmxManagementNamePattern = "#name#"; - private boolean jmxCreateConnector; - private boolean useMdcLogging; - private String threadNamePattern; - private String fileWatchDirectory; - private boolean fileWatchDirectoryRecursively; + private boolean hangupInterceptorEnabled = true; private ReloadStrategy reloadStrategy; - private String routeFilterIncludePattern; - private String routeFilterExcludePattern; // getter and setters // -------------------------------------------------------------- @@ -136,514 +91,6 @@ public class MainConfigurationProperties { this.autowireComponentPropertiesDeep = autowireComponentPropertiesDeep; } - public String getName() { - return name; - } - - /** - * Sets the name of the CamelContext. - */ - public void setName(String name) { - this.name = name; - } - - public int getShutdownTimeout() { - return shutdownTimeout; - } - - /** - * Timeout in seconds to graceful shutdown Camel. - */ - public void setShutdownTimeout(int shutdownTimeout) { - this.shutdownTimeout = shutdownTimeout; - } - - public boolean isShutdownSuppressLoggingOnTimeout() { - return shutdownSuppressLoggingOnTimeout; - } - - /** - * Whether Camel should try to suppress logging during shutdown and timeout was triggered, - * meaning forced shutdown is happening. And during forced shutdown we want to avoid logging - * errors/warnings et all in the logs as a side-effect of the forced timeout. - * Notice the suppress is a best effort as there may still be some logs coming - * from 3rd party libraries and whatnot, which Camel cannot control. - * This option is default false. - */ - public void setShutdownSuppressLoggingOnTimeout(boolean shutdownSuppressLoggingOnTimeout) { - this.shutdownSuppressLoggingOnTimeout = shutdownSuppressLoggingOnTimeout; - } - - public boolean isShutdownNowOnTimeout() { - return shutdownNowOnTimeout; - } - - /** - * Sets whether to force shutdown of all consumers when a timeout occurred and thus - * not all consumers was shutdown within that period. - * - * You should have good reasons to set this option to false as it means that the routes - * keep running and is halted abruptly when CamelContext has been shutdown. - */ - public void setShutdownNowOnTimeout(boolean shutdownNowOnTimeout) { - this.shutdownNowOnTimeout = shutdownNowOnTimeout; - } - - public boolean isShutdownRoutesInReverseOrder() { - return shutdownRoutesInReverseOrder; - } - - /** - * Sets whether routes should be shutdown in reverse or the same order as they where started. - */ - public void setShutdownRoutesInReverseOrder(boolean shutdownRoutesInReverseOrder) { - this.shutdownRoutesInReverseOrder = shutdownRoutesInReverseOrder; - } - - public boolean isShutdownLogInflightExchangesOnTimeout() { - return shutdownLogInflightExchangesOnTimeout; - } - - /** - * Sets whether to log information about the inflight Exchanges which are still running - * during a shutdown which didn't complete without the given timeout. - */ - public void setShutdownLogInflightExchangesOnTimeout(boolean shutdownLogInflightExchangesOnTimeout) { - this.shutdownLogInflightExchangesOnTimeout = shutdownLogInflightExchangesOnTimeout; - } - - public boolean isJmxEnabled() { - return jmxEnabled; - } - - /** - * Enable JMX in your Camel application. - */ - public void setJmxEnabled(boolean jmxEnabled) { - this.jmxEnabled = jmxEnabled; - } - - public int getProducerTemplateCacheSize() { - return producerTemplateCacheSize; - } - - /** - * Producer template endpoints cache size. - */ - public void setProducerTemplateCacheSize(int producerTemplateCacheSize) { - this.producerTemplateCacheSize = producerTemplateCacheSize; - } - - public int getConsumerTemplateCacheSize() { - return consumerTemplateCacheSize; - } - - /** - * Consumer template endpoints cache size. - */ - public void setConsumerTemplateCacheSize(int consumerTemplateCacheSize) { - this.consumerTemplateCacheSize = consumerTemplateCacheSize; - } - - public String getFileConfigurations() { - return fileConfigurations; - } - - /** - * Directory to load additional configuration files that contains - * configuration values that takes precedence over any other configuration. - * This can be used to refer to files that may have secret configuration that - * has been mounted on the file system for containers. - * - * You can specify a pattern to load from sub directories and a name pattern such as /var/app/secret/*.properties, - * multiple directories can be separated by comma. - */ - public void setFileConfigurations(String fileConfigurations) { - this.fileConfigurations = fileConfigurations; - } - - public int getDurationMaxSeconds() { - return durationMaxSeconds; - } - - /** - * To specify for how long time in seconds to keep running the JVM before automatic terminating the JVM. - * You can use this to run Camel for a short while. - */ - public void setDurationMaxSeconds(int durationMaxSeconds) { - this.durationMaxSeconds = durationMaxSeconds; - } - - public int getDurationMaxIdleSeconds() { - return durationMaxIdleSeconds; - } - - /** - * To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. - * You can use this to run Camel for a short while. - */ - public void setDurationMaxIdleSeconds(int durationMaxIdleSeconds) { - this.durationMaxIdleSeconds = durationMaxIdleSeconds; - } - - public int getDurationMaxMessages() { - return durationMaxMessages; - } - - /** - * To specify how many messages to process by Camel before automatic terminating the JVM. - * You can use this to run Camel for a short while. - */ - public void setDurationMaxMessages(int durationMaxMessages) { - this.durationMaxMessages = durationMaxMessages; - } - - public int getLogDebugMaxChars() { - return logDebugMaxChars; - } - - /** - * Is used to limit the maximum length of the logging Camel message bodies. If the message body - * is longer than the limit, the log message is clipped. Use -1 to have unlimited length. - * Use for example 1000 to log at most 1000 characters. - */ - public void setLogDebugMaxChars(int logDebugMaxChars) { - this.logDebugMaxChars = logDebugMaxChars; - } - - public boolean isStreamCachingEnabled() { - return streamCachingEnabled; - } - - /** - * Sets whether stream caching is enabled or not. - * - * Default is false. - */ - public void setStreamCachingEnabled(boolean streamCachingEnabled) { - this.streamCachingEnabled = streamCachingEnabled; - } - - public String getStreamCachingSpoolDirectory() { - return streamCachingSpoolDirectory; - } - - /** - * Sets the stream caching spool (temporary) directory to use for overflow and spooling to disk. - * - * If no spool directory has been explicit configured, then a temporary directory - * is created in the java.io.tmpdir directory. - */ - public void setStreamCachingSpoolDirectory(String streamCachingSpoolDirectory) { - this.streamCachingSpoolDirectory = streamCachingSpoolDirectory; - } - - public String getStreamCachingSpoolCipher() { - return streamCachingSpoolCipher; - } - - /** - * Sets a stream caching cipher name to use when spooling to disk to write with encryption. - * By default the data is not encrypted. - */ - public void setStreamCachingSpoolCipher(String streamCachingSpoolCipher) { - this.streamCachingSpoolCipher = streamCachingSpoolCipher; - } - - public long getStreamCachingSpoolThreshold() { - return streamCachingSpoolThreshold; - } - - /** - * Stream caching threshold in bytes when overflow to disk is activated. - * The default threshold is 128kb. - * Use -1 to disable overflow to disk. - */ - public void setStreamCachingSpoolThreshold(long streamCachingSpoolThreshold) { - this.streamCachingSpoolThreshold = streamCachingSpoolThreshold; - } - - public int getStreamCachingSpoolUsedHeapMemoryThreshold() { - return streamCachingSpoolUsedHeapMemoryThreshold; - } - - /** - * Sets a percentage (1-99) of used heap memory threshold to activate stream caching spooling to disk. - */ - public void setStreamCachingSpoolUsedHeapMemoryThreshold(int streamCachingSpoolUsedHeapMemoryThreshold) { - this.streamCachingSpoolUsedHeapMemoryThreshold = streamCachingSpoolUsedHeapMemoryThreshold; - } - - public String getStreamCachingSpoolUsedHeapMemoryLimit() { - return streamCachingSpoolUsedHeapMemoryLimit; - } - - /** - * Sets what the upper bounds should be when streamCachingSpoolUsedHeapMemoryThreshold is in use. - */ - public void setStreamCachingSpoolUsedHeapMemoryLimit(String streamCachingSpoolUsedHeapMemoryLimit) { - this.streamCachingSpoolUsedHeapMemoryLimit = streamCachingSpoolUsedHeapMemoryLimit; - } - - public boolean isStreamCachingAnySpoolRules() { - return streamCachingAnySpoolRules; - } - - /** - * Sets whether if just any of the org.apache.camel.spi.StreamCachingStrategy.SpoolRule rules - * returns true then shouldSpoolCache(long) returns true, to allow spooling to disk. - * If this option is false, then all the org.apache.camel.spi.StreamCachingStrategy.SpoolRule must - * return true. - * - * The default value is false which means that all the rules must return true. - */ - public void setStreamCachingAnySpoolRules(boolean streamCachingAnySpoolRules) { - this.streamCachingAnySpoolRules = streamCachingAnySpoolRules; - } - - public int getStreamCachingBufferSize() { - return streamCachingBufferSize; - } - - /** - * Sets the stream caching buffer size to use when allocating in-memory buffers used for in-memory stream caches. - * - * The default size is 4096. - */ - public void setStreamCachingBufferSize(int streamCachingBufferSize) { - this.streamCachingBufferSize = streamCachingBufferSize; - } - - public boolean isStreamCachingRemoveSpoolDirectoryWhenStopping() { - return streamCachingRemoveSpoolDirectoryWhenStopping; - } - - /** - * Whether to remove stream caching temporary directory when stopping. - * This option is default true. - */ - public void setStreamCachingRemoveSpoolDirectoryWhenStopping(boolean streamCachingRemoveSpoolDirectoryWhenStopping) { - this.streamCachingRemoveSpoolDirectoryWhenStopping = streamCachingRemoveSpoolDirectoryWhenStopping; - } - - public boolean isStreamCachingStatisticsEnabled() { - return streamCachingStatisticsEnabled; - } - - /** - * Sets whether stream caching statistics is enabled. - */ - public void setStreamCachingStatisticsEnabled(boolean streamCachingStatisticsEnabled) { - this.streamCachingStatisticsEnabled = streamCachingStatisticsEnabled; - } - - public boolean isTracing() { - return tracing; - } - - /** - * Sets whether tracing is enabled or not. - * - * Default is false. - */ - public void setTracing(boolean tracing) { - this.tracing = tracing; - } - - public boolean isMessageHistory() { - return messageHistory; - } - - /** - * Sets whether message history is enabled or not. - * - * Default is true. - */ - public void setMessageHistory(boolean messageHistory) { - this.messageHistory = messageHistory; - } - - public boolean isLogMask() { - return logMask; - } - - /** - * Sets whether log mask is enabled or not. - * - * Default is false. - */ - public void setLogMask(boolean logMask) { - this.logMask = logMask; - } - - public boolean isLogExhaustedMessageBody() { - return logExhaustedMessageBody; - } - - /** - * Sets whether to log exhausted message body with message history. - * - * Default is false. - */ - public void setLogExhaustedMessageBody(boolean logExhaustedMessageBody) { - this.logExhaustedMessageBody = logExhaustedMessageBody; - } - - public boolean isHandleFault() { - return handleFault; - } - - /** - * Sets whether fault handling is enabled or not. - * - * Default is false. - */ - public void setHandleFault(boolean handleFault) { - this.handleFault = handleFault; - } - - public boolean isAutoStartup() { - return autoStartup; - } - - /** - * Sets whether the object should automatically start when Camel starts. - * Important: Currently only routes can be disabled, as CamelContext's are always started. - * Note: When setting auto startup false on CamelContext then that takes precedence - * and no routes is started. You would need to start CamelContext explicit using - * the org.apache.camel.CamelContext.start() method, to start the context, and then - * you would need to start the routes manually using CamelContext.getRouteController().startRoute(String). - * - * Default is true to always start up. - */ - public void setAutoStartup(boolean autoStartup) { - this.autoStartup = autoStartup; - } - - public boolean isAllowUseOriginalMessage() { - return allowUseOriginalMessage; - } - - /** - * Sets whether to allow access to the original message from Camel's error handler, - * or from org.apache.camel.spi.UnitOfWork.getOriginalInMessage(). - * Turning this off can optimize performance, as defensive copy of the original message is not needed. - * - * Default is false. - */ - public void setAllowUseOriginalMessage(boolean allowUseOriginalMessage) { - this.allowUseOriginalMessage = allowUseOriginalMessage; - } - - public boolean isEndpointRuntimeStatisticsEnabled() { - return endpointRuntimeStatisticsEnabled; - } - - /** - * Sets whether endpoint runtime statistics is enabled (gathers runtime usage of each incoming and outgoing endpoints). - * - * The default value is false. - */ - public void setEndpointRuntimeStatisticsEnabled(boolean endpointRuntimeStatisticsEnabled) { - this.endpointRuntimeStatisticsEnabled = endpointRuntimeStatisticsEnabled; - } - - public boolean isUseDataType() { - return useDataType; - } - - /** - * Whether to enable using data type on Camel messages. - * - * Data type are automatic turned on if one ore more routes has been explicit configured with input and output types. - * Otherwise data type is default off. - */ - public void setUseDataType(boolean useDataType) { - this.useDataType = useDataType; - } - - public boolean isUseBreadcrumb() { - return useBreadcrumb; - } - - /** - * Set whether breadcrumb is enabled. - * The default value is false. - */ - public void setUseBreadcrumb(boolean useBreadcrumb) { - this.useBreadcrumb = useBreadcrumb; - } - - public ManagementStatisticsLevel getJmxManagementStatisticsLevel() { - return jmxManagementStatisticsLevel; - } - - /** - * Sets the JMX statistics level - * The level can be set to Extended to gather additional information - * - * The default value is Default. - */ - public void setJmxManagementStatisticsLevel(ManagementStatisticsLevel jmxManagementStatisticsLevel) { - this.jmxManagementStatisticsLevel = jmxManagementStatisticsLevel; - } - - public String getJmxManagementNamePattern() { - return jmxManagementNamePattern; - } - - /** - * The naming pattern for creating the CamelContext JMX management name. - * - * The default pattern is #name# - */ - public void setJmxManagementNamePattern(String jmxManagementNamePattern) { - this.jmxManagementNamePattern = jmxManagementNamePattern; - } - - public boolean isJmxCreateConnector() { - return jmxCreateConnector; - } - - /** - * Whether JMX connector is created, allowing clients to connect remotely - * - * The default value is false. - */ - public void setJmxCreateConnector(boolean jmxCreateConnector) { - this.jmxCreateConnector = jmxCreateConnector; - } - - public boolean isUseMdcLogging() { - return useMdcLogging; - } - - /** - * To turn on MDC logging - */ - public void setUseMdcLogging(boolean useMdcLogging) { - this.useMdcLogging = useMdcLogging; - } - - public String getThreadNamePattern() { - return threadNamePattern; - } - - /** - * Sets the thread name pattern used for creating the full thread name. - * - * The default pattern is: Camel (#camelId#) thread ##counter# - #name# - * - * Where #camelId# is the name of the CamelContext. - * and #counter# is a unique incrementing counter. - * and #name# is the regular thread name. - * - * You can also use #longName# which is the long thread name which can includes endpoint parameters etc. - */ - public void setThreadNamePattern(String threadNamePattern) { - this.threadNamePattern = threadNamePattern; - } - public long getDuration() { return duration; } @@ -678,32 +125,6 @@ public class MainConfigurationProperties { this.durationHitExitCode = durationHitExitCode; } - public String getFileWatchDirectory() { - return fileWatchDirectory; - } - - /** - * Sets the directory name to watch XML file changes to trigger live reload of Camel routes. - * <p/> - * Notice you cannot set this value and a custom {@link ReloadStrategy} as well. - */ - public void setFileWatchDirectory(String fileWatchDirectory) { - this.fileWatchDirectory = fileWatchDirectory; - } - - public boolean isFileWatchDirectoryRecursively() { - return fileWatchDirectoryRecursively; - } - - /** - * Sets the flag to watch directory of XML file changes recursively to trigger live reload of Camel routes. - * <p/> - * Notice you cannot set this value and a custom {@link ReloadStrategy} as well. - */ - public void setFileWatchDirectoryRecursively(boolean fileWatchDirectoryRecursively) { - this.fileWatchDirectoryRecursively = fileWatchDirectoryRecursively; - } - public ReloadStrategy getReloadStrategy() { return reloadStrategy; } @@ -711,62 +132,12 @@ public class MainConfigurationProperties { /** * Sets a custom {@link ReloadStrategy} to be used. * <p/> - * Notice you cannot set this value and the fileWatchDirectory as well. + * Notice you cannot set this value and the xmlRoutesReloadDirectory as well. */ public void setReloadStrategy(ReloadStrategy reloadStrategy) { this.reloadStrategy = reloadStrategy; } - public String getRouteFilterIncludePattern() { - return routeFilterIncludePattern; - } - - /** - * Used for filtering routes routes matching the given pattern, which follows the following rules: - * - * - Match by route id - * - Match by route input endpoint uri - * - * The matching is using exact match, by wildcard and regular expression as documented by {@link PatternHelper#matchPattern(String, String)}. - * - * For example to only include routes which starts with foo in their route id's, use: include=foo* - * And to exclude routes which starts from JMS endpoints, use: exclude=jms:* - * - * Multiple patterns can be separated by comma, for example to exclude both foo and bar routes, use: exclude=foo*,bar* - * - * Exclude takes precedence over include. - * - * @param include the include pattern - */ - public void setRouteFilterIncludePattern(String include) { - this.routeFilterIncludePattern = include; - } - - public String getRouteFilterExcludePattern() { - return routeFilterExcludePattern; - } - - /** - * Used for filtering routes routes matching the given pattern, which follows the following rules: - * - * - Match by route id - * - Match by route input endpoint uri - * - * The matching is using exact match, by wildcard and regular expression as documented by {@link PatternHelper#matchPattern(String, String)}. - * - * For example to only include routes which starts with foo in their route id's, use: include=foo* - * And to exclude routes which starts from JMS endpoints, use: exclude=jms:* - * - * Multiple patterns can be separated by comma, for example to exclude both foo and bar routes, use: exclude=foo*,bar* - * - * Exclude takes precedence over include. - * - * @param exclude the exclude pattern - */ - public void setRouteFilterExcludePattern(String exclude) { - this.routeFilterExcludePattern = exclude; - } - // fluent builders // -------------------------------------------------------------- @@ -819,397 +190,6 @@ public class MainConfigurationProperties { } /** - * Sets the name of the CamelContext. - */ - public MainConfigurationProperties withName(String name) { - this.name = name; - return this; - } - - /** - * Timeout in seconds to graceful shutdown Camel. - */ - public MainConfigurationProperties withShutdownTimeout(int shutdownTimeout) { - this.shutdownTimeout = shutdownTimeout; - return this; - } - - /** - * Whether Camel should try to suppress logging during shutdown and timeout was triggered, - * meaning forced shutdown is happening. And during forced shutdown we want to avoid logging - * errors/warnings et all in the logs as a side-effect of the forced timeout. - * Notice the suppress is a best effort as there may still be some logs coming - * from 3rd party libraries and whatnot, which Camel cannot control. - * This option is default false. - */ - public MainConfigurationProperties withShutdownSuppressLoggingOnTimeout(boolean shutdownSuppressLoggingOnTimeout) { - this.shutdownSuppressLoggingOnTimeout = shutdownSuppressLoggingOnTimeout; - return this; - } - - /** - * Sets whether to force shutdown of all consumers when a timeout occurred and thus - * not all consumers was shutdown within that period. - * - * You should have good reasons to set this option to false as it means that the routes - * keep running and is halted abruptly when CamelContext has been shutdown. - */ - public MainConfigurationProperties withShutdownNowOnTimeout(boolean shutdownNowOnTimeout) { - this.shutdownNowOnTimeout = shutdownNowOnTimeout; - return this; - } - - /** - * Sets whether routes should be shutdown in reverse or the same order as they where started. - */ - public MainConfigurationProperties withShutdownRoutesInReverseOrder(boolean shutdownRoutesInReverseOrder) { - this.shutdownRoutesInReverseOrder = shutdownRoutesInReverseOrder; - return this; - } - - /** - * Sets whether to log information about the inflight Exchanges which are still running - * during a shutdown which didn't complete without the given timeout. - */ - public MainConfigurationProperties withShutdownLogInflightExchangesOnTimeout(boolean shutdownLogInflightExchangesOnTimeout) { - this.shutdownLogInflightExchangesOnTimeout = shutdownLogInflightExchangesOnTimeout; - return this; - } - - /** - * Enable JMX in your Camel application. - */ - public MainConfigurationProperties withJmxEnabled(boolean jmxEnabled) { - this.jmxEnabled = jmxEnabled; - return this; - } - - /** - * Producer template endpoints cache size. - */ - public MainConfigurationProperties withProducerTemplateCacheSize(int producerTemplateCacheSize) { - this.producerTemplateCacheSize = producerTemplateCacheSize; - return this; - } - - /** - * Consumer template endpoints cache size. - */ - public MainConfigurationProperties withConsumerTemplateCacheSize(int consumerTemplateCacheSize) { - this.consumerTemplateCacheSize = consumerTemplateCacheSize; - return this; - } - - /** - * Directory to load additional configuration files that contains - * configuration values that takes precedence over any other configuration. - * This can be used to refer to files that may have secret configuration that - * has been mounted on the file system for containers. - * - * You can specify a pattern to load from sub directories and a name pattern such as /var/app/secret/*.properties, - * multiple directories can be separated by comma. - */ - public MainConfigurationProperties withFileConfigurations(String fileConfigurations) { - this.fileConfigurations = fileConfigurations; - return this; - } - - /** - * To specify for how long time in seconds to keep running the JVM before automatic terminating the JVM. - * You can use this to run Camel for a short while. - */ - public MainConfigurationProperties withDurationMaxSeconds(int durationMaxSeconds) { - this.durationMaxSeconds = durationMaxSeconds; - return this; - } - - /** - * To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. - * You can use this to run Camel for a short while. - */ - public MainConfigurationProperties withDurationMaxIdleSeconds(int durationMaxIdleSeconds) { - this.durationMaxIdleSeconds = durationMaxIdleSeconds; - return this; - } - - /** - * To specify how many messages to process by Camel before automatic terminating the JVM. - * You can use this to run Camel for a short while. - */ - public MainConfigurationProperties withDurationMaxMessages(int durationMaxMessages) { - this.durationMaxMessages = durationMaxMessages; - return this; - } - - /** - * Is used to limit the maximum length of the logging Camel message bodies. If the message body - * is longer than the limit, the log message is clipped. Use -1 to have unlimited length. - * Use for example 1000 to log at most 1000 characters. - */ - public MainConfigurationProperties withLogDebugMaxChars(int logDebugMaxChars) { - this.logDebugMaxChars = logDebugMaxChars; - return this; - } - - /** - * Sets whether stream caching is enabled or not. - * - * Default is false. - */ - public MainConfigurationProperties withStreamCachingEnabled(boolean streamCachingEnabled) { - this.streamCachingEnabled = streamCachingEnabled; - return this; - } - - /** - * Sets the stream caching spool (temporary) directory to use for overflow and spooling to disk. - * - * If no spool directory has been explicit configured, then a temporary directory - * is created in the java.io.tmpdir directory. - */ - public MainConfigurationProperties withStreamCachingSpoolDirectory(String streamCachingSpoolDirectory) { - this.streamCachingSpoolDirectory = streamCachingSpoolDirectory; - return this; - } - - /** - * Sets a stream caching cipher name to use when spooling to disk to write with encryption. - * By default the data is not encrypted. - */ - public MainConfigurationProperties withStreamCachingSpoolCipher(String streamCachingSpoolCipher) { - this.streamCachingSpoolCipher = streamCachingSpoolCipher; - return this; - } - - /** - * Stream caching threshold in bytes when overflow to disk is activated. - * The default threshold is 128kb. - * Use -1 to disable overflow to disk. - */ - public MainConfigurationProperties withStreamCachingSpoolThreshold(long streamCachingSpoolThreshold) { - this.streamCachingSpoolThreshold = streamCachingSpoolThreshold; - return this; - } - - /** - * Sets a percentage (1-99) of used heap memory threshold to activate stream caching spooling to disk. - */ - public MainConfigurationProperties withStreamCachingSpoolUsedHeapMemoryThreshold(int streamCachingSpoolUsedHeapMemoryThreshold) { - this.streamCachingSpoolUsedHeapMemoryThreshold = streamCachingSpoolUsedHeapMemoryThreshold; - return this; - } - - /** - * Sets what the upper bounds should be when streamCachingSpoolUsedHeapMemoryThreshold is in use. - */ - public MainConfigurationProperties withStreamCachingSpoolUsedHeapMemoryLimit(String streamCachingSpoolUsedHeapMemoryLimit) { - this.streamCachingSpoolUsedHeapMemoryLimit = streamCachingSpoolUsedHeapMemoryLimit; - return this; - } - - /** - * Sets whether if just any of the org.apache.camel.spi.StreamCachingStrategy.SpoolRule rules - * returns true then shouldSpoolCache(long) returns true, to allow spooling to disk. - * If this option is false, then all the org.apache.camel.spi.StreamCachingStrategy.SpoolRule must - * return true. - * - * The default value is false which means that all the rules must return true. - */ - public MainConfigurationProperties withStreamCachingAnySpoolRules(boolean streamCachingAnySpoolRules) { - this.streamCachingAnySpoolRules = streamCachingAnySpoolRules; - return this; - } - - /** - * Sets the stream caching buffer size to use when allocating in-memory buffers used for in-memory stream caches. - * - * The default size is 4096. - */ - public MainConfigurationProperties withStreamCachingBufferSize(int streamCachingBufferSize) { - this.streamCachingBufferSize = streamCachingBufferSize; - return this; - } - - /** - * Whether to remove stream caching temporary directory when stopping. - * This option is default true. - */ - public MainConfigurationProperties withStreamCachingRemoveSpoolDirectoryWhenStopping(boolean streamCachingRemoveSpoolDirectoryWhenStopping) { - this.streamCachingRemoveSpoolDirectoryWhenStopping = streamCachingRemoveSpoolDirectoryWhenStopping; - return this; - } - - /** - * Sets whether stream caching statistics is enabled. - */ - public MainConfigurationProperties withStreamCachingStatisticsEnabled(boolean streamCachingStatisticsEnabled) { - this.streamCachingStatisticsEnabled = streamCachingStatisticsEnabled; - return this; - } - - /** - * Sets whether tracing is enabled or not. - * - * Default is false. - */ - public MainConfigurationProperties withTracing(boolean tracing) { - this.tracing = tracing; - return this; - } - - /** - * Sets whether message history is enabled or not. - * - * Default is true. - */ - public MainConfigurationProperties withMessageHistory(boolean messageHistory) { - this.messageHistory = messageHistory; - return this; - } - - /** - * Sets whether log mask is enabled or not. - * - * Default is false. - */ - public MainConfigurationProperties withLogMask(boolean logMask) { - this.logMask = logMask; - return this; - } - - /** - * Sets whether to log exhausted message body with message history. - * - * Default is false. - */ - public MainConfigurationProperties withLogExhaustedMessageBody(boolean logExhaustedMessageBody) { - this.logExhaustedMessageBody = logExhaustedMessageBody; - return this; - } - - /** - * Sets whether fault handling is enabled or not. - * - * Default is false. - */ - public MainConfigurationProperties withHandleFault(boolean handleFault) { - this.handleFault = handleFault; - return this; - } - - /** - * Sets whether the object should automatically start when Camel starts. - * Important: Currently only routes can be disabled, as CamelContext's are always started. - * Note: When setting auto startup false on CamelContext then that takes precedence - * and no routes is started. You would need to start CamelContext explicit using - * the org.apache.camel.CamelContext.start() method, to start the context, and then - * you would need to start the routes manually using CamelContext.getRouteController().startRoute(String). - * - * Default is true to always start up. - */ - public MainConfigurationProperties withAutoStartup(boolean autoStartup) { - this.autoStartup = autoStartup; - return this; - } - - /** - * Sets whether to allow access to the original message from Camel's error handler, - * or from org.apache.camel.spi.UnitOfWork.getOriginalInMessage(). - * Turning this off can optimize performance, as defensive copy of the original message is not needed. - * - * Default is false. - */ - public MainConfigurationProperties withAllowUseOriginalMessage(boolean allowUseOriginalMessage) { - this.allowUseOriginalMessage = allowUseOriginalMessage; - return this; - } - - /** - * Sets whether endpoint runtime statistics is enabled (gathers runtime usage of each incoming and outgoing endpoints). - * - * The default value is false. - */ - public MainConfigurationProperties withEndpointRuntimeStatisticsEnabled(boolean endpointRuntimeStatisticsEnabled) { - this.endpointRuntimeStatisticsEnabled = endpointRuntimeStatisticsEnabled; - return this; - } - - /** - * Whether to enable using data type on Camel messages. - * - * Data type are automatic turned on if one ore more routes has been explicit configured with input and output types. - * Otherwise data type is default off. - */ - public MainConfigurationProperties withUseDataType(boolean useDataType) { - this.useDataType = useDataType; - return this; - } - - /** - * Set whether breadcrumb is enabled. - * The default value is false. - */ - public MainConfigurationProperties withUseBreadcrumb(boolean useBreadcrumb) { - this.useBreadcrumb = useBreadcrumb; - return this; - } - - /** - * Sets the JMX statistics level - * The level can be set to Extended to gather additional information - * - * The default value is Default. - */ - public MainConfigurationProperties withJmxManagementStatisticsLevel(ManagementStatisticsLevel jmxManagementStatisticsLevel) { - this.jmxManagementStatisticsLevel = jmxManagementStatisticsLevel; - return this; - } - - /** - * The naming pattern for creating the CamelContext JMX management name. - * - * The default pattern is #name# - */ - public MainConfigurationProperties withJmxManagementNamePattern(String jmxManagementNamePattern) { - this.jmxManagementNamePattern = jmxManagementNamePattern; - return this; - } - - /** - * Whether JMX connector is created, allowing clients to connect remotely - * - * The default value is false. - */ - public MainConfigurationProperties withJmxCreateConnector(boolean jmxCreateConnector) { - this.jmxCreateConnector = jmxCreateConnector; - return this; - } - - /** - * To turn on MDC logging - */ - public MainConfigurationProperties withUseMdcLogging(boolean useMdcLogging) { - this.useMdcLogging = useMdcLogging; - return this; - } - - /** - * Sets the thread name pattern used for creating the full thread name. - * - * The default pattern is: Camel (#camelId#) thread ##counter# - #name# - * - * Where #camelId# is the name of the CamelContext. - * and #counter# is a unique incrementing counter. - * and #name# is the regular thread name. - * - * You can also use #longName# which is the long thread name which can includes endpoint parameters etc. - */ - public MainConfigurationProperties withThreadNamePattern(String threadNamePattern) { - this.threadNamePattern = threadNamePattern; - return this; - } - - /** * Sets the duration (in seconds) to run the application until it * should be terminated. Defaults to -1. Any value <= 0 will run forever. */ @@ -1235,26 +215,6 @@ public class MainConfigurationProperties { } /** - * Sets the directory name to watch XML file changes to trigger live reload of Camel routes. - * <p/> - * Notice you cannot set this value and a custom {@link ReloadStrategy} as well. - */ - public MainConfigurationProperties withFileWatchDirectory(String fileWatchDirectory) { - this.fileWatchDirectory = fileWatchDirectory; - return this; - } - - /** - * Sets the flag to watch directory of XML file changes recursively to trigger live reload of Camel routes. - * <p/> - * Notice you cannot set this value and a custom {@link ReloadStrategy} as well. - */ - public MainConfigurationProperties withFileWatchDirectoryRecursively(boolean fileWatchDirectoryRecursively) { - this.fileWatchDirectoryRecursively = fileWatchDirectoryRecursively; - return this; - } - - /** * Sets a custom {@link ReloadStrategy} to be used. * <p/> * Notice you cannot set this value and the fileWatchDirectory as well. @@ -1264,44 +224,4 @@ public class MainConfigurationProperties { return this; } - - /** - * Used for filtering routes routes matching the given pattern, which follows the following rules: - * - * - Match by route id - * - Match by route input endpoint uri - * - * The matching is using exact match, by wildcard and regular expression as documented by {@link PatternHelper#matchPattern(String, String)}. - * - * For example to only include routes which starts with foo in their route id's, use: include=foo* - * And to exclude routes which starts from JMS endpoints, use: exclude=jms:* - * - * Multiple patterns can be separated by comma, for example to exclude both foo and bar routes, use: exclude=foo*,bar* - * - * Exclude takes precedence over include. - */ - public MainConfigurationProperties withRouteFilterIncludePattern(String routeFilterIncludePattern) { - this.routeFilterIncludePattern = routeFilterIncludePattern; - return this; - } - - /** - * Used for filtering routes routes matching the given pattern, which follows the following rules: - * - * - Match by route id - * - Match by route input endpoint uri - * - * The matching is using exact match, by wildcard and regular expression as documented by {@link PatternHelper#matchPattern(String, String)}. - * - * For example to only include routes which starts with foo in their route id's, use: include=foo* - * And to exclude routes which starts from JMS endpoints, use: exclude=jms:* - * - * Multiple patterns can be separated by comma, for example to exclude both foo and bar routes, use: exclude=foo*,bar* - * - * Exclude takes precedence over include. - */ - public MainConfigurationProperties withRouteFilterExcludePattern(String routeFilterExcludePattern) { - this.routeFilterExcludePattern = routeFilterExcludePattern; - return this; - } } diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java index ab5fc17..cbf64b7 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java @@ -205,7 +205,7 @@ public abstract class MainSupport extends ServiceSupport { "fileWatch") { @Override protected void doProcess(String arg, String parameter, LinkedList<String> remainingArgs) { - configure().setFileWatchDirectory(parameter); + configure().setXmlRoutesReloadDirectory(parameter); } }); addOption(new ParameterOption("pl", "propertiesLocation", @@ -502,7 +502,7 @@ public abstract class MainSupport extends ServiceSupport { @Deprecated public String getFileWatchDirectory() { - return mainConfigurationProperties.getFileWatchDirectory(); + return mainConfigurationProperties.getXmlRoutesReloadDirectory(); } /** @@ -513,12 +513,12 @@ public abstract class MainSupport extends ServiceSupport { */ @Deprecated public void setFileWatchDirectory(String fileWatchDirectory) { - mainConfigurationProperties.setFileWatchDirectory(fileWatchDirectory); + mainConfigurationProperties.setXmlRoutesReloadDirectory(fileWatchDirectory); } @Deprecated public boolean isFileWatchDirectoryRecursively() { - return mainConfigurationProperties.isFileWatchDirectoryRecursively(); + return mainConfigurationProperties.isXmlRoutesReloadDirectoryRecursively(); } /** @@ -529,7 +529,7 @@ public abstract class MainSupport extends ServiceSupport { */ @Deprecated public void setFileWatchDirectoryRecursively(boolean fileWatchDirectoryRecursively) { - mainConfigurationProperties.setFileWatchDirectoryRecursively(fileWatchDirectoryRecursively); + mainConfigurationProperties.setXmlRoutesReloadDirectoryRecursively(fileWatchDirectoryRecursively); } @Deprecated @@ -802,8 +802,8 @@ public abstract class MainSupport extends ServiceSupport { } LOG.info("Using optional properties from classpath:application.properties"); } - if (mainConfigurationProperties.getFileWatchDirectory() != null) { - ReloadStrategy reload = new FileWatcherReloadStrategy(mainConfigurationProperties.getFileWatchDirectory(), mainConfigurationProperties.isFileWatchDirectoryRecursively()); + if (mainConfigurationProperties.getXmlRoutesReloadDirectory() != null) { + ReloadStrategy reload = new FileWatcherReloadStrategy(mainConfigurationProperties.getXmlRoutesReloadDirectory(), mainConfigurationProperties.isXmlRoutesReloadDirectoryRecursively()); camelContext.setReloadStrategy(reload); // ensure reload is added as service and started camelContext.addService(reload);