You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/03/27 15:05:00 UTC
camel git commit: CAMEL-11067: camel-hystrix - Include default values
in spring-boot auto configuration
Repository: camel
Updated Branches:
refs/heads/master f28c95c86 -> cbbe9668b
CAMEL-11067: camel-hystrix - Include default values in spring-boot auto configuration
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cbbe9668
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cbbe9668
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cbbe9668
Branch: refs/heads/master
Commit: cbbe9668b911c751d94d7cef2e978d6d1e35be54
Parents: f28c95c
Author: lburgazzoli <lb...@gmail.com>
Authored: Mon Mar 27 17:02:52 2017 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Mon Mar 27 17:04:27 2017 +0200
----------------------------------------------------------------------
.../HystrixConfigurationDefinitionCommon.java | 480 +++++++++++++++++++
...ystrixConfigurationDefinitionProperties.java | 48 ++
.../springboot/HystrixAutoConfiguration.java | 38 +-
.../springboot/HystrixConfiguration.java | 35 --
.../src/test/resources/application.properties | 0
.../camel/maven/packaging/PackageHelper.java | 8 +
.../SpringBootAutoConfigurationMojo.java | 166 ++++++-
.../camel/maven/packaging/SpringBootHelper.java | 2 -
.../camel/maven/packaging/model/OtherModel.java | 36 ++
.../maven/packaging/model/OtherOptionModel.java | 203 ++++++++
10 files changed, 951 insertions(+), 65 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/cbbe9668/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/springboot/HystrixConfigurationDefinitionCommon.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/springboot/HystrixConfigurationDefinitionCommon.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/springboot/HystrixConfigurationDefinitionCommon.java
new file mode 100644
index 0000000..7947788
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/springboot/HystrixConfigurationDefinitionCommon.java
@@ -0,0 +1,480 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model.springboot;
+/**
+ * Hystrix Circuit Breaker EIP configuration
+ *
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+public class HystrixConfigurationDefinitionCommon {
+
+ /**
+ * Sets the group key to use. The default value is CamelHystrix.
+ */
+ private String groupKey = "CamelHystrix";
+ /**
+ * Sets the thread pool key to use. Will by default use the same value as
+ * groupKey has been configured to use.
+ */
+ private String threadPoolKey = "CamelHystrix";
+ /**
+ * Whether to use a HystrixCircuitBreaker or not. If false no
+ * circuit-breaker logic will be used and all requests permitted. This is
+ * similar in effect to circuitBreakerForceClosed() except that continues
+ * tracking metrics and knowing whether it should be open/closed this
+ * property results in not even instantiating a circuit-breaker.
+ */
+ private Boolean circuitBreakerEnabled = true;
+ /**
+ * Error percentage threshold (as whole number such as 50) at which point
+ * the circuit breaker will trip open and reject requests. It will stay
+ * tripped for the duration defined in
+ * circuitBreakerSleepWindowInMilliseconds; The error percentage this is
+ * compared against comes from HystrixCommandMetrics.getHealthCounts().
+ */
+ private Integer circuitBreakerErrorThresholdPercentage = 50;
+ /**
+ * If true the HystrixCircuitBreakerallowRequest() will always return true
+ * to allow requests regardless of the error percentage from
+ * HystrixCommandMetrics.getHealthCounts(). The circuitBreakerForceOpen()
+ * property takes precedence so if it set to true this property does
+ * nothing.
+ */
+ private Boolean circuitBreakerForceClosed = true;
+ /**
+ * If true the HystrixCircuitBreaker.allowRequest() will always return false
+ * causing the circuit to be open (tripped) and reject all requests. This
+ * property takes precedence over circuitBreakerForceClosed();
+ */
+ private Boolean circuitBreakerForceOpen = false;
+ /**
+ * Minimum number of requests in the
+ * metricsRollingStatisticalWindowInMilliseconds() that must exist before
+ * the HystrixCircuitBreaker will trip. If below this number the circuit
+ * will not trip regardless of error percentage.
+ */
+ private Integer circuitBreakerRequestVolumeThreshold = 20;
+ /**
+ * The time in milliseconds after a HystrixCircuitBreaker trips open that it
+ * should wait before trying requests again.
+ */
+ private Integer circuitBreakerSleepWindowInMilliseconds = 5000;
+ /**
+ * Number of concurrent requests permitted to HystrixCommand.run(). Requests
+ * beyond the concurrent limit will be rejected. Applicable only when
+ * executionIsolationStrategy == SEMAPHORE.
+ */
+ private Integer executionIsolationSemaphoreMaxConcurrentRequests = 20;
+ /**
+ * What isolation strategy HystrixCommand.run() will be executed with. If
+ * THREAD then it will be executed on a separate thread and concurrent
+ * requests limited by the number of threads in the thread-pool. If
+ * SEMAPHORE then it will be executed on the calling thread and concurrent
+ * requests limited by the semaphore count.
+ */
+ private String executionIsolationStrategy = "THREAD";
+ /**
+ * Whether the execution thread should attempt an interrupt (using link
+ * Futurecancel) when a thread times out. Applicable only when
+ * executionIsolationStrategy() == THREAD.
+ */
+ private Boolean executionIsolationThreadInterruptOnTimeout = true;
+ /**
+ * Time in milliseconds at which point the command will timeout and halt
+ * execution. If link executionIsolationThreadInterruptOnTimeout == true and
+ * the command is thread-isolated the executing thread will be interrupted.
+ * If the command is semaphore-isolated and a HystrixObservableCommand that
+ * command will get unsubscribed.
+ */
+ private Integer executionTimeoutInMilliseconds = 1000;
+ /**
+ * Whether the timeout mechanism is enabled for this command
+ */
+ private Boolean executionTimeoutEnabled = true;
+ /**
+ * Number of concurrent requests permitted to HystrixCommand.getFallback().
+ * Requests beyond the concurrent limit will fail-fast and not attempt
+ * retrieving a fallback.
+ */
+ private Integer fallbackIsolationSemaphoreMaxConcurrentRequests = 10;
+ /**
+ * Whether HystrixCommand.getFallback() should be attempted when failure
+ * occurs.
+ */
+ private Boolean fallbackEnabled = true;
+ /**
+ * Time in milliseconds to wait between allowing health snapshots to be
+ * taken that calculate success and error percentages and affect
+ * HystrixCircuitBreaker.isOpen() status. On high-volume circuits the
+ * continual calculation of error percentage can become CPU intensive thus
+ * this controls how often it is calculated.
+ */
+ private Integer metricsHealthSnapshotIntervalInMilliseconds = 500;
+ /**
+ * Maximum number of values stored in each bucket of the rolling percentile.
+ * This is passed into HystrixRollingPercentile inside
+ * HystrixCommandMetrics.
+ */
+ private Integer metricsRollingPercentileBucketSize = 10;
+ /**
+ * Whether percentile metrics should be captured using
+ * HystrixRollingPercentile inside HystrixCommandMetrics.
+ */
+ private Boolean metricsRollingPercentileEnabled = true;
+ /**
+ * Duration of percentile rolling window in milliseconds. This is passed
+ * into HystrixRollingPercentile inside HystrixCommandMetrics.
+ */
+ private Integer metricsRollingPercentileWindowInMilliseconds = 10000;
+ /**
+ * Number of buckets the rolling percentile window is broken into. This is
+ * passed into HystrixRollingPercentile inside HystrixCommandMetrics.
+ */
+ private Integer metricsRollingPercentileWindowBuckets = 6;
+ /**
+ * This property sets the duration of the statistical rolling window in
+ * milliseconds. This is how long metrics are kept for the thread pool. The
+ * window is divided into buckets and rolls by those increments.
+ */
+ private Integer metricsRollingStatisticalWindowInMilliseconds = 10000;
+ /**
+ * Number of buckets the rolling statistical window is broken into. This is
+ * passed into HystrixRollingNumber inside HystrixCommandMetrics.
+ */
+ private Integer metricsRollingStatisticalWindowBuckets = 10;
+ /**
+ * Whether HystrixCommand execution and events should be logged to
+ * HystrixRequestLog.
+ */
+ private Boolean requestLogEnabled = true;
+ /**
+ * Core thread-pool size that gets passed to link
+ * java.util.concurrent.ThreadPoolExecutorsetCorePoolSize(int)
+ */
+ private Integer corePoolSize = 10;
+ /**
+ * Maximum thread-pool size that gets passed to link
+ * ThreadPoolExecutorsetMaximumPoolSize(int). This is the maximum amount of
+ * concurrency that can be supported without starting to reject
+ * HystrixCommands. Please note that this setting only takes effect if you
+ * also set allowMaximumSizeToDivergeFromCoreSize
+ */
+ private Integer maximumSize = 10;
+ /**
+ * Keep-alive time in minutes that gets passed to link
+ * ThreadPoolExecutorsetKeepAliveTime(long TimeUnit)
+ */
+ private Integer keepAliveTime = 1;
+ /**
+ * Max queue size that gets passed to BlockingQueue in
+ * HystrixConcurrencyStrategy.getBlockingQueue(int) This should only affect
+ * the instantiation of a threadpool - it is not eliglible to change a queue
+ * size on the fly. For that use queueSizeRejectionThreshold().
+ */
+ private Integer maxQueueSize = -1;
+ /**
+ * Queue size rejection threshold is an artificial max size at which
+ * rejections will occur even if link maxQueueSize has not been reached.
+ * This is done because the link maxQueueSize of a BlockingQueue can not be
+ * dynamically changed and we want to support dynamically changing the queue
+ * size that affects rejections. This is used by HystrixCommand when queuing
+ * a thread for execution.
+ */
+ private Integer queueSizeRejectionThreshold = 5;
+ /**
+ * Duration of statistical rolling window in milliseconds. This is passed
+ * into HystrixRollingNumber inside each HystrixThreadPoolMetrics instance.
+ */
+ private Integer threadPoolRollingNumberStatisticalWindowInMilliseconds = 10000;
+ /**
+ * Number of buckets the rolling statistical window is broken into. This is
+ * passed into HystrixRollingNumber inside each HystrixThreadPoolMetrics
+ * instance.
+ */
+ private Integer threadPoolRollingNumberStatisticalWindowBuckets = 10;
+ /**
+ * Allows the configuration for maximumSize to take effect. That value can
+ * then be equal to or higher than coreSize
+ */
+ private Boolean allowMaximumSizeToDivergeFromCoreSize = false;
+
+ public String getGroupKey() {
+ return groupKey;
+ }
+
+ public void setGroupKey(String groupKey) {
+ this.groupKey = groupKey;
+ }
+
+ public String getThreadPoolKey() {
+ return threadPoolKey;
+ }
+
+ public void setThreadPoolKey(String threadPoolKey) {
+ this.threadPoolKey = threadPoolKey;
+ }
+
+ public Boolean getCircuitBreakerEnabled() {
+ return circuitBreakerEnabled;
+ }
+
+ public void setCircuitBreakerEnabled(Boolean circuitBreakerEnabled) {
+ this.circuitBreakerEnabled = circuitBreakerEnabled;
+ }
+
+ public Integer getCircuitBreakerErrorThresholdPercentage() {
+ return circuitBreakerErrorThresholdPercentage;
+ }
+
+ public void setCircuitBreakerErrorThresholdPercentage(
+ Integer circuitBreakerErrorThresholdPercentage) {
+ this.circuitBreakerErrorThresholdPercentage = circuitBreakerErrorThresholdPercentage;
+ }
+
+ public Boolean getCircuitBreakerForceClosed() {
+ return circuitBreakerForceClosed;
+ }
+
+ public void setCircuitBreakerForceClosed(Boolean circuitBreakerForceClosed) {
+ this.circuitBreakerForceClosed = circuitBreakerForceClosed;
+ }
+
+ public Boolean getCircuitBreakerForceOpen() {
+ return circuitBreakerForceOpen;
+ }
+
+ public void setCircuitBreakerForceOpen(Boolean circuitBreakerForceOpen) {
+ this.circuitBreakerForceOpen = circuitBreakerForceOpen;
+ }
+
+ public Integer getCircuitBreakerRequestVolumeThreshold() {
+ return circuitBreakerRequestVolumeThreshold;
+ }
+
+ public void setCircuitBreakerRequestVolumeThreshold(
+ Integer circuitBreakerRequestVolumeThreshold) {
+ this.circuitBreakerRequestVolumeThreshold = circuitBreakerRequestVolumeThreshold;
+ }
+
+ public Integer getCircuitBreakerSleepWindowInMilliseconds() {
+ return circuitBreakerSleepWindowInMilliseconds;
+ }
+
+ public void setCircuitBreakerSleepWindowInMilliseconds(
+ Integer circuitBreakerSleepWindowInMilliseconds) {
+ this.circuitBreakerSleepWindowInMilliseconds = circuitBreakerSleepWindowInMilliseconds;
+ }
+
+ public Integer getExecutionIsolationSemaphoreMaxConcurrentRequests() {
+ return executionIsolationSemaphoreMaxConcurrentRequests;
+ }
+
+ public void setExecutionIsolationSemaphoreMaxConcurrentRequests(
+ Integer executionIsolationSemaphoreMaxConcurrentRequests) {
+ this.executionIsolationSemaphoreMaxConcurrentRequests = executionIsolationSemaphoreMaxConcurrentRequests;
+ }
+
+ public String getExecutionIsolationStrategy() {
+ return executionIsolationStrategy;
+ }
+
+ public void setExecutionIsolationStrategy(String executionIsolationStrategy) {
+ this.executionIsolationStrategy = executionIsolationStrategy;
+ }
+
+ public Boolean getExecutionIsolationThreadInterruptOnTimeout() {
+ return executionIsolationThreadInterruptOnTimeout;
+ }
+
+ public void setExecutionIsolationThreadInterruptOnTimeout(
+ Boolean executionIsolationThreadInterruptOnTimeout) {
+ this.executionIsolationThreadInterruptOnTimeout = executionIsolationThreadInterruptOnTimeout;
+ }
+
+ public Integer getExecutionTimeoutInMilliseconds() {
+ return executionTimeoutInMilliseconds;
+ }
+
+ public void setExecutionTimeoutInMilliseconds(
+ Integer executionTimeoutInMilliseconds) {
+ this.executionTimeoutInMilliseconds = executionTimeoutInMilliseconds;
+ }
+
+ public Boolean getExecutionTimeoutEnabled() {
+ return executionTimeoutEnabled;
+ }
+
+ public void setExecutionTimeoutEnabled(Boolean executionTimeoutEnabled) {
+ this.executionTimeoutEnabled = executionTimeoutEnabled;
+ }
+
+ public Integer getFallbackIsolationSemaphoreMaxConcurrentRequests() {
+ return fallbackIsolationSemaphoreMaxConcurrentRequests;
+ }
+
+ public void setFallbackIsolationSemaphoreMaxConcurrentRequests(
+ Integer fallbackIsolationSemaphoreMaxConcurrentRequests) {
+ this.fallbackIsolationSemaphoreMaxConcurrentRequests = fallbackIsolationSemaphoreMaxConcurrentRequests;
+ }
+
+ public Boolean getFallbackEnabled() {
+ return fallbackEnabled;
+ }
+
+ public void setFallbackEnabled(Boolean fallbackEnabled) {
+ this.fallbackEnabled = fallbackEnabled;
+ }
+
+ public Integer getMetricsHealthSnapshotIntervalInMilliseconds() {
+ return metricsHealthSnapshotIntervalInMilliseconds;
+ }
+
+ public void setMetricsHealthSnapshotIntervalInMilliseconds(
+ Integer metricsHealthSnapshotIntervalInMilliseconds) {
+ this.metricsHealthSnapshotIntervalInMilliseconds = metricsHealthSnapshotIntervalInMilliseconds;
+ }
+
+ public Integer getMetricsRollingPercentileBucketSize() {
+ return metricsRollingPercentileBucketSize;
+ }
+
+ public void setMetricsRollingPercentileBucketSize(
+ Integer metricsRollingPercentileBucketSize) {
+ this.metricsRollingPercentileBucketSize = metricsRollingPercentileBucketSize;
+ }
+
+ public Boolean getMetricsRollingPercentileEnabled() {
+ return metricsRollingPercentileEnabled;
+ }
+
+ public void setMetricsRollingPercentileEnabled(
+ Boolean metricsRollingPercentileEnabled) {
+ this.metricsRollingPercentileEnabled = metricsRollingPercentileEnabled;
+ }
+
+ public Integer getMetricsRollingPercentileWindowInMilliseconds() {
+ return metricsRollingPercentileWindowInMilliseconds;
+ }
+
+ public void setMetricsRollingPercentileWindowInMilliseconds(
+ Integer metricsRollingPercentileWindowInMilliseconds) {
+ this.metricsRollingPercentileWindowInMilliseconds = metricsRollingPercentileWindowInMilliseconds;
+ }
+
+ public Integer getMetricsRollingPercentileWindowBuckets() {
+ return metricsRollingPercentileWindowBuckets;
+ }
+
+ public void setMetricsRollingPercentileWindowBuckets(
+ Integer metricsRollingPercentileWindowBuckets) {
+ this.metricsRollingPercentileWindowBuckets = metricsRollingPercentileWindowBuckets;
+ }
+
+ public Integer getMetricsRollingStatisticalWindowInMilliseconds() {
+ return metricsRollingStatisticalWindowInMilliseconds;
+ }
+
+ public void setMetricsRollingStatisticalWindowInMilliseconds(
+ Integer metricsRollingStatisticalWindowInMilliseconds) {
+ this.metricsRollingStatisticalWindowInMilliseconds = metricsRollingStatisticalWindowInMilliseconds;
+ }
+
+ public Integer getMetricsRollingStatisticalWindowBuckets() {
+ return metricsRollingStatisticalWindowBuckets;
+ }
+
+ public void setMetricsRollingStatisticalWindowBuckets(
+ Integer metricsRollingStatisticalWindowBuckets) {
+ this.metricsRollingStatisticalWindowBuckets = metricsRollingStatisticalWindowBuckets;
+ }
+
+ public Boolean getRequestLogEnabled() {
+ return requestLogEnabled;
+ }
+
+ public void setRequestLogEnabled(Boolean requestLogEnabled) {
+ this.requestLogEnabled = requestLogEnabled;
+ }
+
+ public Integer getCorePoolSize() {
+ return corePoolSize;
+ }
+
+ public void setCorePoolSize(Integer corePoolSize) {
+ this.corePoolSize = corePoolSize;
+ }
+
+ public Integer getMaximumSize() {
+ return maximumSize;
+ }
+
+ public void setMaximumSize(Integer maximumSize) {
+ this.maximumSize = maximumSize;
+ }
+
+ public Integer getKeepAliveTime() {
+ return keepAliveTime;
+ }
+
+ public void setKeepAliveTime(Integer keepAliveTime) {
+ this.keepAliveTime = keepAliveTime;
+ }
+
+ public Integer getMaxQueueSize() {
+ return maxQueueSize;
+ }
+
+ public void setMaxQueueSize(Integer maxQueueSize) {
+ this.maxQueueSize = maxQueueSize;
+ }
+
+ public Integer getQueueSizeRejectionThreshold() {
+ return queueSizeRejectionThreshold;
+ }
+
+ public void setQueueSizeRejectionThreshold(
+ Integer queueSizeRejectionThreshold) {
+ this.queueSizeRejectionThreshold = queueSizeRejectionThreshold;
+ }
+
+ public Integer getThreadPoolRollingNumberStatisticalWindowInMilliseconds() {
+ return threadPoolRollingNumberStatisticalWindowInMilliseconds;
+ }
+
+ public void setThreadPoolRollingNumberStatisticalWindowInMilliseconds(
+ Integer threadPoolRollingNumberStatisticalWindowInMilliseconds) {
+ this.threadPoolRollingNumberStatisticalWindowInMilliseconds = threadPoolRollingNumberStatisticalWindowInMilliseconds;
+ }
+
+ public Integer getThreadPoolRollingNumberStatisticalWindowBuckets() {
+ return threadPoolRollingNumberStatisticalWindowBuckets;
+ }
+
+ public void setThreadPoolRollingNumberStatisticalWindowBuckets(
+ Integer threadPoolRollingNumberStatisticalWindowBuckets) {
+ this.threadPoolRollingNumberStatisticalWindowBuckets = threadPoolRollingNumberStatisticalWindowBuckets;
+ }
+
+ public Boolean getAllowMaximumSizeToDivergeFromCoreSize() {
+ return allowMaximumSizeToDivergeFromCoreSize;
+ }
+
+ public void setAllowMaximumSizeToDivergeFromCoreSize(
+ Boolean allowMaximumSizeToDivergeFromCoreSize) {
+ this.allowMaximumSizeToDivergeFromCoreSize = allowMaximumSizeToDivergeFromCoreSize;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cbbe9668/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/springboot/HystrixConfigurationDefinitionProperties.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/springboot/HystrixConfigurationDefinitionProperties.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/springboot/HystrixConfigurationDefinitionProperties.java
new file mode 100644
index 0000000..0daa611
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/model/springboot/HystrixConfigurationDefinitionProperties.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model.springboot;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@ConfigurationProperties(prefix = "camel.hystrix")
+public class HystrixConfigurationDefinitionProperties
+ extends
+ HystrixConfigurationDefinitionCommon {
+
+ /**
+ * Enable camel-hystrix
+ */
+ private boolean enabled = true;
+ /**
+ * Define additional configuration definitions
+ */
+ private Map<String, HystrixConfigurationDefinitionCommon> configurations = new HashMap<>();
+
+ public Map<String, HystrixConfigurationDefinitionCommon> getConfigurations() {
+ return configurations;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cbbe9668/platforms/spring-boot/components-starter/camel-hystrix-starter/src/main/java/org/apache/camel/component/hystrix/springboot/HystrixAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-hystrix-starter/src/main/java/org/apache/camel/component/hystrix/springboot/HystrixAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hystrix-starter/src/main/java/org/apache/camel/component/hystrix/springboot/HystrixAutoConfiguration.java
index a486065..5bb3887 100644
--- a/platforms/spring-boot/components-starter/camel-hystrix-starter/src/main/java/org/apache/camel/component/hystrix/springboot/HystrixAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-hystrix-starter/src/main/java/org/apache/camel/component/hystrix/springboot/HystrixAutoConfiguration.java
@@ -22,16 +22,12 @@ import javax.annotation.PostConstruct;
import org.apache.camel.CamelContext;
import org.apache.camel.component.hystrix.processor.HystrixConstants;
-import org.apache.camel.model.HystrixConfigurationCommon;
import org.apache.camel.model.HystrixConfigurationDefinition;
+import org.apache.camel.model.springboot.HystrixConfigurationDefinitionCommon;
+import org.apache.camel.model.springboot.HystrixConfigurationDefinitionProperties;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.apache.camel.util.IntrospectionSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanCreationException;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@@ -50,21 +46,14 @@ import org.springframework.context.annotation.Configuration;
@ConditionalOnProperty(name = "camel.hystrix.enabled", matchIfMissing = true)
@ConditionalOnBean(value = CamelAutoConfiguration.class)
@AutoConfigureAfter(value = CamelAutoConfiguration.class)
-@EnableConfigurationProperties(HystrixConfiguration.class)
-public class HystrixAutoConfiguration implements BeanFactoryAware {
- private static final Logger LOGGER = LoggerFactory.getLogger(HystrixAutoConfiguration.class);
-
- private BeanFactory beanFactory;
-
+@EnableConfigurationProperties(HystrixConfigurationDefinitionProperties.class)
+public class HystrixAutoConfiguration {
+ @Autowired
+ private ConfigurableBeanFactory beanFactory;
@Autowired
private CamelContext camelContext;
@Autowired
- private HystrixConfiguration config;
-
- @Override
- public void setBeanFactory(BeanFactory factory) throws BeansException {
- beanFactory = factory;
- }
+ private HystrixConfigurationDefinitionProperties config;
@Bean(name = HystrixConstants.DEFAULT_HYSTRIX_CONFIGURATION_ID)
@ConditionalOnClass(CamelContext.class)
@@ -73,7 +62,6 @@ public class HystrixAutoConfiguration implements BeanFactoryAware {
Map<String, Object> properties = new HashMap<>();
IntrospectionSupport.getProperties(config, properties, null, false);
-
HystrixConfigurationDefinition definition = new HystrixConfigurationDefinition();
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), definition, properties);
@@ -81,16 +69,14 @@ public class HystrixAutoConfiguration implements BeanFactoryAware {
}
@PostConstruct
- public void addHystrixConfigurations() {
- if (!(beanFactory instanceof ConfigurableBeanFactory)) {
- LOGGER.warn("BeanFactory is not of type ConfigurableBeanFactory");
+ public void postConstruct() {
+ if (beanFactory == null) {
return;
}
- final ConfigurableBeanFactory factory = (ConfigurableBeanFactory) beanFactory;
- final Map<String, Object> properties = new HashMap<>();
+ Map<String, Object> properties = new HashMap<>();
- for (Map.Entry<String, HystrixConfigurationCommon> entry : config.getConfigurations().entrySet()) {
+ for (Map.Entry<String, HystrixConfigurationDefinitionCommon> entry : config.getConfigurations().entrySet()) {
// clear the properties map for reuse
properties.clear();
@@ -103,7 +89,7 @@ public class HystrixAutoConfiguration implements BeanFactoryAware {
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), definition, properties);
// Registry the definition
- factory.registerSingleton(entry.getKey(), definition);
+ beanFactory.registerSingleton(entry.getKey(), definition);
} catch (Exception e) {
throw new BeanCreationException(entry.getKey(), e);
http://git-wip-us.apache.org/repos/asf/camel/blob/cbbe9668/platforms/spring-boot/components-starter/camel-hystrix-starter/src/main/java/org/apache/camel/component/hystrix/springboot/HystrixConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-hystrix-starter/src/main/java/org/apache/camel/component/hystrix/springboot/HystrixConfiguration.java b/platforms/spring-boot/components-starter/camel-hystrix-starter/src/main/java/org/apache/camel/component/hystrix/springboot/HystrixConfiguration.java
deleted file mode 100644
index deb402c..0000000
--- a/platforms/spring-boot/components-starter/camel-hystrix-starter/src/main/java/org/apache/camel/component/hystrix/springboot/HystrixConfiguration.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.hystrix.springboot;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.camel.model.HystrixConfigurationCommon;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-/**
- * Hystrix component.
- */
-@ConfigurationProperties(prefix = "camel.hystrix")
-public class HystrixConfiguration extends HystrixConfigurationCommon {
- private Map<String, HystrixConfigurationCommon> configurations = new HashMap<>();
-
- public Map<String, HystrixConfigurationCommon> getConfigurations() {
- return configurations;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/cbbe9668/platforms/spring-boot/components-starter/camel-hystrix-starter/src/test/resources/application.properties
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-hystrix-starter/src/test/resources/application.properties b/platforms/spring-boot/components-starter/camel-hystrix-starter/src/test/resources/application.properties
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/camel/blob/cbbe9668/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java
index 5d421b9..53cc0ec 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java
@@ -27,6 +27,7 @@ import java.io.LineNumberReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import java.util.TreeSet;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.logging.Log;
@@ -123,6 +124,13 @@ public final class PackageHelper {
return answer;
}
+ public static Set<File> findJsonFiles(File dir, FileFilter filter) {
+ Set<File> files = new TreeSet<>();
+ findJsonFiles(dir, files, filter);
+
+ return files;
+ }
+
public static void findJsonFiles(File dir, Set<File> found, FileFilter filter) {
File[] files = dir.listFiles(filter);
if (files != null) {
http://git-wip-us.apache.org/repos/asf/camel/blob/cbbe9668/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
index 23bad4c..0ffa9a4 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
@@ -39,13 +39,11 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-
import org.apache.camel.maven.packaging.model.ComponentModel;
import org.apache.camel.maven.packaging.model.ComponentOptionModel;
import org.apache.camel.maven.packaging.model.DataFormatModel;
@@ -53,6 +51,8 @@ import org.apache.camel.maven.packaging.model.DataFormatOptionModel;
import org.apache.camel.maven.packaging.model.EndpointOptionModel;
import org.apache.camel.maven.packaging.model.LanguageModel;
import org.apache.camel.maven.packaging.model.LanguageOptionModel;
+import org.apache.camel.maven.packaging.model.OtherModel;
+import org.apache.camel.maven.packaging.model.OtherOptionModel;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriPath;
import org.apache.commons.io.FileUtils;
@@ -94,6 +94,7 @@ import static org.apache.camel.maven.packaging.JSonSchemaHelper.getPropertyDefau
import static org.apache.camel.maven.packaging.JSonSchemaHelper.getPropertyJavaType;
import static org.apache.camel.maven.packaging.JSonSchemaHelper.getPropertyType;
import static org.apache.camel.maven.packaging.JSonSchemaHelper.getSafeValue;
+import static org.apache.camel.maven.packaging.JSonSchemaHelper.parseJsonSchema;
import static org.apache.camel.maven.packaging.PackageHelper.loadText;
/**
@@ -186,11 +187,122 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
return;
}
+ executeModels();
executeComponent();
executeDataFormat();
executeLanguage();
}
+ private void executeModels() throws MojoExecutionException, MojoFailureException {
+ final Set<File> files = PackageHelper.findJsonFiles(buildDir, p -> p.isDirectory() || p.getName().endsWith(".json"));
+
+ // Hystrix
+ final String json = loadModelJson(files, "hystrixConfiguration");
+ if (json != null) {
+ OtherModel model = generateOtherModel(json);
+
+ int pos = model.getJavaType().lastIndexOf(".");
+ String pkg = model.getJavaType().substring(0, pos) + ".springboot";
+
+ // Generate properties, auto-configuration happens in camel-hystrix-starter
+ createHystrixConfigurationSource(pkg, model);
+ }
+ }
+
+ private void createHystrixConfigurationSource(String packageName, OtherModel model) throws MojoFailureException {
+ final int pos = model.getJavaType().lastIndexOf(".");
+ final String commonName = model.getJavaType().substring(pos + 1) + "Common";
+ final String configName = model.getJavaType().substring(pos + 1) + "Properties";
+
+ // Common base class
+ JavaClassSource commonClass = Roaster.create(JavaClassSource.class);
+ commonClass.setPackage(packageName);
+ commonClass.setName(commonName);
+
+ String doc = "Generated by camel-package-maven-plugin - do not edit this file!";
+ if (!Strings.isBlank(model.getDescription())) {
+ doc = model.getDescription() + "\n\n" + doc;
+ }
+ commonClass.getJavaDoc().setFullText(doc);
+
+ for (OtherOptionModel option : model.getOptions()) {
+ String type = option.getJavaType();
+ String name = option.getName();
+
+ if ("id".equalsIgnoreCase(name) || "parent".equalsIgnoreCase(name)) {
+ // Skip it as it should not be set via spring boot
+ continue;
+ }
+
+ // generate inner class for non-primitive options
+ PropertySource<JavaClassSource> prop = commonClass.addProperty(type, option.getName());
+ if (!Strings.isBlank(option.getDescription())) {
+ prop.getField().getJavaDoc().setFullText(option.getDescription());
+ }
+ if (!Strings.isBlank(option.getDefaultValue())) {
+ if ("java.lang.String".equals(option.getJavaType())) {
+ prop.getField().setStringInitializer(option.getDefaultValue());
+ } else if ("long".equals(option.getJavaType()) || "java.lang.Long".equals(option.getJavaType())) {
+ // the value should be a Long number
+ String value = option.getDefaultValue() + "L";
+ prop.getField().setLiteralInitializer(value);
+ } else if ("integer".equals(option.getType()) || "boolean".equals(option.getType())) {
+ prop.getField().setLiteralInitializer(option.getDefaultValue());
+ } else if (!Strings.isBlank(option.getEnums())) {
+ String enumShortName = type.substring(type.lastIndexOf(".") + 1);
+ prop.getField().setLiteralInitializer(enumShortName + "." + option.getDefaultValue());
+ commonClass.addImport(model.getJavaType());
+ }
+ }
+ }
+
+ // Config class
+ JavaClassSource configClass = Roaster.create(JavaClassSource.class);
+ configClass.setPackage(packageName);
+ configClass.setName(configName);
+ configClass.extendSuperType(commonClass);
+ configClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationProperties").setStringValue("prefix", "camel.hystrix");
+ configClass.addImport(Map.class);
+ configClass.addImport(HashMap.class);
+ configClass.removeImport(commonClass);
+
+ configClass.addField()
+ .setName("enabled")
+ .setType(boolean.class)
+ .setPrivate()
+ .setLiteralInitializer("true")
+ .getJavaDoc().setFullText("Enable camel-hystrix");
+ configClass.addField("Map<String, " + commonName + "> configurations = new HashMap<>()")
+ .setPrivate()
+ .getJavaDoc().setFullText("Define additional configuration definitions");
+
+ MethodSource<JavaClassSource> method;
+
+ method = configClass.addMethod();
+ method.setName("getConfigurations");
+ method.setReturnType("Map<String, " + commonName + ">");
+ method.setPublic();
+ method.setBody("return configurations;");
+
+ method = configClass.addMethod();
+ method.setName("isEnabled");
+ method.setReturnType(boolean.class);
+ method.setPublic();
+ method.setBody("return enabled;");
+
+ method = configClass.addMethod();
+ method.setName("setEnabled");
+ method.addParameter(boolean.class, "enabled");
+ method.setPublic();
+ method.setBody("this.enabled = enabled;");
+
+ sortImports(commonClass);
+ sortImports(configClass);
+
+ writeSourceIfChanged(commonClass, packageName.replaceAll("\\.", "\\/") + "/" + commonName + ".java");
+ writeSourceIfChanged(configClass, packageName.replaceAll("\\.", "\\/") + "/" + configName + ".java");
+ }
+
private void executeComponent() throws MojoExecutionException, MojoFailureException {
// find the component names
List<String> componentNames = findComponentNames();
@@ -1226,6 +1338,23 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
return code;
}
+ private static String loadModelJson(Set<File> jsonFiles, String modelName) {
+ try {
+ for (File file : jsonFiles) {
+ if (file.getName().equals(modelName + ".json")) {
+ String json = loadText(new FileInputStream(file));
+ boolean isModel = json.contains("\"kind\": \"model\"");
+ if (isModel) {
+ return json;
+ }
+ }
+ }
+ } catch (IOException e) {
+ // ignore
+ }
+ return null;
+ }
+
private static String loadComponentJson(Set<File> jsonFiles, String componentName) {
try {
for (File file : jsonFiles) {
@@ -1402,6 +1531,39 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
return language;
}
+ private OtherModel generateOtherModel(String json) {
+ List<Map<String, String>> rows = parseJsonSchema("model", json, false);
+
+ OtherModel model = new OtherModel();
+ model.setName(getSafeValue("name", rows));
+ model.setTitle(getSafeValue("title", rows));
+ model.setDescription(getSafeValue("description", rows));
+ model.setJavaType(getSafeValue("javaType", rows));
+ model.setLabel(getSafeValue("label", rows));
+ model.setDeprecated(getSafeValue("deprecated", rows));
+
+ rows = parseJsonSchema("properties", json, true);
+ for (Map<String, String> row : rows) {
+ OtherOptionModel option = new OtherOptionModel();
+ option.setName(getSafeValue("name", row));
+ option.setDisplayName(getSafeValue("displayName", row));
+ option.setKind(getSafeValue("kind", row));
+ option.setGroup(getSafeValue("group", row));
+ option.setRequired(getSafeValue("required", row));
+ option.setType(getSafeValue("type", row));
+ option.setJavaType(getSafeValue("javaType", row));
+ option.setEnums(getSafeValue("enum", row));
+ option.setDeprecated(getSafeValue("deprecated", row));
+ option.setDefaultValue(getSafeValue("defaultValue", row));
+ option.setDescription(getSafeValue("description", row));
+ option.setEnums(getSafeValue("enums", row));
+
+ model.addOptionModel(option);
+ }
+
+ return model;
+ }
+
private List<String> findComponentNames() {
List<String> componentNames = new ArrayList<String>();
for (Resource r : project.getBuild().getResources()) {
http://git-wip-us.apache.org/repos/asf/camel/blob/cbbe9668/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootHelper.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootHelper.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootHelper.java
index df673b5..242979d 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootHelper.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootHelper.java
@@ -71,6 +71,4 @@ public final class SpringBootHelper {
throw new IllegalStateException("Error while getting directory", e);
}
}
-
-
}
http://git-wip-us.apache.org/repos/asf/camel/blob/cbbe9668/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/OtherModel.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/OtherModel.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/OtherModel.java
index fd0c8dd..a42b25b 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/OtherModel.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/OtherModel.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.maven.packaging.model;
+import java.util.ArrayList;
+import java.util.List;
+
import static org.apache.camel.maven.packaging.StringHelper.cutLastZeroDigit;
public class OtherModel {
@@ -30,6 +33,16 @@ public class OtherModel {
private String groupId;
private String artifactId;
private String version;
+ private String javaType;
+ private final List<OtherOptionModel> options = new ArrayList<>();
+
+ public String getJavaType() {
+ return javaType;
+ }
+
+ public void setJavaType(String javaType) {
+ this.javaType = javaType;
+ }
public String getKind() {
return kind;
@@ -119,4 +132,27 @@ public class OtherModel {
return cutLastZeroDigit(firstVersion);
}
+ public List<OtherOptionModel> getOptions() {
+ return options;
+ }
+
+ public void addOptionModel(OtherOptionModel option) {
+ options.add(option);
+ }
+
+ public String getShortJavaType() {
+ if (javaType.startsWith("java.util.Map")) {
+ return "Map";
+ } else if (javaType.startsWith("java.util.Set")) {
+ return "Set";
+ } else if (javaType.startsWith("java.util.List")) {
+ return "List";
+ }
+ int pos = javaType.lastIndexOf(".");
+ if (pos != -1) {
+ return javaType.substring(pos + 1);
+ } else {
+ return javaType;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/cbbe9668/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/OtherOptionModel.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/OtherOptionModel.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/OtherOptionModel.java
new file mode 100644
index 0000000..1d825b5
--- /dev/null
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/OtherOptionModel.java
@@ -0,0 +1,203 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven.packaging.model;
+
+import static org.apache.camel.maven.packaging.StringHelper.wrapCamelCaseWords;
+
+public class OtherOptionModel {
+
+ private String name;
+ private String displayName;
+ private String kind;
+ private String group;
+ private String required;
+ private String type;
+ private String javaType;
+ private String deprecated;
+ private String secret;
+ private String description;
+ private String defaultValue;
+ private String enums;
+
+ // special for documentation rendering
+ private boolean newGroup;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getKind() {
+ return kind;
+ }
+
+ public void setKind(String kind) {
+ this.kind = kind;
+ }
+
+ public String getGroup() {
+ return group;
+ }
+
+ public void setGroup(String group) {
+ this.group = group;
+ }
+
+ public String getRequired() {
+ return required;
+ }
+
+ public void setRequired(String required) {
+ this.required = required;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getJavaType() {
+ return javaType;
+ }
+
+ public void setJavaType(String javaType) {
+ this.javaType = javaType;
+ }
+
+ public String getDeprecated() {
+ return deprecated;
+ }
+
+ public void setDeprecated(String deprecated) {
+ this.deprecated = deprecated;
+ }
+
+ public String getSecret() {
+ return secret;
+ }
+
+ public void setSecret(String secret) {
+ this.secret = secret;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public String getEnums() {
+ return enums;
+ }
+
+ public void setEnums(String enums) {
+ this.enums = enums;
+ }
+
+ public boolean isNewGroup() {
+ return newGroup;
+ }
+
+ public void setNewGroup(boolean newGroup) {
+ this.newGroup = newGroup;
+ }
+
+ public String getShortJavaType() {
+ // TODO: use watermark in the others
+ return getShortJavaType(40);
+ }
+
+ public String getShortJavaType(int watermark) {
+ if (javaType.startsWith("java.util.Map")) {
+ return "Map";
+ } else if (javaType.startsWith("java.util.Set")) {
+ return "Set";
+ } else if (javaType.startsWith("java.util.List")) {
+ return "List";
+ }
+
+ String text = javaType;
+
+ int pos = text.lastIndexOf(".");
+ if (pos != -1) {
+ text = text.substring(pos + 1);
+ }
+
+ // if its some kind of java object then lets wrap it as its long
+ if ("object".equals(type)) {
+ text = wrapCamelCaseWords(text, watermark, " ");
+ }
+ return text;
+ }
+
+ public String getShortGroup() {
+ if (group.endsWith(" (advanced)")) {
+ return group.substring(0, group.length() - 11);
+ }
+ return group;
+ }
+
+ public String getShortDefaultValue(int watermark) {
+ if (defaultValue.isEmpty()) {
+ return "";
+ }
+ String text = defaultValue;
+ if (text.endsWith("<T>")) {
+ text = text.substring(0, text.length() - 3);
+ } else if (text.endsWith("<T>>")) {
+ text = text.substring(0, text.length() - 4);
+ }
+
+ // TODO: dirty hack for AUTO_ACKNOWLEDGE which we should wrap
+ if ("AUTO_ACKNOWLEDGE".equals(text)) {
+ return "AUTO_ ACKNOWLEDGE";
+ }
+
+ return text;
+ }
+
+ public String getShortName(int watermark) {
+ String text = wrapCamelCaseWords(name, watermark, " ");
+ // ensure the option name starts with lower-case
+ return Character.toLowerCase(text.charAt(0)) + text.substring(1);
+ }
+
+}