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 67c8cc7eec6b6cf4a45052b932cd009f614938b6 Author: Andrea Cosentino <[email protected]> AuthorDate: Mon Nov 16 14:51:30 2020 +0100 CAMEL-15836 - Camel-AWS2-IAM: enable autowire on the Iam client --- .../apache/camel/component/aws2/iam/IAM2Component.java | 18 ------------------ .../camel/component/aws2/iam/IAM2Configuration.java | 15 +-------------- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java b/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java index c3d110d..847ce04 100644 --- a/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java +++ b/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java @@ -55,9 +55,6 @@ public class IAM2Component extends DefaultComponent { IAM2Configuration configuration = this.configuration != null ? this.configuration.copy() : new IAM2Configuration(); IAM2Endpoint endpoint = new IAM2Endpoint(uri, this, configuration); setProperties(endpoint, parameters); - if (endpoint.getConfiguration().isAutoDiscoverClient()) { - checkAndSetRegistryClient(configuration, endpoint); - } if (configuration.getIamClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) { throw new IllegalArgumentException("Amazon IAM client or accessKey and secretKey must be specified"); @@ -76,19 +73,4 @@ public class IAM2Component extends DefaultComponent { public void setConfiguration(IAM2Configuration configuration) { this.configuration = configuration; } - - private void checkAndSetRegistryClient(IAM2Configuration configuration, IAM2Endpoint endpoint) { - if (ObjectHelper.isEmpty(endpoint.getConfiguration().getIamClient())) { - LOG.debug("Looking for an IamClient instance in the registry"); - Set<IamClient> clients = getCamelContext().getRegistry().findByType(IamClient.class); - if (clients.size() == 1) { - LOG.debug("Found exactly one IamClient instance in the registry"); - configuration.setIamClient(clients.stream().findFirst().get()); - } else { - LOG.debug("No IamClient instance in the registry"); - } - } else { - LOG.debug("IamClient instance is already set at endpoint level: skipping the check in the registry"); - } - } } diff --git a/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java b/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java index 16fb89f..afd0c30 100644 --- a/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java +++ b/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java @@ -32,6 +32,7 @@ public class IAM2Configuration implements Cloneable { @Metadata(required = true) private String label; @UriParam + @Metadata(autowired = true) private IamClient iamClient; @UriParam(label = "security", secret = true) private String accessKey; @@ -52,8 +53,6 @@ public class IAM2Configuration implements Cloneable { private boolean pojoRequest; @UriParam(defaultValue = "false") private boolean trustAllCertificates; - @UriParam(label = "common", defaultValue = "true") - private boolean autoDiscoverClient = true; public IamClient getIamClient() { return iamClient; @@ -166,18 +165,6 @@ public class IAM2Configuration 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; - } - // ************************************************* // // *************************************************
