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 6096db920f4b5645d095f9570ecfaf2dcdbc957b Author: Claus Ibsen <[email protected]> AuthorDate: Sat Dec 28 13:56:28 2019 +0100 Avoid non singleton endpoints and polish code --- .../slot/PgReplicationSlotEndpoint.java | 10 +-- .../src/main/docs/soroush-component.adoc | 2 +- .../soroushbot/component/SoroushBotEndpoint.java | 8 +-- .../integration/SpringIntegrationEndpoint.java | 5 -- .../dsl/SoroushBotEndpointBuilderFactory.java | 78 +++++++++++----------- .../modules/ROOT/pages/soroush-component.adoc | 2 +- 6 files changed, 43 insertions(+), 62 deletions(-) diff --git a/components/camel-pg-replication-slot/src/main/java/org/apache/camel/component/pg/replication/slot/PgReplicationSlotEndpoint.java b/components/camel-pg-replication-slot/src/main/java/org/apache/camel/component/pg/replication/slot/PgReplicationSlotEndpoint.java index 6617d77..bc30852 100644 --- a/components/camel-pg-replication-slot/src/main/java/org/apache/camel/component/pg/replication/slot/PgReplicationSlotEndpoint.java +++ b/components/camel-pg-replication-slot/src/main/java/org/apache/camel/component/pg/replication/slot/PgReplicationSlotEndpoint.java @@ -77,7 +77,7 @@ public class PgReplicationSlotEndpoint extends ScheduledPollEndpoint { @Override public Producer createProducer() throws Exception { - return null; + throw new UnsupportedOperationException("Producer not supported"); } @Override @@ -87,16 +87,8 @@ public class PgReplicationSlotEndpoint extends ScheduledPollEndpoint { return consumer; } - @Override - public boolean isSingleton() { - return true; - } - /** * Creates a new PostgreSQL JDBC connection that's setup for replication. - * - * @return JDBC connection - * @throws SQLException */ Connection newDbConnection() throws SQLException { Properties props = new Properties(); diff --git a/components/camel-soroush/src/main/docs/soroush-component.adoc b/components/camel-soroush/src/main/docs/soroush-component.adoc index c341a06..43cfa5f 100644 --- a/components/camel-soroush/src/main/docs/soroush-component.adoc +++ b/components/camel-soroush/src/main/docs/soroush-component.adoc @@ -108,13 +108,13 @@ with the following path and query parameters: | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...] | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean -| *authorizationToken* (security) | The authorization token for using the bot. if uri path does not contain authorization token, this token will be used. | | String | *backOffStrategy* (scheduling) | The strategy to backoff in case of connection failure. Currently 3 strategies are supported: 1. Exponential (default): It multiply retryWaitingTime by retryExponentialCoefficient after each connection failure. 2. Linear: It increase retryWaitingTime by retryLinearIncrement after each connection failure. 3. Fixed: Always use retryWaitingTime as the time between retries. | Exponential | String | *maxRetryWaitingTime* (scheduling) | Maximum amount of time (in millisecond) a thread wait before retrying failed request. | 3600000 | long | *reconnectIdleConnection Timeout* (scheduling) | The timeout in millisecond to reconnect the existing getMessage connection to ensure that the connection is always live and does not dead without notifying the bot. this value should not be changed. | 300000 | long | *retryExponentialCoefficient* (scheduling) | Coefficient to compute back off time when using Exponential Back Off strategy | 2 | long | *retryLinearIncrement* (scheduling) | The amount of time (in millisecond) which adds to waiting time when using Linear back off strategy | 10000 | long | *retryWaitingTime* (scheduling) | Waiting time before retry failed request (Millisecond). If backOffStrategy is not Fixed this is the based value for computing back off waiting time. the first retry is always happen immediately after failure and retryWaitingTime do not apply to the first retry. | 1000 | long +| *authorizationToken* (security) | The authorization token for using the bot. if uri path does not contain authorization token, this token will be used. | | String |=== // endpoint options: END diff --git a/components/camel-soroush/src/main/java/org/apache/camel/component/soroushbot/component/SoroushBotEndpoint.java b/components/camel-soroush/src/main/java/org/apache/camel/component/soroushbot/component/SoroushBotEndpoint.java index 5ae6bfa..030d241 100644 --- a/components/camel-soroush/src/main/java/org/apache/camel/component/soroushbot/component/SoroushBotEndpoint.java +++ b/components/camel-soroush/src/main/java/org/apache/camel/component/soroushbot/component/SoroushBotEndpoint.java @@ -63,7 +63,7 @@ public class SoroushBotEndpoint extends DefaultEndpoint { @UriPath(name = "action", description = "The action to do.") @Metadata(required = true) private SoroushAction action; - @UriParam(label = "common,security", description = "The authorization token for using" + @UriParam(label = "security", description = "The authorization token for using" + " the bot. if uri path does not contain authorization token, this token will be used.", secret = true) private String authorizationToken; @UriParam(label = "common", description = "Connection timeout in ms when connecting to soroush API", defaultValue = "30000") @@ -264,11 +264,6 @@ public class SoroushBotEndpoint extends DefaultEndpoint { return consumer; } - @Override - public boolean isSingleton() { - return true; - } - /** * create a {@link WebTarget} that could be used to download file from soroush based on {@link SoroushBotEndpoint#authorizationToken}, * {@link SoroushBotEndpoint#connectionTimeout} and {@code fileUrl} (fileId) @@ -280,7 +275,6 @@ public class SoroushBotEndpoint extends DefaultEndpoint { return SoroushService.get().createDownloadFileTarget(authorizationToken, fileUrl, connectionTimeout); } - /** * return the lazily created instance of {@link SoroushBotEndpoint#uploadFileTarget} to used for uploading file to soroush. */ diff --git a/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java b/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java index f30f45a..5b1e554 100644 --- a/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java +++ b/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java @@ -99,11 +99,6 @@ public class SpringIntegrationEndpoint extends DefaultEndpoint { return messageChannel; } - @Override - public boolean isSingleton() { - return false; - } - /** * The exchange pattern that the Spring integration endpoint should use. * If inOut=true then a reply channel is expected, either from the Spring Integration Message header or configured on the endpoint. diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/SoroushBotEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/SoroushBotEndpointBuilderFactory.java index 73f803a..6494f0d3 100644 --- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/SoroushBotEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/SoroushBotEndpointBuilderFactory.java @@ -198,19 +198,6 @@ public interface SoroushBotEndpointBuilderFactory { return this; } /** - * The authorization token for using the bot. if uri path does not - * contain authorization token, this token will be used. - * - * The option is a: <code>java.lang.String</code> type. - * - * Group: security - */ - default SoroushBotEndpointConsumerBuilder authorizationToken( - String authorizationToken) { - doSetProperty("authorizationToken", authorizationToken); - return this; - } - /** * The strategy to backoff in case of connection failure. Currently 3 * strategies are supported: 1. Exponential (default): It multiply * retryWaitingTime by retryExponentialCoefficient after each connection @@ -363,6 +350,19 @@ public interface SoroushBotEndpointBuilderFactory { doSetProperty("retryWaitingTime", retryWaitingTime); return this; } + /** + * The authorization token for using the bot. if uri path does not + * contain authorization token, this token will be used. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default SoroushBotEndpointConsumerBuilder authorizationToken( + String authorizationToken) { + doSetProperty("authorizationToken", authorizationToken); + return this; + } } /** @@ -730,19 +730,6 @@ public interface SoroushBotEndpointBuilderFactory { return this; } /** - * The authorization token for using the bot. if uri path does not - * contain authorization token, this token will be used. - * - * The option is a: <code>java.lang.String</code> type. - * - * Group: security - */ - default SoroushBotEndpointProducerBuilder authorizationToken( - String authorizationToken) { - doSetProperty("authorizationToken", authorizationToken); - return this; - } - /** * The strategy to backoff in case of connection failure. Currently 3 * strategies are supported: 1. Exponential (default): It multiply * retryWaitingTime by retryExponentialCoefficient after each connection @@ -895,6 +882,19 @@ public interface SoroushBotEndpointBuilderFactory { doSetProperty("retryWaitingTime", retryWaitingTime); return this; } + /** + * The authorization token for using the bot. if uri path does not + * contain authorization token, this token will be used. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default SoroushBotEndpointProducerBuilder authorizationToken( + String authorizationToken) { + doSetProperty("authorizationToken", authorizationToken); + return this; + } } /** @@ -1022,19 +1022,6 @@ public interface SoroushBotEndpointBuilderFactory { return this; } /** - * The authorization token for using the bot. if uri path does not - * contain authorization token, this token will be used. - * - * The option is a: <code>java.lang.String</code> type. - * - * Group: security - */ - default SoroushBotEndpointBuilder authorizationToken( - String authorizationToken) { - doSetProperty("authorizationToken", authorizationToken); - return this; - } - /** * The strategy to backoff in case of connection failure. Currently 3 * strategies are supported: 1. Exponential (default): It multiply * retryWaitingTime by retryExponentialCoefficient after each connection @@ -1185,6 +1172,19 @@ public interface SoroushBotEndpointBuilderFactory { doSetProperty("retryWaitingTime", retryWaitingTime); return this; } + /** + * The authorization token for using the bot. if uri path does not + * contain authorization token, this token will be used. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default SoroushBotEndpointBuilder authorizationToken( + String authorizationToken) { + doSetProperty("authorizationToken", authorizationToken); + return this; + } } /** diff --git a/docs/components/modules/ROOT/pages/soroush-component.adoc b/docs/components/modules/ROOT/pages/soroush-component.adoc index 6715834..3cbcd2a 100644 --- a/docs/components/modules/ROOT/pages/soroush-component.adoc +++ b/docs/components/modules/ROOT/pages/soroush-component.adoc @@ -109,13 +109,13 @@ with the following path and query parameters: | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...] | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean -| *authorizationToken* (security) | The authorization token for using the bot. if uri path does not contain authorization token, this token will be used. | | String | *backOffStrategy* (scheduling) | The strategy to backoff in case of connection failure. Currently 3 strategies are supported: 1. Exponential (default): It multiply retryWaitingTime by retryExponentialCoefficient after each connection failure. 2. Linear: It increase retryWaitingTime by retryLinearIncrement after each connection failure. 3. Fixed: Always use retryWaitingTime as the time between retries. | Exponential | String | *maxRetryWaitingTime* (scheduling) | Maximum amount of time (in millisecond) a thread wait before retrying failed request. | 3600000 | long | *reconnectIdleConnection Timeout* (scheduling) | The timeout in millisecond to reconnect the existing getMessage connection to ensure that the connection is always live and does not dead without notifying the bot. this value should not be changed. | 300000 | long | *retryExponentialCoefficient* (scheduling) | Coefficient to compute back off time when using Exponential Back Off strategy | 2 | long | *retryLinearIncrement* (scheduling) | The amount of time (in millisecond) which adds to waiting time when using Linear back off strategy | 10000 | long | *retryWaitingTime* (scheduling) | Waiting time before retry failed request (Millisecond). If backOffStrategy is not Fixed this is the based value for computing back off waiting time. the first retry is always happen immediately after failure and retryWaitingTime do not apply to the first retry. | 1000 | long +| *authorizationToken* (security) | The authorization token for using the bot. if uri path does not contain authorization token, this token will be used. | | String |=== // endpoint options: END
