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 2022/10/21 10:56:38 UTC
[camel] branch main updated: feat: replace custom aws health check repositories with the components one
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 37b90d302fe feat: replace custom aws health check repositories with the components one
37b90d302fe is described below
commit 37b90d302fe3f9ad82e98984ab760f417e415e4d
Author: Luca Burgazzoli <lb...@gmail.com>
AuthorDate: Thu Oct 20 15:16:46 2022 +0200
feat: replace custom aws health check repositories with the components one
---
.../health-check/camel-aws2-athena-repository | 2 -
.../component/aws2/athena/Athena2Endpoint.java | 10 ++-
.../aws2/athena/Athena2HealthCheckRepository.java | 87 ----------------------
.../camel/health-check/camel-aws2-s3-repository | 2 -
.../camel/component/aws2/s3/AWS2S3Consumer.java | 9 ++-
.../aws2/s3/AWS2S3HealthCheckRepository.java | 87 ----------------------
.../camel/health-check/camel-aws2-sqs-repository | 2 -
.../camel/component/aws2/sqs/Sqs2Consumer.java | 10 ++-
.../aws2/sqs/Sqs2HealthCheckRepository.java | 87 ----------------------
9 files changed, 20 insertions(+), 276 deletions(-)
diff --git a/components/camel-aws/camel-aws2-athena/src/generated/resources/META-INF/services/org/apache/camel/health-check/camel-aws2-athena-repository b/components/camel-aws/camel-aws2-athena/src/generated/resources/META-INF/services/org/apache/camel/health-check/camel-aws2-athena-repository
deleted file mode 100644
index 4a65fadb0b7..00000000000
--- a/components/camel-aws/camel-aws2-athena/src/generated/resources/META-INF/services/org/apache/camel/health-check/camel-aws2-athena-repository
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated by camel build tools - do NOT edit this file!
-class=org.apache.camel.component.aws2.athena.Athena2HealthCheckRepository
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java
index 9799e0300a0..3932fc05dd8 100644
--- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java
@@ -23,6 +23,7 @@ import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.component.aws2.athena.client.Athena2ClientFactory;
import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.WritableHealthCheckRepository;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.support.DefaultEndpoint;
@@ -38,7 +39,7 @@ public class Athena2Endpoint extends DefaultEndpoint {
private AthenaClient athenaClient;
- private Athena2HealthCheckRepository healthCheckRepository;
+ private WritableHealthCheckRepository healthCheckRepository;
private Athena2ClientHealthCheck clientHealthCheck;
@UriParam
@@ -67,8 +68,11 @@ public class Athena2Endpoint extends DefaultEndpoint {
? configuration.getAmazonAthenaClient()
: Athena2ClientFactory.getAWSAthenaClient(configuration).getAthenaClient();
- healthCheckRepository = HealthCheckHelper.getHealthCheckRepository(getCamelContext(),
- Athena2HealthCheckRepository.REPOSITORY_ID, Athena2HealthCheckRepository.class);
+ // health-check is optional so discover and resolve
+ healthCheckRepository = HealthCheckHelper.getHealthCheckRepository(
+ getCamelContext(),
+ "components",
+ WritableHealthCheckRepository.class);
if (healthCheckRepository != null) {
clientHealthCheck = new Athena2ClientHealthCheck(this, getId());
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2HealthCheckRepository.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2HealthCheckRepository.java
deleted file mode 100644
index 090671edbab..00000000000
--- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2HealthCheckRepository.java
+++ /dev/null
@@ -1,87 +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.aws2.athena;
-
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.stream.Stream;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelContextAware;
-import org.apache.camel.DeferredContextBinding;
-import org.apache.camel.NonManagedService;
-import org.apache.camel.StaticService;
-import org.apache.camel.health.HealthCheck;
-import org.apache.camel.health.HealthCheckRepository;
-import org.apache.camel.support.service.ServiceSupport;
-
-/**
- * Repository for camel-aws2-athena {@link HealthCheck}s.
- */
-@org.apache.camel.spi.annotations.HealthCheck("camel-aws2-athena-repository")
-@DeferredContextBinding
-public class Athena2HealthCheckRepository extends ServiceSupport
- implements CamelContextAware, HealthCheckRepository, StaticService, NonManagedService {
-
- public static final String REPOSITORY_ID = "camel-aws2-athena";
-
- private final List<HealthCheck> checks = new CopyOnWriteArrayList<>();
- private volatile CamelContext context;
- private boolean enabled = true;
-
- @Override
- public void setCamelContext(CamelContext camelContext) {
- this.context = camelContext;
- }
-
- @Override
- public String getId() {
- return REPOSITORY_ID;
- }
-
- @Override
- public CamelContext getCamelContext() {
- return context;
- }
-
- @Override
- public boolean isEnabled() {
- return enabled;
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- @Override
- public Stream<HealthCheck> stream() {
- return this.context != null && enabled
- ? checks.stream()
- : Stream.empty();
- }
-
- public void addHealthCheck(HealthCheck healthCheck) {
- CamelContextAware.trySetCamelContext(healthCheck, getCamelContext());
- this.checks.add(healthCheck);
- }
-
- public void removeHealthCheck(HealthCheck healthCheck) {
- this.checks.remove(healthCheck);
- }
-}
diff --git a/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/services/org/apache/camel/health-check/camel-aws2-s3-repository b/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/services/org/apache/camel/health-check/camel-aws2-s3-repository
deleted file mode 100644
index 2073257dbd0..00000000000
--- a/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/services/org/apache/camel/health-check/camel-aws2-s3-repository
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated by camel build tools - do NOT edit this file!
-class=org.apache.camel.component.aws2.s3.AWS2S3HealthCheckRepository
diff --git a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Consumer.java b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Consumer.java
index 63835ca652d..624bee29660 100644
--- a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Consumer.java
+++ b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Consumer.java
@@ -33,6 +33,7 @@ import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.WritableHealthCheckRepository;
import org.apache.camel.spi.Synchronization;
import org.apache.camel.support.ScheduledBatchPollingConsumer;
import org.apache.camel.support.SynchronizationAdapter;
@@ -70,7 +71,7 @@ public class AWS2S3Consumer extends ScheduledBatchPollingConsumer {
private String marker;
private transient String s3ConsumerToString;
- private AWS2S3HealthCheckRepository healthCheckRepository;
+ private WritableHealthCheckRepository healthCheckRepository;
private AWS2S3ConsumerHealthCheck consumerHealthCheck;
public AWS2S3Consumer(AWS2S3Endpoint endpoint, Processor processor) {
@@ -81,8 +82,10 @@ public class AWS2S3Consumer extends ScheduledBatchPollingConsumer {
protected void doStart() throws Exception {
super.doStart();
- healthCheckRepository = HealthCheckHelper.getHealthCheckRepository(getEndpoint().getCamelContext(),
- AWS2S3HealthCheckRepository.REPOSITORY_ID, AWS2S3HealthCheckRepository.class);
+ healthCheckRepository = HealthCheckHelper.getHealthCheckRepository(
+ getEndpoint().getCamelContext(),
+ "components",
+ WritableHealthCheckRepository.class);
if (healthCheckRepository != null) {
consumerHealthCheck = new AWS2S3ConsumerHealthCheck(this, getRouteId());
diff --git a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3HealthCheckRepository.java b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3HealthCheckRepository.java
deleted file mode 100644
index 9c01730dce4..00000000000
--- a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3HealthCheckRepository.java
+++ /dev/null
@@ -1,87 +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.aws2.s3;
-
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.stream.Stream;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelContextAware;
-import org.apache.camel.DeferredContextBinding;
-import org.apache.camel.NonManagedService;
-import org.apache.camel.StaticService;
-import org.apache.camel.health.HealthCheck;
-import org.apache.camel.health.HealthCheckRepository;
-import org.apache.camel.support.service.ServiceSupport;
-
-/**
- * Repository for camel-aws2-s3 {@link HealthCheck}s.
- */
-@org.apache.camel.spi.annotations.HealthCheck("camel-aws2-s3-repository")
-@DeferredContextBinding
-public class AWS2S3HealthCheckRepository extends ServiceSupport
- implements CamelContextAware, HealthCheckRepository, StaticService, NonManagedService {
-
- public static final String REPOSITORY_ID = "camel-aws2-s3";
-
- private final List<HealthCheck> checks = new CopyOnWriteArrayList<>();
- private volatile CamelContext context;
- private boolean enabled = true;
-
- @Override
- public void setCamelContext(CamelContext camelContext) {
- this.context = camelContext;
- }
-
- @Override
- public String getId() {
- return REPOSITORY_ID;
- }
-
- @Override
- public CamelContext getCamelContext() {
- return context;
- }
-
- @Override
- public boolean isEnabled() {
- return enabled;
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- @Override
- public Stream<HealthCheck> stream() {
- return this.context != null && enabled
- ? checks.stream()
- : Stream.empty();
- }
-
- public void addHealthCheck(HealthCheck healthCheck) {
- CamelContextAware.trySetCamelContext(healthCheck, getCamelContext());
- this.checks.add(healthCheck);
- }
-
- public void removeHealthCheck(HealthCheck healthCheck) {
- this.checks.remove(healthCheck);
- }
-
-}
diff --git a/components/camel-aws/camel-aws2-sqs/src/generated/resources/META-INF/services/org/apache/camel/health-check/camel-aws2-sqs-repository b/components/camel-aws/camel-aws2-sqs/src/generated/resources/META-INF/services/org/apache/camel/health-check/camel-aws2-sqs-repository
deleted file mode 100644
index 66a881d7ddc..00000000000
--- a/components/camel-aws/camel-aws2-sqs/src/generated/resources/META-INF/services/org/apache/camel/health-check/camel-aws2-sqs-repository
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated by camel build tools - do NOT edit this file!
-class=org.apache.camel.component.aws2.sqs.Sqs2HealthCheckRepository
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java
index bc853ac882f..3cfd9ab84ee 100644
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java
+++ b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java
@@ -35,6 +35,7 @@ import org.apache.camel.ExtendedExchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.WritableHealthCheckRepository;
import org.apache.camel.spi.HeaderFilterStrategy;
import org.apache.camel.spi.ScheduledPollConsumerScheduler;
import org.apache.camel.spi.Synchronization;
@@ -70,7 +71,7 @@ public class Sqs2Consumer extends ScheduledBatchPollingConsumer {
private transient String sqsConsumerToString;
private Collection<String> attributeNames;
private Collection<String> messageAttributeNames;
- private Sqs2HealthCheckRepository healthCheckRepository;
+ private WritableHealthCheckRepository healthCheckRepository;
private Sqs2ConsumerHealthCheck consumerHealthCheck;
public Sqs2Consumer(Sqs2Endpoint endpoint, Processor processor) {
@@ -355,8 +356,11 @@ public class Sqs2Consumer extends ScheduledBatchPollingConsumer {
super.doStart();
- healthCheckRepository = HealthCheckHelper.getHealthCheckRepository(getEndpoint().getCamelContext(),
- Sqs2HealthCheckRepository.REPOSITORY_ID, Sqs2HealthCheckRepository.class);
+ // health-check is optional so discover and resolve
+ healthCheckRepository = HealthCheckHelper.getHealthCheckRepository(
+ getEndpoint().getCamelContext(),
+ "components",
+ WritableHealthCheckRepository.class);
if (healthCheckRepository != null) {
consumerHealthCheck = new Sqs2ConsumerHealthCheck(this, getRouteId());
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2HealthCheckRepository.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2HealthCheckRepository.java
deleted file mode 100644
index b2c8712e165..00000000000
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2HealthCheckRepository.java
+++ /dev/null
@@ -1,87 +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.aws2.sqs;
-
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.stream.Stream;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelContextAware;
-import org.apache.camel.DeferredContextBinding;
-import org.apache.camel.NonManagedService;
-import org.apache.camel.StaticService;
-import org.apache.camel.health.HealthCheck;
-import org.apache.camel.health.HealthCheckRepository;
-import org.apache.camel.support.service.ServiceSupport;
-
-/**
- * Repository for camel-aws2-sqs {@link HealthCheck}s.
- */
-@org.apache.camel.spi.annotations.HealthCheck("camel-aws2-sqs-repository")
-@DeferredContextBinding
-public class Sqs2HealthCheckRepository extends ServiceSupport
- implements CamelContextAware, HealthCheckRepository, StaticService, NonManagedService {
-
- public static final String REPOSITORY_ID = "camel-aws2-sqs";
-
- private final List<HealthCheck> checks = new CopyOnWriteArrayList<>();
- private volatile CamelContext context;
- private boolean enabled = true;
-
- @Override
- public void setCamelContext(CamelContext camelContext) {
- this.context = camelContext;
- }
-
- @Override
- public String getId() {
- return REPOSITORY_ID;
- }
-
- @Override
- public CamelContext getCamelContext() {
- return context;
- }
-
- @Override
- public boolean isEnabled() {
- return enabled;
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- @Override
- public Stream<HealthCheck> stream() {
- return this.context != null && enabled
- ? checks.stream()
- : Stream.empty();
- }
-
- public void addHealthCheck(HealthCheck healthCheck) {
- CamelContextAware.trySetCamelContext(healthCheck, getCamelContext());
- this.checks.add(healthCheck);
- }
-
- public void removeHealthCheck(HealthCheck healthCheck) {
- this.checks.remove(healthCheck);
- }
-
-}