You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/11/13 12:00:17 UTC
[camel] 01/10: CAMEL-15836 - Camel-AWS2-DDB: enable autowire on the
DynamoDb client
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 858ba2f445911cb2e7c60b90f9f87bc92d5ca43b
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Nov 13 11:49:43 2020 +0100
CAMEL-15836 - Camel-AWS2-DDB: enable autowire on the DynamoDb client
---
.../apache/camel/component/aws2/ddb/Ddb2Component.java | 18 ------------------
.../camel/component/aws2/ddb/Ddb2Configuration.java | 15 +--------------
2 files changed, 1 insertion(+), 32 deletions(-)
diff --git a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Component.java b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Component.java
index e14096f..944f9af 100644
--- a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Component.java
+++ b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Component.java
@@ -57,9 +57,6 @@ public class Ddb2Component extends DefaultComponent {
configuration.setTableName(remaining);
Ddb2Endpoint endpoint = new Ddb2Endpoint(uri, this, configuration);
setProperties(endpoint, parameters);
- if (endpoint.getConfiguration().isAutoDiscoverClient()) {
- checkAndSetRegistryClient(configuration, endpoint);
- }
if (configuration.getAmazonDDBClient() == null
&& (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
throw new IllegalArgumentException("amazonDDBClient or accessKey and secretKey must be specified");
@@ -78,19 +75,4 @@ public class Ddb2Component extends DefaultComponent {
public void setConfiguration(Ddb2Configuration configuration) {
this.configuration = configuration;
}
-
- private void checkAndSetRegistryClient(Ddb2Configuration configuration, Ddb2Endpoint endpoint) {
- if (ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonDDBClient())) {
- LOG.debug("Looking for an DynamoDbClient instance in the registry");
- Set<DynamoDbClient> clients = getCamelContext().getRegistry().findByType(DynamoDbClient.class);
- if (clients.size() == 1) {
- LOG.debug("Found exactly one DynamoDbClient instance in the registry");
- configuration.setAmazonDDBClient(clients.stream().findFirst().get());
- } else {
- LOG.debug("No DynamoDbClient instance in the registry");
- }
- } else {
- LOG.debug("DynamoDbClient instance is already set at endpoint level: skipping the check in the registry");
- }
- }
}
diff --git a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Configuration.java b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Configuration.java
index 1b68538..3677b26 100644
--- a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Configuration.java
+++ b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Configuration.java
@@ -35,6 +35,7 @@ public class Ddb2Configuration implements Cloneable {
@UriParam(label = "security", secret = true)
private String secretKey;
@UriParam
+ @Metadata(autowired = true)
private DynamoDbClient amazonDDBClient;
@UriParam
private boolean consistentRead;
@@ -58,8 +59,6 @@ public class Ddb2Configuration implements Cloneable {
private String region;
@UriParam(defaultValue = "false")
private boolean trustAllCertificates;
- @UriParam(label = "common", defaultValue = "true")
- private boolean autoDiscoverClient = true;
public String getAccessKey() {
return accessKey;
@@ -227,18 +226,6 @@ public class Ddb2Configuration implements Cloneable {
this.trustAllCertificates = trustAllCertificates;
}
- public boolean isAutoDiscoverClient() {
- return autoDiscoverClient;
- }
-
- /**
- * Setting the autoDiscoverClient mechanism, if true, the component will look for a client instance in the registry
- * automatically otherwise it will skip that checking.
- */
- public void setAutoDiscoverClient(boolean autoDiscoverClient) {
- this.autoDiscoverClient = autoDiscoverClient;
- }
-
// *************************************************
//
// *************************************************