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 10:07:04 UTC
[camel] 01/04: CAMEL-15836 - Camel-AWS2-Cloudwatch: enable autowire
on the cloudwatch 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 73be2d8de8b6d32fbd3cfc3251e25df573347a59
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Nov 13 09:14:53 2020 +0100
CAMEL-15836 - Camel-AWS2-Cloudwatch: enable autowire on the cloudwatch client
---
.../apache/camel/component/aws2/cw/Cw2Component.java | 18 ------------------
.../camel/component/aws2/cw/Cw2Configuration.java | 15 +--------------
2 files changed, 1 insertion(+), 32 deletions(-)
diff --git a/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Component.java b/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Component.java
index 0588755..ddaf518 100644
--- a/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Component.java
+++ b/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Component.java
@@ -63,9 +63,6 @@ public class Cw2Component extends DefaultComponent {
// parameters
setProperties(endpoint, parameters);
- if (endpoint.getConfiguration().isAutoDiscoverClient()) {
- checkAndSetRegistryClient(configuration, endpoint);
- }
if (configuration.getAmazonCwClient() == null
&& (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
throw new IllegalArgumentException("AmazonCwClient or accessKey and secretKey must be specified");
@@ -84,19 +81,4 @@ public class Cw2Component extends DefaultComponent {
public void setConfiguration(Cw2Configuration configuration) {
this.configuration = configuration;
}
-
- private void checkAndSetRegistryClient(Cw2Configuration configuration, Cw2Endpoint endpoint) {
- if (ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonCwClient())) {
- LOG.debug("Looking for an CloudWatchClient instance in the registry");
- Set<CloudWatchClient> clients = getCamelContext().getRegistry().findByType(CloudWatchClient.class);
- if (clients.size() == 1) {
- LOG.debug("Found exactly one CloudWatchClient instance in the registry");
- configuration.setAmazonCwClient(clients.stream().findFirst().get());
- } else {
- LOG.debug("No CloudWatchClient instance in the registry");
- }
- } else {
- LOG.debug("CloudWatchClient instance is already set at endpoint level: skipping the check in the registry");
- }
- }
}
diff --git a/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Configuration.java b/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Configuration.java
index 61f818e..fd9dae2 100644
--- a/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Configuration.java
+++ b/components/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Configuration.java
@@ -33,6 +33,7 @@ public class Cw2Configuration implements Cloneable {
@Metadata(required = true)
private String namespace;
@UriParam
+ @Metadata(autowired = true)
private CloudWatchClient amazonCwClient;
@UriParam(label = "security", secret = true)
private String accessKey;
@@ -56,8 +57,6 @@ public class Cw2Configuration 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;
@@ -203,18 +202,6 @@ public class Cw2Configuration 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;
- }
-
// *************************************************
//
// *************************************************