You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2024/02/29 11:53:41 UTC
(camel-quarkus) branch main updated: Clean up camel-k extension leftovers and add option to shutdown the context on exchange completion
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 8555b89d1d Clean up camel-k extension leftovers and add option to shutdown the context on exchange completion
8555b89d1d is described below
commit 8555b89d1d153fbc529b833226fec239b31defa7
Author: Luca Burgazzoli <lb...@users.noreply.github.com>
AuthorDate: Thu Feb 29 12:53:35 2024 +0100
Clean up camel-k extension leftovers and add option to shutdown the context on exchange completion
* Clean up camel-k extension leftovers
- interceptors are not more needed
- customizers are not more needed
- custom source loader not more needed and replaced with camel.main.routes-include-pattern
- custom "Runtime" not more needed
* Clean up camel-k extension leftovers (poms)
* feat(camel-k): add option to shutdown the context on exchange completion
---
.../org/apache/camel/quarkus/main/CamelMain.java | 5 +-
extensions/camel-k/deployment/pom.xml | 81 -----
.../quarkus/k/deployment/RuntimeProcessor.java | 114 ++-----
.../deployment/devmode/HotDeploymentProcessor.java | 32 +-
.../camel/quarkus/k/deployment/LoaderTest.java | 335 --------------------
.../deployment/src/test/resources/MyRoutes.java | 26 --
.../deployment/src/test/resources/routes.groovy | 20 --
.../deployment/src/test/resources/routes.js | 19 --
.../deployment/src/test/resources/routes.jsh | 21 --
.../deployment/src/test/resources/routes.xml | 34 --
extensions/camel-k/runtime/pom.xml | 10 +-
.../quarkus/k/core/SourceDefinitionConfigurer.java | 114 -------
.../k/listener/SourcesConfigurerConfigurer.java | 49 ---
...rg.apache.camel.quarkus.k.core.SourceDefinition | 2 -
...ache.camel.quarkus.k.listener.SourcesConfigurer | 2 -
.../org/apache/camel/quarkus/k/core/Runtime.java | 156 ----------
.../apache/camel/quarkus/k/core/RuntimeAware.java | 24 --
.../org/apache/camel/quarkus/k/core/Source.java | 54 ----
.../camel/quarkus/k/core/SourceDefinition.java | 184 -----------
.../apache/camel/quarkus/k/core/SourceType.java | 24 --
.../quarkus/k/listener/AbstractPhaseListener.java | 39 ---
.../quarkus/k/listener/ContextConfigurer.java | 38 ---
.../quarkus/k/listener/SourcesConfigurer.java | 109 -------
.../camel/quarkus/k/runtime/Application.java | 185 -----------
.../k/runtime/ApplicationConfigSourceProvider.java | 167 +++++++++-
.../quarkus/k/runtime/ApplicationConstants.java | 40 +++
.../quarkus/k/runtime/ApplicationRecorder.java | 30 +-
.../camel/quarkus/k/runtime/ApplicationRoutes.java | 10 +-
.../quarkus/k/runtime/ApplicationRoutesConfig.java | 6 +-
...oducers.java => ApplicationShutdownConfig.java} | 32 +-
.../k/runtime/ApplicationShutdownCustomizer.java | 91 ++++++
.../apache/camel/quarkus/k/support/Constants.java | 63 ----
.../camel/quarkus/k/support/DelegatingRuntime.java | 80 -----
.../camel/quarkus/k/support/PropertiesSupport.java | 93 ------
.../camel/quarkus/k/support/RouteBuilders.java | 73 -----
.../camel/quarkus/k/support/RuntimeSupport.java | 341 ---------------------
.../apache/camel/quarkus/k/support/Sources.java | 243 ---------------
.../camel/quarkus/k/support/SourcesSupport.java | 187 -----------
.../camel/quarkus/k/support/StringSupport.java | 75 -----
...rg.apache.camel.quarkus.k.core.Runtime$Listener | 19 --
.../org/apache/camel/quarkus/k/SourceTest.java | 54 ----
.../PropertiesFunctionsConfigurerTest.java | 55 ----
.../quarkus/k/listener/SourceConfigurerTest.java | 143 ---------
.../runtime/PropertiesFunctionsConfigurerTest.java | 55 ++++
.../camel/quarkus/k/support/NameCustomizer.java | 45 ---
.../quarkus/k/support/PropertiesSupportTest.java | 94 ------
.../quarkus/k/support/RuntimeSupportTest.java | 194 ------------
.../org.apache.camel.quarkus.k/customizer/name | 18 --
.../_configmaps}/my-binary-cm/my-property.zip | Bin
.../_configmaps/my-cm/application.properties | 2 +
.../_configmaps}/my-cm/my-property | 0
.../_secrets}/my-secret/my-property | 0
.../runtime/src/test/resources/my-cp-resource.txt | 1 -
.../src/test/resources/my-file-resource.txt | 1 -
.../src/main/resources/application.properties | 2 +-
.../{routes.yaml => routes/test-route-001.yaml} | 0
.../quarkus/k/it/WithRoutesOverridesTest.java | 7 +-
.../camel-k-runtime-shutdown}/pom.xml | 263 +++++++---------
.../src/main/resources/application.properties | 9 +-
.../src/main/resources/routes/test-route-001.yaml | 25 +-
.../camel/quarkus/k/it/RuntimeShutdownIT.java | 6 +-
.../camel/quarkus/k/it/RuntimeShutdownTest.java | 48 +++
.../org/apache/camel/quarkus/k/it/Application.java | 82 ++---
.../camel/quarkus/k/it/RuntimeInspector.java | 111 -------
.../src/main/resources/application.properties | 5 +-
.../resources => main/resources/routes}/rests.xml | 0
.../resources/routes}/routes-with-beans.yaml | 0
.../resources/routes}/routes-with-expression.xml | 0
.../resources => main/resources/routes}/routes.xml | 0
.../quarkus/k/it/RuntimeCustomizerFallbackIT.java | 23 --
.../k/it/RuntimeCustomizerFallbackTest.java | 58 ----
.../camel/quarkus/k/it/RuntimeCustomizerIT.java | 23 --
.../camel/quarkus/k/it/RuntimeCustomizerTest.java | 58 ----
.../org/apache/camel/quarkus/k/it/RuntimeTest.java | 53 ++--
.../camel/quarkus/k/it/RuntimeWithXmlTest.java | 64 +---
.../camel/quarkus/k/it/RuntimeWithYamlTest.java | 60 +---
.../apache/camel/quarkus/k/it/TestCustomizer.java | 50 ---
.../org.apache.camel.quarkus.k/customizer/test | 18 --
.../conf.d/{ => _configmaps}/001/conf.properties | 0
.../conf.d/{ => _configmaps}/002/conf.properties | 0
.../conf.d/{ => _configmaps}/003/flat-property | 0
integration-tests/pom.xml | 1 +
poms/bom-test/pom.xml | 10 -
poms/bom/pom.xml | 25 --
poms/bom/src/main/generated/flattened-full-pom.xml | 50 +--
.../src/main/generated/flattened-reduced-pom.xml | 10 +-
.../generated/flattened-reduced-verbose-pom.xml | 10 +-
tooling/scripts/test-categories.yaml | 1 +
tooling/test-list/pom.xml | 1 +
89 files changed, 720 insertions(+), 4242 deletions(-)
diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMain.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMain.java
index e75d87c794..e6c6014894 100644
--- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMain.java
+++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMain.java
@@ -38,12 +38,8 @@ import org.apache.camel.spi.HasCamelContext;
import org.apache.camel.support.PluginHelper;
import org.apache.camel.support.service.ServiceHelper;
import org.apache.camel.util.StringHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public final class CamelMain extends MainCommandLineSupport implements HasCamelContext {
- private static final Logger LOGGER = LoggerFactory.getLogger(CamelMain.class);
-
private final AtomicBoolean engineStarted;
private final FailureRemedy failureRemedy;
@@ -53,6 +49,7 @@ public final class CamelMain extends MainCommandLineSupport implements HasCamelC
this.failureRemedy = failureRemedy;
}
+ @Override
protected void configureRoutes(CamelContext camelContext) throws Exception {
// then configure and add the routes
RoutesConfigurer configurer = new RoutesConfigurer();
diff --git a/extensions/camel-k/deployment/pom.xml b/extensions/camel-k/deployment/pom.xml
index d27ae857b9..74c40d74a6 100644
--- a/extensions/camel-k/deployment/pom.xml
+++ b/extensions/camel-k/deployment/pom.xml
@@ -50,87 +50,6 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
-
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-junit5-internal</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.rest-assured</groupId>
- <artifactId>rest-assured</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-resteasy</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-groovy-dsl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-java-joor-dsl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-js-dsl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-jsh-dsl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-kotlin-dsl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-yaml-dsl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-xml-io-dsl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-direct</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-jackson</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-log</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-jsonb</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-resteasy-jsonb</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/extensions/camel-k/deployment/src/main/java/org/apache/camel/quarkus/k/deployment/RuntimeProcessor.java b/extensions/camel-k/deployment/src/main/java/org/apache/camel/quarkus/k/deployment/RuntimeProcessor.java
index 8563c7ab25..c8a7cc7180 100644
--- a/extensions/camel-k/deployment/src/main/java/org/apache/camel/quarkus/k/deployment/RuntimeProcessor.java
+++ b/extensions/camel-k/deployment/src/main/java/org/apache/camel/quarkus/k/deployment/RuntimeProcessor.java
@@ -16,113 +16,27 @@
*/
package org.apache.camel.quarkus.k.deployment;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ServiceLoader;
-import java.util.stream.Collectors;
-
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
-import io.quarkus.arc.deployment.BeanContainerBuildItem;
-import io.quarkus.arc.deployment.SyntheticBeansRuntimeInitBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.annotations.Consume;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
-import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
-import org.apache.camel.builder.RouteBuilderLifecycleStrategy;
-import org.apache.camel.quarkus.core.deployment.main.spi.CamelMainBuildItem;
-import org.apache.camel.quarkus.core.deployment.main.spi.CamelMainListenerBuildItem;
-import org.apache.camel.quarkus.core.deployment.main.spi.CamelRoutesCollectorBuildItem;
import org.apache.camel.quarkus.core.deployment.spi.CamelModelReifierFactoryBuildItem;
import org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeTaskBuildItem;
-import org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination;
-import org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem;
-import org.apache.camel.quarkus.k.core.Runtime;
-import org.apache.camel.quarkus.k.core.SourceDefinition;
-import org.apache.camel.quarkus.k.runtime.ApplicationProducers;
+import org.apache.camel.quarkus.core.deployment.spi.RuntimeCamelContextCustomizerBuildItem;
import org.apache.camel.quarkus.k.runtime.ApplicationRecorder;
import org.apache.camel.quarkus.k.runtime.ApplicationRoutes;
-import org.apache.camel.quarkus.k.support.Constants;
-import org.apache.camel.quarkus.k.support.RuntimeSupport;
-import org.apache.camel.spi.CamelContextCustomizer;
+import org.apache.camel.quarkus.k.runtime.ApplicationRoutesConfig;
+import org.apache.camel.quarkus.k.runtime.ApplicationShutdownConfig;
import org.apache.camel.spi.StreamCachingStrategy;
import org.jboss.jandex.IndexView;
import static org.apache.camel.quarkus.k.deployment.support.DeploymentSupport.getAllKnownImplementors;
import static org.apache.camel.quarkus.k.deployment.support.DeploymentSupport.reflectiveClassBuildItem;
-import static org.apache.camel.quarkus.k.deployment.support.DeploymentSupport.stream;
public class RuntimeProcessor {
-
- @Record(ExecutionTime.STATIC_INIT)
- @BuildStep
- CamelMainListenerBuildItem mainListener(ApplicationRecorder recorder) {
- List<Runtime.Listener> listeners = new ArrayList<>();
- ServiceLoader.load(Runtime.Listener.class).forEach(listeners::add);
-
- return new CamelMainListenerBuildItem(recorder.createMainListener(listeners));
- }
-
- @Record(ExecutionTime.STATIC_INIT)
- @BuildStep
- CamelRoutesCollectorBuildItem routesCollector(ApplicationRecorder recorder) {
- return new CamelRoutesCollectorBuildItem(recorder.createRoutesCollector());
- }
-
- @Record(ExecutionTime.RUNTIME_INIT)
- @BuildStep
- @Consume(SyntheticBeansRuntimeInitBuildItem.class)
- CamelRuntimeTaskBuildItem registerRuntime(
- ApplicationRecorder recorder,
- CamelMainBuildItem camelMain,
- BeanContainerBuildItem beanContainer) {
-
- recorder.publishRuntime(camelMain.getInstance(), beanContainer.getValue());
- recorder.version(RuntimeSupport.getRuntimeVersion());
-
- return new CamelRuntimeTaskBuildItem("camel-k-runtime");
- }
-
- @BuildStep
- List<AdditionalBeanBuildItem> unremovableBeans() {
- return List.of(
- AdditionalBeanBuildItem.unremovableOf(ApplicationProducers.class),
- AdditionalBeanBuildItem.unremovableOf(ApplicationRoutes.class));
- }
-
- @BuildStep
- List<CamelServicePatternBuildItem> servicePatterns() {
- return List.of(
- new CamelServicePatternBuildItem(
- CamelServiceDestination.REGISTRY,
- true,
- Constants.CONTEXT_CUSTOMIZER_RESOURCE_PATH + "/*"),
- new CamelServicePatternBuildItem(
- CamelServiceDestination.DISCOVERY,
- true,
- Constants.SOURCE_LOADER_INTERCEPTOR_RESOURCE_PATH + "/*"));
- }
-
- @BuildStep
- List<ReflectiveClassBuildItem> registerClasses(CombinedIndexBuildItem index) {
- return List.of(
- ReflectiveClassBuildItem.builder(SourceDefinition.class).methods().fields(false).build(),
- reflectiveClassBuildItem(getAllKnownImplementors(index.getIndex(), CamelContextCustomizer.class)),
- reflectiveClassBuildItem(getAllKnownImplementors(index.getIndex(), RouteBuilderLifecycleStrategy.class)));
- }
-
- @BuildStep
- List<ServiceProviderBuildItem> registerServices(CombinedIndexBuildItem combinedIndexBuildItem) {
- final IndexView view = combinedIndexBuildItem.getIndex();
- final String serviceType = "org.apache.camel.quarkus.k.core.Runtime$Listener";
- return stream(getAllKnownImplementors(view, serviceType))
- .map(i -> new ServiceProviderBuildItem(serviceType, i.name().toString()))
- .collect(Collectors.toList());
- }
-
@BuildStep
void registerStreamCachingClasses(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
CombinedIndexBuildItem combinedIndex) {
@@ -139,9 +53,31 @@ public class RuntimeProcessor {
.forEach(i -> reflectiveClass.produce(reflectiveClassBuildItem(i)));
}
+ @BuildStep
+ void unremovableBeans(
+ BuildProducer<AdditionalBeanBuildItem> additionalBeans,
+ BuildProducer<CamelRuntimeTaskBuildItem> runtimeTasks) {
+
+ additionalBeans.produce(
+ AdditionalBeanBuildItem.unremovableOf(ApplicationRoutes.class));
+ additionalBeans.produce(
+ AdditionalBeanBuildItem.unremovableOf(ApplicationRoutesConfig.class));
+ additionalBeans.produce(
+ AdditionalBeanBuildItem.unremovableOf(ApplicationShutdownConfig.class));
+
+ runtimeTasks.produce(
+ new CamelRuntimeTaskBuildItem("camel-k"));
+ }
+
@BuildStep
@Record(value = ExecutionTime.STATIC_INIT, optional = true)
CamelModelReifierFactoryBuildItem modelReifierFactory(ApplicationRecorder recorder) {
return new CamelModelReifierFactoryBuildItem(recorder.modelReifierFactory());
}
+
+ @BuildStep
+ @Record(value = ExecutionTime.RUNTIME_INIT)
+ RuntimeCamelContextCustomizerBuildItem eventNotifier(ApplicationRecorder recorder, ApplicationShutdownConfig config) {
+ return new RuntimeCamelContextCustomizerBuildItem(recorder.shutdownCustomizer(config));
+ }
}
diff --git a/extensions/camel-k/deployment/src/main/java/org/apache/camel/quarkus/k/deployment/devmode/HotDeploymentProcessor.java b/extensions/camel-k/deployment/src/main/java/org/apache/camel/quarkus/k/deployment/devmode/HotDeploymentProcessor.java
index 8777938ca5..6e430aaccd 100644
--- a/extensions/camel-k/deployment/src/main/java/org/apache/camel/quarkus/k/deployment/devmode/HotDeploymentProcessor.java
+++ b/extensions/camel-k/deployment/src/main/java/org/apache/camel/quarkus/k/deployment/devmode/HotDeploymentProcessor.java
@@ -31,8 +31,7 @@ import java.util.Optional;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.HotDeploymentWatchedFileBuildItem;
-import org.apache.camel.quarkus.k.support.Constants;
-import org.apache.camel.util.StringHelper;
+import org.apache.camel.quarkus.k.runtime.ApplicationConstants;
import org.apache.commons.io.FilenameUtils;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
@@ -43,36 +42,11 @@ public class HotDeploymentProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(HotDeploymentProcessor.class);
- @BuildStep
- List<HotDeploymentWatchedFileBuildItem> routes() {
- final Config config = ConfigProvider.getConfig();
- final Optional<String> value = config.getOptionalValue(Constants.PROPERTY_CAMEL_K_ROUTES, String.class);
-
- List<HotDeploymentWatchedFileBuildItem> items = new ArrayList<>();
-
- if (value.isPresent()) {
- for (String source : value.get().split(",", -1)) {
- String path = StringHelper.after(source, ":");
- if (path == null) {
- path = source;
- }
-
- Path p = Paths.get(path);
- if (Files.exists(p)) {
- LOGGER.info("Register source for hot deployment: {}", p.toAbsolutePath());
- items.add(new HotDeploymentWatchedFileBuildItem(p.toAbsolutePath().toString()));
- }
- }
- }
-
- return items;
- }
-
@BuildStep
List<HotDeploymentWatchedFileBuildItem> conf() {
final Config config = ConfigProvider.getConfig();
- final Optional<String> conf = config.getOptionalValue(Constants.PROPERTY_CAMEL_K_CONF, String.class);
- final Optional<String> confd = config.getOptionalValue(Constants.PROPERTY_CAMEL_K_CONF_D, String.class);
+ final Optional<String> conf = config.getOptionalValue(ApplicationConstants.PROPERTY_CAMEL_K_CONF, String.class);
+ final Optional<String> confd = config.getOptionalValue(ApplicationConstants.PROPERTY_CAMEL_K_CONF_D, String.class);
List<HotDeploymentWatchedFileBuildItem> items = new ArrayList<>();
diff --git a/extensions/camel-k/deployment/src/test/java/org/apache/camel/quarkus/k/deployment/LoaderTest.java b/extensions/camel-k/deployment/src/test/java/org/apache/camel/quarkus/k/deployment/LoaderTest.java
deleted file mode 100644
index 5d398f4f54..0000000000
--- a/extensions/camel-k/deployment/src/test/java/org/apache/camel/quarkus/k/deployment/LoaderTest.java
+++ /dev/null
@@ -1,335 +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.quarkus.k.deployment;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.Collection;
-import java.util.ServiceLoader;
-
-import io.quarkus.test.QuarkusUnitTest;
-import io.restassured.RestAssured;
-import io.restassured.path.json.JsonPath;
-import jakarta.enterprise.context.ApplicationScoped;
-import jakarta.inject.Inject;
-import jakarta.json.Json;
-import jakarta.json.JsonArrayBuilder;
-import jakarta.json.JsonObject;
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import org.apache.camel.CamelContext;
-import org.apache.camel.ExtendedCamelContext;
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.quarkus.k.core.Runtime;
-import org.apache.camel.quarkus.k.listener.ContextConfigurer;
-import org.apache.camel.quarkus.k.listener.SourcesConfigurer;
-import org.apache.camel.spi.RoutesLoader;
-import org.apache.camel.support.PluginHelper;
-import org.apache.camel.support.ResourceHelper;
-import org.apache.camel.util.IOHelper;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class LoaderTest {
- @RegisterExtension
- public static final QuarkusUnitTest test = new QuarkusUnitTest()
- .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
- .addClasses(Application.class, LoaderSupport.class)
- .addAsResource("MyRoutes.java")
- .addAsResource("routes.groovy")
- .addAsResource("routes.js")
- .addAsResource("routes.jsh")
- .addAsResource("routes.kts")
- .addAsResource("routes.xml")
- .addAsResource("routes.yaml"))
- .overrideConfigKey("quarkus.camel.routes-discovery.enabled", "false");
-
- @Test
- public void testServices() {
- JsonPath p = RestAssured.given()
- .accept(MediaType.APPLICATION_JSON)
- .get("/camel-k/loader/services")
- .then()
- .statusCode(200)
- .extract()
- .body()
- .jsonPath();
-
- assertThat(p.getList("services", String.class)).contains(
- ContextConfigurer.class.getName(),
- SourcesConfigurer.class.getName());
- }
-
- @Test
- public void testLoadGroovyRoutes() throws IOException {
- String code;
- try (InputStream is = LoaderTest.class.getResourceAsStream("/routes.groovy")) {
- code = IOHelper.loadText(is);
- }
-
- JsonPath p = RestAssured.given()
- .contentType(MediaType.TEXT_PLAIN)
- .accept(MediaType.APPLICATION_JSON)
- .body(code)
- .post("/camel-k/loader/load-routes/groovy/MyRoute")
- .then()
- .statusCode(200)
- .extract()
- .body()
- .jsonPath();
-
- assertThat(p.getList("components", String.class)).contains("direct", "log");
- assertThat(p.getList("routes", String.class)).contains("groovy");
- assertThat(p.getList("endpoints", String.class)).contains("direct://groovy", "log://groovy");
- }
-
- @Test
- public void testLoadJavaRoutes() throws IOException {
- String code;
-
- try (InputStream is = LoaderTest.class.getResourceAsStream("/MyRoutes.java")) {
- code = IOHelper.loadText(is);
- }
-
- JsonPath p = RestAssured.given()
- .contentType(MediaType.TEXT_PLAIN)
- .accept(MediaType.APPLICATION_JSON)
- .body(code)
- .post("/camel-k/loader/load-routes/java/MyRoutes")
- .then()
- .statusCode(200)
- .extract()
- .body()
- .jsonPath();
-
- assertThat(p.getList("components", String.class)).contains("direct", "log");
- assertThat(p.getList("routes", String.class)).contains("java");
- assertThat(p.getList("endpoints", String.class)).contains("direct://java", "log://java");
- }
-
- @Test
- public void testLoadJavascriptRoutes() throws IOException {
- String code;
-
- try (InputStream is = LoaderTest.class.getResourceAsStream("/routes.js")) {
- code = IOHelper.loadText(is);
- }
-
- JsonPath p = RestAssured.given()
- .contentType(MediaType.TEXT_PLAIN)
- .accept(MediaType.APPLICATION_JSON)
- .body(code)
- .post("/camel-k/loader/load-routes/js/MyRoute")
- .then()
- .statusCode(200)
- .extract()
- .body()
- .jsonPath();
-
- assertThat(p.getList("components", String.class)).contains("direct", "log");
- assertThat(p.getList("routes", String.class)).contains("js");
- assertThat(p.getList("endpoints", String.class)).contains("direct://js", "log://js");
- }
-
- @Test
- public void testLoadJshRoutes() throws IOException {
- String code;
-
- try (InputStream is = LoaderTest.class.getResourceAsStream("/routes.jsh")) {
- code = IOHelper.loadText(is);
- }
-
- JsonPath p = RestAssured.given()
- .contentType(MediaType.TEXT_PLAIN)
- .accept(MediaType.APPLICATION_JSON)
- .body(code)
- .post("/camel-k/loader/load-routes/jsh/routes")
- .then()
- .statusCode(200)
- .extract()
- .body()
- .jsonPath();
-
- assertThat(p.getList("components", String.class)).contains("direct", "log");
- assertThat(p.getList("routes", String.class)).contains("jsh");
- assertThat(p.getList("endpoints", String.class)).contains("direct://jsh", "log://jsh");
- }
-
- @Test
- public void testLoadKotlinRoutes() throws IOException {
-
- String code;
-
- try (InputStream is = LoaderTest.class.getResourceAsStream("/routes.kts")) {
- code = IOHelper.loadText(is);
- }
-
- JsonPath p = RestAssured.given()
- .contentType(MediaType.TEXT_PLAIN)
- .accept(MediaType.APPLICATION_JSON)
- .body(code)
- .post("/camel-k/loader/load-routes/kts/MyRoute")
- .then()
- .statusCode(200)
- .extract()
- .body()
- .jsonPath();
-
- assertThat(p.getList("components", String.class)).contains("direct", "log");
- assertThat(p.getList("routes", String.class)).contains("kotlin");
- assertThat(p.getList("endpoints", String.class)).contains("direct://kotlin", "log://kotlin");
- }
-
- @Test
- public void testLoadXmlRoutes() throws IOException {
- String code;
-
- try (InputStream is = LoaderTest.class.getResourceAsStream("/routes.xml")) {
- code = IOHelper.loadText(is);
- }
-
- JsonPath p = RestAssured.given()
- .contentType(MediaType.TEXT_PLAIN)
- .accept(MediaType.APPLICATION_JSON)
- .body(code)
- .post("/camel-k/loader/load-routes/xml/MyRoute")
- .then()
- .statusCode(200)
- .extract()
- .body()
- .jsonPath();
-
- assertThat(p.getList("components", String.class)).contains("direct", "log");
- assertThat(p.getList("routes", String.class)).contains("xml");
- assertThat(p.getList("endpoints", String.class)).contains("direct://xml", "log://xml");
- }
-
- @Test
- public void testLoadYamlRoutes() throws IOException {
- String code;
-
- try (InputStream is = LoaderTest.class.getResourceAsStream("/routes.yaml")) {
- code = IOHelper.loadText(is);
- }
-
- JsonPath p = RestAssured.given()
- .contentType(MediaType.TEXT_PLAIN)
- .accept(MediaType.APPLICATION_JSON)
- .body(code)
- .post("/camel-k/loader/load-routes/yaml/MyRoute")
- .then()
- .statusCode(200)
- .extract()
- .body()
- .jsonPath();
-
- assertThat(p.getList("components", String.class)).contains("direct", "log");
- assertThat(p.getList("routes", String.class)).contains("yaml");
- assertThat(p.getList("endpoints", String.class)).contains("direct://yaml", "log://yaml");
- }
-
- @Path("/camel-k/loader")
- @ApplicationScoped
- public static class Application {
-
- @Inject
- CamelContext context;
-
- // k-core
- @GET
- @Path("/services")
- @Produces(MediaType.APPLICATION_JSON)
- public JsonObject getServices() {
- JsonArrayBuilder builder = Json.createArrayBuilder();
-
- ServiceLoader.load(Runtime.Listener.class).forEach(listener -> {
- builder.add(listener.getClass().getName());
- });
-
- return Json.createObjectBuilder()
- .add("services", builder)
- .build();
- }
-
- @POST
- @Path("/load-routes/{loaderName}/{name}")
- @Consumes(MediaType.TEXT_PLAIN)
- @Produces(MediaType.APPLICATION_JSON)
- public JsonObject loadRoutes(@PathParam("loaderName") String loaderName, @PathParam("name") String name, byte[] code)
- throws Exception {
- return LoaderSupport.inspectSource(context, name + "." + loaderName, code);
- }
- }
-
- static final class LoaderSupport {
- private LoaderSupport() {
- }
-
- public static JsonObject inspectSource(CamelContext context, String location, byte[] code) throws Exception {
- final Runtime runtime = Runtime.on(context);
- final ExtendedCamelContext ecc = runtime.getExtendedCamelContext();
- final RoutesLoader loader = PluginHelper.getRoutesLoader(ecc);
- final Collection<RoutesBuilder> builders = loader.findRoutesBuilders(ResourceHelper.fromBytes(location, code));
-
- for (RoutesBuilder builder : builders) {
- runtime.addRoutes(builder);
- }
-
- return Json.createObjectBuilder()
- .add("components", extractComponents(context))
- .add("routes", extractRoutes(context))
- .add("endpoints", extractEndpoints(context))
- .build();
- }
-
- public static JsonObject inspectSource(CamelContext context, String location, String code) throws Exception {
- return inspectSource(context, location, code.getBytes(StandardCharsets.UTF_8));
- }
-
- public static JsonArrayBuilder extractComponents(CamelContext context) {
- JsonArrayBuilder answer = Json.createArrayBuilder();
- context.getComponentNames().forEach(answer::add);
-
- return answer;
- }
-
- public static JsonArrayBuilder extractRoutes(CamelContext context) {
- JsonArrayBuilder answer = Json.createArrayBuilder();
- context.getRoutes().forEach(r -> answer.add(r.getId()));
-
- return answer;
- }
-
- public static JsonArrayBuilder extractEndpoints(CamelContext context) {
- JsonArrayBuilder answer = Json.createArrayBuilder();
- context.getEndpoints().forEach(e -> answer.add(e.getEndpointUri()));
-
- return answer;
- }
- }
-
-}
diff --git a/extensions/camel-k/deployment/src/test/resources/MyRoutes.java b/extensions/camel-k/deployment/src/test/resources/MyRoutes.java
deleted file mode 100644
index d305e3e2d5..0000000000
--- a/extensions/camel-k/deployment/src/test/resources/MyRoutes.java
+++ /dev/null
@@ -1,26 +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.
- */
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyRoutes extends RouteBuilder {
- @Override
- public void configure() throws Exception {
- from("direct:java")
- .routeId("java")
- .to("log:java");
- }
-}
\ No newline at end of file
diff --git a/extensions/camel-k/deployment/src/test/resources/routes.groovy b/extensions/camel-k/deployment/src/test/resources/routes.groovy
deleted file mode 100644
index a96deb2378..0000000000
--- a/extensions/camel-k/deployment/src/test/resources/routes.groovy
+++ /dev/null
@@ -1,20 +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.
- */
-
-from('direct:groovy')
- .routeId('groovy')
- .to('log:groovy')
\ No newline at end of file
diff --git a/extensions/camel-k/deployment/src/test/resources/routes.js b/extensions/camel-k/deployment/src/test/resources/routes.js
deleted file mode 100644
index 414fe0a798..0000000000
--- a/extensions/camel-k/deployment/src/test/resources/routes.js
+++ /dev/null
@@ -1,19 +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.
- */
-from('direct:js')
- .routeId('js')
- .to('log:js')
\ No newline at end of file
diff --git a/extensions/camel-k/deployment/src/test/resources/routes.jsh b/extensions/camel-k/deployment/src/test/resources/routes.jsh
deleted file mode 100644
index c47a78f30f..0000000000
--- a/extensions/camel-k/deployment/src/test/resources/routes.jsh
+++ /dev/null
@@ -1,21 +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.
- */
-
-
-builder.from("direct:jsh")
- .routeId("jsh")
- .to("log:jsh");
diff --git a/extensions/camel-k/deployment/src/test/resources/routes.xml b/extensions/camel-k/deployment/src/test/resources/routes.xml
deleted file mode 100644
index 2bb35d9d4d..0000000000
--- a/extensions/camel-k/deployment/src/test/resources/routes.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://camel.apache.org/schema/spring"
- xsi:schemaLocation="
- http://camel.apache.org/schema/spring
- http://camel.apache.org/schema/spring/camel-spring.xsd">
-
- <route id="xml">
- <from uri="direct:xml"/>
- <marshal>
- <json/>
- </marshal>
- <to uri="log:xml"/>
- </route>
-
-</routes>
\ No newline at end of file
diff --git a/extensions/camel-k/runtime/pom.xml b/extensions/camel-k/runtime/pom.xml
index 2dd1917a79..3b92a22ffe 100644
--- a/extensions/camel-k/runtime/pom.xml
+++ b/extensions/camel-k/runtime/pom.xml
@@ -167,16 +167,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <environmentVariables>
- <CAMEL_K_RESOURCE_001>my env content</CAMEL_K_RESOURCE_001>
- <MY_ENV_RESOURCE_TXT>env:CAMEL_K_RESOURCE_001</MY_ENV_RESOURCE_TXT>
- <CAMEL_K_RESOURCE_002>H4sIAFlah1wAA8utVEjOzy0oSi0uTk1RSM0rA3LzSlLzSrgAUbkzGRoAAAA=</CAMEL_K_RESOURCE_002>
- <MY_COMPRESSED_ENV_RESOURCE_TXT>env:CAMEL_K_RESOURCE_002?compression=true</MY_COMPRESSED_ENV_RESOURCE_TXT>
- </environmentVariables>
<systemPropertyVariables>
<root>${project.basedir}</root>
- <camel.k.mount-path.configmaps>${project.basedir}/src/test/resources/configmaps</camel.k.mount-path.configmaps>
- <camel.k.mount-path.secrets>${project.basedir}/src/test/resources/secrets</camel.k.mount-path.secrets>
+ <camel.k.mount-path.configmaps>${project.basedir}/src/test/resources/conf.d/_configmaps</camel.k.mount-path.configmaps>
+ <camel.k.mount-path.secrets>${project.basedir}/src/test/resources/conf.d/_secrets</camel.k.mount-path.secrets>
<camel.kubernetes-config.client-enabled>false</camel.kubernetes-config.client-enabled>
</systemPropertyVariables>
</configuration>
diff --git a/extensions/camel-k/runtime/src/generated/java/org/apache/camel/quarkus/k/core/SourceDefinitionConfigurer.java b/extensions/camel-k/runtime/src/generated/java/org/apache/camel/quarkus/k/core/SourceDefinitionConfigurer.java
deleted file mode 100644
index be4f0d7a7f..0000000000
--- a/extensions/camel-k/runtime/src/generated/java/org/apache/camel/quarkus/k/core/SourceDefinitionConfigurer.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/* Generated by camel build tools - do NOT edit this file! */
-package org.apache.camel.quarkus.k.core;
-
-import java.util.Map;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
-import org.apache.camel.spi.PropertyConfigurerGetter;
-import org.apache.camel.spi.ConfigurerStrategy;
-import org.apache.camel.spi.GeneratedPropertyConfigurer;
-import org.apache.camel.util.CaseInsensitiveMap;
-import org.apache.camel.quarkus.k.core.SourceDefinition;
-
-/**
- * Generated by camel build tools - do NOT edit this file!
- */
-@SuppressWarnings("unchecked")
-public class SourceDefinitionConfigurer extends org.apache.camel.support.component.PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
-
- @Override
- public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
- org.apache.camel.quarkus.k.core.SourceDefinition target = (org.apache.camel.quarkus.k.core.SourceDefinition) obj;
- switch (ignoreCase ? name.toLowerCase() : name) {
- case "compressed":
- case "Compressed": target.setCompressed(property(camelContext, boolean.class, value)); return true;
- case "content":
- case "Content": target.setContent(property(camelContext, byte[].class, value)); return true;
- case "id":
- case "Id": target.setId(property(camelContext, java.lang.String.class, value)); return true;
- case "interceptors":
- case "Interceptors": target.setInterceptors(property(camelContext, java.util.List.class, value)); return true;
- case "language":
- case "Language": target.setLanguage(property(camelContext, java.lang.String.class, value)); return true;
- case "loader":
- case "Loader": target.setLoader(property(camelContext, java.lang.String.class, value)); return true;
- case "location":
- case "Location": target.setLocation(property(camelContext, java.lang.String.class, value)); return true;
- case "name":
- case "Name": target.setName(property(camelContext, java.lang.String.class, value)); return true;
- case "propertynames":
- case "PropertyNames": target.setPropertyNames(property(camelContext, java.util.List.class, value)); return true;
- case "type":
- case "Type": target.setType(property(camelContext, org.apache.camel.quarkus.k.core.SourceType.class, value)); return true;
- default: return false;
- }
- }
-
- @Override
- public Class<?> getOptionType(String name, boolean ignoreCase) {
- switch (ignoreCase ? name.toLowerCase() : name) {
- case "compressed":
- case "Compressed": return boolean.class;
- case "content":
- case "Content": return byte[].class;
- case "id":
- case "Id": return java.lang.String.class;
- case "interceptors":
- case "Interceptors": return java.util.List.class;
- case "language":
- case "Language": return java.lang.String.class;
- case "loader":
- case "Loader": return java.lang.String.class;
- case "location":
- case "Location": return java.lang.String.class;
- case "name":
- case "Name": return java.lang.String.class;
- case "propertynames":
- case "PropertyNames": return java.util.List.class;
- case "type":
- case "Type": return org.apache.camel.quarkus.k.core.SourceType.class;
- default: return null;
- }
- }
-
- @Override
- public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
- org.apache.camel.quarkus.k.core.SourceDefinition target = (org.apache.camel.quarkus.k.core.SourceDefinition) obj;
- switch (ignoreCase ? name.toLowerCase() : name) {
- case "compressed":
- case "Compressed": return target.isCompressed();
- case "content":
- case "Content": return target.getContent();
- case "id":
- case "Id": return target.getId();
- case "interceptors":
- case "Interceptors": return target.getInterceptors();
- case "language":
- case "Language": return target.getLanguage();
- case "loader":
- case "Loader": return target.getLoader();
- case "location":
- case "Location": return target.getLocation();
- case "name":
- case "Name": return target.getName();
- case "propertynames":
- case "PropertyNames": return target.getPropertyNames();
- case "type":
- case "Type": return target.getType();
- default: return null;
- }
- }
-
- @Override
- public Object getCollectionValueType(Object target, String name, boolean ignoreCase) {
- switch (ignoreCase ? name.toLowerCase() : name) {
- case "interceptors":
- case "Interceptors": return java.lang.String.class;
- case "propertynames":
- case "PropertyNames": return java.lang.String.class;
- default: return null;
- }
- }
-}
-
diff --git a/extensions/camel-k/runtime/src/generated/java/org/apache/camel/quarkus/k/listener/SourcesConfigurerConfigurer.java b/extensions/camel-k/runtime/src/generated/java/org/apache/camel/quarkus/k/listener/SourcesConfigurerConfigurer.java
deleted file mode 100644
index d0586e63f8..0000000000
--- a/extensions/camel-k/runtime/src/generated/java/org/apache/camel/quarkus/k/listener/SourcesConfigurerConfigurer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Generated by camel build tools - do NOT edit this file! */
-package org.apache.camel.quarkus.k.listener;
-
-import java.util.Map;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
-import org.apache.camel.spi.PropertyConfigurerGetter;
-import org.apache.camel.spi.ConfigurerStrategy;
-import org.apache.camel.spi.GeneratedPropertyConfigurer;
-import org.apache.camel.util.CaseInsensitiveMap;
-import org.apache.camel.quarkus.k.listener.SourcesConfigurer;
-
-/**
- * Generated by camel build tools - do NOT edit this file!
- */
-@SuppressWarnings("unchecked")
-public class SourcesConfigurerConfigurer extends org.apache.camel.support.component.PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
-
- @Override
- public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
- org.apache.camel.quarkus.k.listener.SourcesConfigurer target = (org.apache.camel.quarkus.k.listener.SourcesConfigurer) obj;
- switch (ignoreCase ? name.toLowerCase() : name) {
- case "sources":
- case "Sources": target.setSources(property(camelContext, org.apache.camel.quarkus.k.core.SourceDefinition[].class, value)); return true;
- default: return false;
- }
- }
-
- @Override
- public Class<?> getOptionType(String name, boolean ignoreCase) {
- switch (ignoreCase ? name.toLowerCase() : name) {
- case "sources":
- case "Sources": return org.apache.camel.quarkus.k.core.SourceDefinition[].class;
- default: return null;
- }
- }
-
- @Override
- public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
- org.apache.camel.quarkus.k.listener.SourcesConfigurer target = (org.apache.camel.quarkus.k.listener.SourcesConfigurer) obj;
- switch (ignoreCase ? name.toLowerCase() : name) {
- case "sources":
- case "Sources": return target.getSources();
- default: return null;
- }
- }
-}
-
diff --git a/extensions/camel-k/runtime/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.quarkus.k.core.SourceDefinition b/extensions/camel-k/runtime/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.quarkus.k.core.SourceDefinition
deleted file mode 100644
index 92383b0230..0000000000
--- a/extensions/camel-k/runtime/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.quarkus.k.core.SourceDefinition
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated by camel build tools - do NOT edit this file!
-class=org.apache.camel.quarkus.k.core.SourceDefinitionConfigurer
diff --git a/extensions/camel-k/runtime/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.quarkus.k.listener.SourcesConfigurer b/extensions/camel-k/runtime/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.quarkus.k.listener.SourcesConfigurer
deleted file mode 100644
index 6a1ffed062..0000000000
--- a/extensions/camel-k/runtime/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.quarkus.k.listener.SourcesConfigurer
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated by camel build tools - do NOT edit this file!
-class=org.apache.camel.quarkus.k.listener.SourcesConfigurerConfigurer
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/Runtime.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/Runtime.java
deleted file mode 100644
index f67b227753..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/Runtime.java
+++ /dev/null
@@ -1,156 +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.quarkus.k.core;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ExtendedCamelContext;
-import org.apache.camel.Ordered;
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.spi.HasCamelContext;
-import org.apache.camel.spi.Registry;
-
-import static org.apache.camel.util.CollectionHelper.mapOf;
-
-public interface Runtime extends HasCamelContext, AutoCloseable {
- /**
- * Returns the camel context adapting it to the specialized type.
- *
- * @see HasCamelContext#getCamelContext()
- *
- * @return the extended camel context.
- */
- default ExtendedCamelContext getExtendedCamelContext() {
- return getCamelContext().getCamelContextExtension();
- }
-
- /**
- * Returns the registry associated to this runtime.
- */
- default Registry getRegistry() {
- return getCamelContext().getRegistry();
- }
-
- /**
- * Sets a special list of properties that take precedence and will use first, if a property exist.
- *
- * @see org.apache.camel.spi.PropertiesComponent#setOverrideProperties(Properties)
- * @param properties the properties to set
- */
- default void setProperties(Properties properties) {
- getCamelContext().getPropertiesComponent().setOverrideProperties(properties);
- }
-
- /**
- * Sets a special list of properties that take precedence and will use first, if a property exist.
- *
- * @see org.apache.camel.spi.PropertiesComponent#setOverrideProperties(Properties)
- * @param properties the properties to set
- */
- default void setProperties(Map<String, String> properties) {
- Properties p = new Properties();
- p.putAll(properties);
-
- setProperties(p);
- }
-
- /**
- * Sets a special list of properties that take precedence and will use first, if a property exist.
- *
- * @see org.apache.camel.spi.PropertiesComponent#setOverrideProperties(Properties)
- * @param key the mapping's key
- * @param value the mapping's value
- * @param entries containing the keys and values from which the map is populated
- *
- */
- default void setProperties(String key, String value, String... entries) {
- setProperties(
- mapOf(HashMap::new, key, value, entries));
- }
-
- /**
- * Sets a special list of properties that take precedence and will use first, if a property exist.
- *
- * @see org.apache.camel.spi.PropertiesComponent#setOverrideProperties(Properties)
- * @param builder the builder which will create the routes
- */
- default void addRoutes(RoutesBuilder builder) {
- try {
- getCamelContext().addRoutes(builder);
- } catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
- }
- }
-
- /**
- * Lifecycle method used to stops the entire integration.
- */
- default void stop() throws Exception {
- // Stopping the Camel context in default config is enough to tear down the integration
- getCamelContext().stop();
- }
-
- @Override
- default void close() throws Exception {
- stop();
- }
-
- enum Phase {
- Initializing,
- ConfigureProperties,
- ConfigureContext,
- ConfigureRoutes,
- Starting,
- Started,
- Stopping,
- Stopped
- }
-
- @FunctionalInterface
- interface Listener extends Ordered {
- boolean accept(Phase phase, Runtime runtime);
-
- @Override
- default int getOrder() {
- return Ordered.LOWEST;
- }
- }
-
- /**
- * Helper to create a simple runtime from a given Camel Context.
- *
- * @param camelContext the camel context
- * @return the runtime
- */
- static Runtime on(CamelContext camelContext) {
- return () -> camelContext;
- }
-
- /**
- * Helper to create a simple runtime from a given Camel Context provider.
- *
- * @param provider the camel context provider
- * @return the runtime
- */
- static Runtime on(HasCamelContext provider) {
- return provider::getCamelContext;
- }
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/RuntimeAware.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/RuntimeAware.java
deleted file mode 100644
index a6df6d2d4e..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/RuntimeAware.java
+++ /dev/null
@@ -1,24 +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.quarkus.k.core;
-
-public interface RuntimeAware {
-
- void setRuntime(Runtime runtime);
-
- Runtime getRuntime();
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/Source.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/Source.java
deleted file mode 100644
index afbe41235b..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/Source.java
+++ /dev/null
@@ -1,54 +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.quarkus.k.core;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.Optional;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.spi.HasId;
-
-public interface Source extends HasId {
- String getLocation();
-
- String getName();
-
- String getLanguage();
-
- SourceType getType();
-
- Optional<String> getLoader();
-
- List<String> getInterceptors();
-
- List<String> getPropertyNames();
-
- InputStream resolveAsInputStream(CamelContext ctx);
-
- default Reader resolveAsReader(CamelContext ctx) {
- return resolveAsReader(ctx, StandardCharsets.UTF_8);
- }
-
- default Reader resolveAsReader(CamelContext ctx, Charset charset) {
- return new InputStreamReader(resolveAsInputStream(ctx), charset);
- }
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/SourceDefinition.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/SourceDefinition.java
deleted file mode 100644
index 45ba6cef9c..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/SourceDefinition.java
+++ /dev/null
@@ -1,184 +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.quarkus.k.core;
-
-import java.util.List;
-
-import org.apache.camel.spi.Configurer;
-import org.apache.camel.spi.IdAware;
-
-@Configurer
-public class SourceDefinition implements IdAware {
- private String id;
- private String name;
- private String language;
- private String loader;
- private List<String> interceptors;
- // Default as source type
- private SourceType type = SourceType.source;
- private List<String> propertyNames;
- private String location;
- private byte[] content;
- private boolean compressed;
-
- @Override
- public String getId() {
- return id;
- }
-
- /**
- * Sets the id
- */
- @Override
- public void setId(String id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- /**
- * The name of the source.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- public String getLanguage() {
- return language;
- }
-
- /**
- * The language use to define the source.
- */
- public void setLanguage(String language) {
- this.language = language;
- }
-
- public String getLoader() {
- return loader;
- }
-
- /**
- * The {@link SourceLoader} that should be used to load the content of the source.
- */
- public void setLoader(String loader) {
- this.loader = loader;
- }
-
- public List<String> getInterceptors() {
- return interceptors;
- }
-
- /**
- * The {@link org.apache.camel.quarkus.SourceLoader.Interceptor} that should be applied.
- */
- public void setInterceptors(List<String> interceptors) {
- this.interceptors = interceptors;
- }
-
- public SourceType getType() {
- return type;
- }
-
- /**
- * The {@link SourceType} of the source.
- */
- public void setType(SourceType type) {
- this.type = type;
- }
-
- public List<String> getPropertyNames() {
- return propertyNames;
- }
-
- /**
- * The list of properties names the source requires (used only for templates).
- */
- public void setPropertyNames(List<String> propertyNames) {
- this.propertyNames = propertyNames;
- }
-
- public String getLocation() {
- return location;
- }
-
- /**
- * The location of the source.
- */
- public void setLocation(String location) {
- this.location = location;
- }
-
- public byte[] getContent() {
- return content;
- }
-
- /**
- * The content of the source.
- */
- public void setContent(byte[] content) {
- this.content = content;
- }
-
- public boolean isCompressed() {
- return compressed;
- }
-
- /**
- * If the content of the source is compressed.
- */
- public void setCompressed(boolean compressed) {
- this.compressed = compressed;
- }
-
- @Override
- public String toString() {
- String answer = "";
-
- if (name != null) {
- answer += "name='" + name + "', ";
- }
- if (language != null) {
- answer += "language='" + language + "', ";
- }
- if (loader != null) {
- answer += "loader='" + loader + "', ";
- }
- if (interceptors != null) {
- answer += "interceptors='" + interceptors + "', ";
- }
- if (type != null) {
- answer += "type='" + type + "', ";
- }
- if (propertyNames != null) {
- answer += "propertyNames='" + propertyNames + "', ";
- }
- if (location != null) {
- answer += "location='" + location + "', ";
- }
- if (compressed) {
- answer += "compressed='true', ";
- }
- if (content != null) {
- answer += "<...>";
- }
-
- return "SourceDefinition{" + answer + '}';
- }
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/SourceType.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/SourceType.java
deleted file mode 100644
index da4e053ad4..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/core/SourceType.java
+++ /dev/null
@@ -1,24 +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.quarkus.k.core;
-
-public enum SourceType {
- // Order matters. We want the sources to be loaded following this enum order.
- errorHandler,
- template,
- source
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/listener/AbstractPhaseListener.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/listener/AbstractPhaseListener.java
deleted file mode 100644
index f303ba3aad..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/listener/AbstractPhaseListener.java
+++ /dev/null
@@ -1,39 +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.quarkus.k.listener;
-
-import org.apache.camel.quarkus.k.core.Runtime;
-
-public abstract class AbstractPhaseListener implements Runtime.Listener {
- private final Runtime.Phase phase;
-
- protected AbstractPhaseListener(Runtime.Phase phase) {
- this.phase = phase;
- }
-
- @Override
- public boolean accept(Runtime.Phase phase, Runtime runtime) {
- boolean run = this.phase == phase;
- if (run) {
- accept(runtime);
- }
-
- return run;
- }
-
- protected abstract void accept(Runtime runtime);
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/listener/ContextConfigurer.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/listener/ContextConfigurer.java
deleted file mode 100644
index 7c1f965c48..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/listener/ContextConfigurer.java
+++ /dev/null
@@ -1,38 +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.quarkus.k.listener;
-
-import org.apache.camel.quarkus.k.core.Runtime;
-import org.apache.camel.quarkus.k.support.RuntimeSupport;
-
-public class ContextConfigurer extends AbstractPhaseListener {
-
- public ContextConfigurer() {
- super(Runtime.Phase.ConfigureContext);
- }
-
- @Override
- protected void accept(Runtime runtime) {
- //
- // Programmatically configure the camel context.
- //
- // This is useful to configure services such as the ClusterService,
- // RouteController, etc
- //
- RuntimeSupport.configureContextCustomizers(runtime.getCamelContext());
- }
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/listener/SourcesConfigurer.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/listener/SourcesConfigurer.java
deleted file mode 100644
index dd221e1451..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/listener/SourcesConfigurer.java
+++ /dev/null
@@ -1,109 +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.quarkus.k.listener;
-
-import java.util.Arrays;
-import java.util.Comparator;
-
-import org.apache.camel.quarkus.k.core.Runtime;
-import org.apache.camel.quarkus.k.core.SourceDefinition;
-import org.apache.camel.quarkus.k.core.SourceType;
-import org.apache.camel.quarkus.k.support.Constants;
-import org.apache.camel.quarkus.k.support.PropertiesSupport;
-import org.apache.camel.quarkus.k.support.SourcesSupport;
-import org.apache.camel.spi.Configurer;
-import org.apache.camel.util.ObjectHelper;
-
-@Configurer
-public class SourcesConfigurer extends AbstractPhaseListener {
-
- public static final String CAMEL_K_PREFIX = "camel.k.";
- public static final String CAMEL_K_SOURCES_PREFIX = "camel.k.sources[";
-
- private SourceDefinition[] sources;
-
- public SourcesConfigurer() {
- super(Runtime.Phase.ConfigureRoutes);
- }
-
- public SourceDefinition[] getSources() {
- return sources;
- }
-
- public void setSources(SourceDefinition[] sources) {
- this.sources = sources;
- }
-
- @Override
- protected void accept(Runtime runtime) {
- //
- // load routes from env var for backward compatibility
- //
- String routes = System.getProperty(Constants.PROPERTY_CAMEL_K_ROUTES);
- if (ObjectHelper.isEmpty(routes)) {
- routes = System.getenv(Constants.ENV_CAMEL_K_ROUTES);
- }
-
- if (ObjectHelper.isNotEmpty(routes)) {
- SourcesSupport.loadSources(runtime, routes.split(","));
- }
-
- //
- // load routes from properties
- //
- // In order not to load any unwanted property, the filer remove any
- // property that can't be bound to this configurer.
- //
- PropertiesSupport.bindProperties(
- runtime.getCamelContext(),
- this,
- k -> k.startsWith(CAMEL_K_SOURCES_PREFIX),
- CAMEL_K_PREFIX);
-
- checkUniqueErrorHandler();
- sortSources();
-
- if (ObjectHelper.isNotEmpty(this.getSources())) {
- SourcesSupport.loadSources(runtime, this.getSources());
- }
- }
-
- private void checkUniqueErrorHandler() {
- checkUniqueErrorHandler(this.sources);
- }
-
- static void checkUniqueErrorHandler(SourceDefinition[] sources) {
- long errorHandlers = sources == null ? 0
- : Arrays.stream(sources).filter(s -> s.getType() == SourceType.errorHandler).count();
- if (errorHandlers > 1) {
- throw new IllegalArgumentException("Expected only one error handler source type, got " + errorHandlers);
- }
- }
-
- private void sortSources() {
- sortSources(this.getSources());
- }
-
- static void sortSources(SourceDefinition[] sources) {
- if (sources == null) {
- return;
- }
- // We must ensure the source order as defined in SourceType enum
- Arrays.sort(sources, Comparator.comparingInt(a -> a.getType().ordinal()));
- }
-
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/Application.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/Application.java
deleted file mode 100644
index 2d681a13da..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/Application.java
+++ /dev/null
@@ -1,185 +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.quarkus.k.runtime;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Optional;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import io.quarkus.arc.Arc;
-import io.quarkus.arc.ArcContainer;
-import io.quarkus.arc.InstanceHandle;
-import io.quarkus.runtime.Quarkus;
-import org.apache.camel.CamelContext;
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.main.BaseMainSupport;
-import org.apache.camel.main.MainListener;
-import org.apache.camel.main.RoutesCollector;
-import org.apache.camel.spi.Resource;
-
-public final class Application {
-
- private Application() {
- }
-
- /**
- * The camel-k runtime impl based on camel-quarkus
- */
- public static class Runtime implements org.apache.camel.quarkus.k.core.Runtime {
- private final BaseMainSupport main;
- private final AtomicBoolean stopped;
-
- public Runtime(BaseMainSupport main) {
- this.main = main;
- this.main.configure().setAutoConfigurationLogSummary(false);
- this.stopped = new AtomicBoolean();
- }
-
- @Override
- public CamelContext getCamelContext() {
- return main.getCamelContext();
- }
-
- @Override
- public void addRoutes(RoutesBuilder builder) {
- main.configure().addRoutesBuilder(builder);
- }
-
- @Override
- public void setProperties(Properties properties) {
- main.setOverrideProperties(properties);
- }
-
- @Override
- public void stop() throws Exception {
- if (!this.stopped.compareAndExchange(false, true)) {
- Quarkus.asyncExit();
- }
- }
- }
-
- /**
- * Adapts main events to camel-k runtime lifecycle
- */
- public static class ListenerAdapter implements MainListener {
- private final org.apache.camel.quarkus.k.core.Runtime.Listener[] listeners;
-
- public ListenerAdapter(List<org.apache.camel.quarkus.k.core.Runtime.Listener> listeners) {
- this.listeners = listeners.stream()
- .sorted(Comparator.comparingInt(org.apache.camel.quarkus.k.core.Runtime.Listener::getOrder))
- .toArray(org.apache.camel.quarkus.k.core.Runtime.Listener[]::new);
- }
-
- @Override
- public void beforeInitialize(BaseMainSupport main) {
- invokeListeners(org.apache.camel.quarkus.k.core.Runtime.Phase.Initializing);
- invokeListeners(org.apache.camel.quarkus.k.core.Runtime.Phase.ConfigureProperties);
- }
-
- @Override
- public void beforeConfigure(BaseMainSupport main) {
- invokeListeners(org.apache.camel.quarkus.k.core.Runtime.Phase.ConfigureRoutes);
- }
-
- @Override
- public void afterConfigure(BaseMainSupport main) {
- invokeListeners(org.apache.camel.quarkus.k.core.Runtime.Phase.ConfigureContext);
- }
-
- @Override
- public void beforeStart(BaseMainSupport main) {
- invokeListeners(org.apache.camel.quarkus.k.core.Runtime.Phase.Starting);
- }
-
- @Override
- public void afterStart(BaseMainSupport main) {
- invokeListeners(org.apache.camel.quarkus.k.core.Runtime.Phase.Started);
- }
-
- @Override
- public void beforeStop(BaseMainSupport main) {
- invokeListeners(org.apache.camel.quarkus.k.core.Runtime.Phase.Stopping);
- }
-
- @Override
- public void afterStop(BaseMainSupport main) {
- invokeListeners(org.apache.camel.quarkus.k.core.Runtime.Phase.Stopped);
- }
-
- private void invokeListeners(org.apache.camel.quarkus.k.core.Runtime.Phase phase) {
- org.apache.camel.quarkus.k.core.Runtime runtime = instance(org.apache.camel.quarkus.k.core.Runtime.class)
- .orElseThrow(() -> new IllegalStateException("Unable to fine a Runtime instance"));
-
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].accept(phase, runtime);
- }
- }
- }
-
- /**
- * Since routes are programmatically loaded, create a no-hop collector
- */
- public static class NoRoutesCollector implements RoutesCollector {
- @Override
- public Collection<RoutesBuilder> collectRoutesFromDirectory(CamelContext camelContext, String excludePattern,
- String includePattern) {
- return Collections.emptyList();
- }
-
- @Override
- public Collection<Resource> findRouteResourcesFromDirectory(CamelContext camelContext, String excludePattern,
- String includePattern) {
- return Collections.emptyList();
- }
-
- @Override
- public boolean isIgnoreLoadingError() {
- return false;
- }
-
- @Override
- public void setIgnoreLoadingError(boolean ignoreLoadingError) {
- // Noop
- }
-
- @Override
- public List<RoutesBuilder> collectRoutesFromRegistry(CamelContext camelContext, String excludePattern,
- String includePattern) {
- return Collections.emptyList();
- }
- }
-
- // *********************************
- //
- // Helpers
- //
- // *********************************
-
- public static Optional<ArcContainer> container() {
- return Optional.of(Arc.container());
- }
-
- public static <T> Optional<T> instance(Class<T> type) {
- return container()
- .map(container -> container.instance(type))
- .map(InstanceHandle::get);
- }
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationConfigSourceProvider.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationConfigSourceProvider.java
index f0fb7f90f6..be130b57b5 100644
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationConfigSourceProvider.java
+++ b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationConfigSourceProvider.java
@@ -16,17 +16,34 @@
*/
package org.apache.camel.quarkus.k.runtime;
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.charset.MalformedInputException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.FileVisitResult;
+import java.nio.file.FileVisitor;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
import io.smallrye.config.PropertiesConfigSource;
import org.apache.camel.component.kubernetes.properties.ConfigMapPropertiesFunction;
-import org.apache.camel.quarkus.k.support.RuntimeSupport;
+import org.apache.camel.util.ObjectHelper;
import org.eclipse.microprofile.config.spi.ConfigSource;
import org.eclipse.microprofile.config.spi.ConfigSourceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ApplicationConfigSourceProvider implements ConfigSourceProvider {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationConfigSourceProvider.class);
@Override
public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) {
@@ -34,12 +51,150 @@ public class ApplicationConfigSourceProvider implements ConfigSourceProvider {
// explicit disable looking up configmap and secret using the KubernetesClient
sysProperties.put(ConfigMapPropertiesFunction.CLIENT_ENABLED, "false");
- final Map<String, String> appProperties = RuntimeSupport.loadApplicationProperties();
- final Map<String, String> usrProperties = RuntimeSupport.loadUserProperties();
+ final Map<String, String> appProperties = loadApplicationProperties();
+
+ // As today the resources directory is part of the conf.d directory, ideally the resources
+ // directory should be moved outside it, so we can walk the conf.d directory without having
+ // to individually load sub-dirs.
+
+ final Map<String, String> usrPropertiesConfigMaps = loadConfigMapUserProperties();
+ final Map<String, String> usrPropertiesSecrets = loadSecretsProperties();
+ final Map<String, String> abBindingProperties = loadServiceBindingsProperties();
return List.of(
- new PropertiesConfigSource(sysProperties, "camel-k-sys", ConfigSource.DEFAULT_ORDINAL + 1000),
- new PropertiesConfigSource(appProperties, "camel-k-app", ConfigSource.DEFAULT_ORDINAL),
- new PropertiesConfigSource(usrProperties, "camel-k-usr", ConfigSource.DEFAULT_ORDINAL + 1));
+ new PropertiesConfigSource(
+ sysProperties,
+ "camel-k-sys",
+ ConfigSource.DEFAULT_ORDINAL + 1100),
+ new PropertiesConfigSource(
+ appProperties,
+ "camel-k-app",
+ ConfigSource.DEFAULT_ORDINAL + 1050),
+ new PropertiesConfigSource(
+ usrPropertiesConfigMaps,
+ "camel-k-usr-configmap",
+ ConfigSource.DEFAULT_ORDINAL + 1010),
+ new PropertiesConfigSource(
+ usrPropertiesSecrets,
+ "camel-k-usr-secrets",
+ ConfigSource.DEFAULT_ORDINAL + 1010),
+ new PropertiesConfigSource(
+ abBindingProperties,
+ "camel-k-servicebindings",
+ ConfigSource.DEFAULT_ORDINAL + 1005));
+ }
+
+ public static Map<String, String> loadApplicationProperties() {
+ final String conf = System.getProperty(ApplicationConstants.PROPERTY_CAMEL_K_CONF,
+ System.getenv(ApplicationConstants.ENV_CAMEL_K_CONF));
+ final Map<String, String> properties = new HashMap<>();
+
+ if (ObjectHelper.isEmpty(conf)) {
+ return properties;
+ }
+
+ try {
+ Path confPath = Paths.get(conf);
+ if (Files.exists(confPath) && !Files.isDirectory(confPath)) {
+ try (Reader reader = Files.newBufferedReader(confPath)) {
+ Properties p = new Properties();
+ p.load(reader);
+ p.forEach((key, value) -> properties.put(String.valueOf(key), String.valueOf(value)));
+ }
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ return properties;
+ }
+
+ public static Map<String, String> loadConfigMapUserProperties() {
+ return loadUserProperties(
+ ApplicationConstants.PROPERTY_CAMEL_K_MOUNT_PATH_CONFIGMAPS,
+ ApplicationConstants.ENV_CAMEL_K_MOUNT_PATH_CONFIGMAPS,
+ ApplicationConstants.PATH_CONFIGMAPS);
+ }
+
+ public static Map<String, String> loadSecretsProperties() {
+ return loadUserProperties(
+ ApplicationConstants.PROPERTY_CAMEL_K_MOUNT_PATH_SECRETS,
+ ApplicationConstants.ENV_CAMEL_K_MOUNT_PATH_SECRETS,
+ ApplicationConstants.PATH_SECRETS);
+ }
+
+ public static Map<String, String> loadServiceBindingsProperties() {
+ return loadUserProperties(
+ ApplicationConstants.PROPERTY_CAMEL_K_MOUNT_PATH_SERVICEBINDINGS,
+ ApplicationConstants.ENV_CAMEL_K_MOUNT_PATH_SERVICEBINDINGS,
+ ApplicationConstants.PATH_SERVICEBINDINGS);
+ }
+
+ public static Map<String, String> loadUserProperties(String property, String env, String subpath) {
+ String path = System.getProperty(property, System.getenv(env));
+
+ if (path == null) {
+ String conf = System.getProperty(
+ ApplicationConstants.PROPERTY_CAMEL_K_CONF_D,
+ System.getenv(ApplicationConstants.ENV_CAMEL_K_CONF_D));
+
+ if (conf != null) {
+ if (!conf.endsWith("/")) {
+ conf = conf + "/";
+ }
+
+ path = conf + subpath;
+ }
+ }
+
+ if (ObjectHelper.isEmpty(path)) {
+ return Map.of();
+ }
+
+ final Map<String, String> properties = new HashMap<>();
+ final Path root = Paths.get(path);
+
+ if (Files.exists(root)) {
+ FileVisitor<Path> visitor = propertiesCollector(properties);
+ try {
+ Files.walkFileTree(root, visitor);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return Collections.unmodifiableMap(properties);
+ }
+
+ private static FileVisitor<Path> propertiesCollector(Map<String, String> properties) {
+ return new SimpleFileVisitor<>() {
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ Objects.requireNonNull(file);
+ Objects.requireNonNull(attrs);
+
+ if (Files.isDirectory(file) || Files.isSymbolicLink(file)) {
+ return FileVisitResult.CONTINUE;
+ }
+
+ if (file.toFile().getAbsolutePath().endsWith(".properties")) {
+ try (Reader reader = Files.newBufferedReader(file)) {
+ Properties p = new Properties();
+ p.load(reader);
+ p.forEach((key, value) -> properties.put(String.valueOf(key), String.valueOf(value)));
+ }
+ } else {
+ try {
+ properties.put(
+ file.getFileName().toString(),
+ Files.readString(file, StandardCharsets.UTF_8));
+ } catch (MalformedInputException mie) {
+ // Just skip if it is not a UTF-8 encoded file (ie a binary)
+ LOGGER.info("Cannot transform {} into UTF-8 text, skipping.", file);
+ }
+ }
+ return FileVisitResult.CONTINUE;
+ }
+ };
}
}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationConstants.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationConstants.java
new file mode 100644
index 0000000000..5130343ffd
--- /dev/null
+++ b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationConstants.java
@@ -0,0 +1,40 @@
+/*
+ * 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.quarkus.k.runtime;
+
+public final class ApplicationConstants {
+ public static final String ENV_CAMEL_K_CONF = "CAMEL_K_CONF";
+ public static final String PROPERTY_CAMEL_K_CONF = "camel.k.conf";
+
+ public static final String ENV_CAMEL_K_CONF_D = "CAMEL_K_CONF_D";
+ public static final String PROPERTY_CAMEL_K_CONF_D = "camel.k.conf.d";
+
+ public static final String ENV_CAMEL_K_MOUNT_PATH_CONFIGMAPS = "CAMEL_K_MOUNT_PATH_CONFIGMAPS";
+ public static final String PROPERTY_CAMEL_K_MOUNT_PATH_CONFIGMAPS = "camel.k.mount-path.configmaps";
+ public static final String PATH_CONFIGMAPS = "_configmaps";
+
+ public static final String ENV_CAMEL_K_MOUNT_PATH_SECRETS = "CAMEL_K_MOUNT_PATH_SECRETS";
+ public static final String PROPERTY_CAMEL_K_MOUNT_PATH_SECRETS = "camel.k.mount-path.secrets";
+ public static final String PATH_SECRETS = "_secrets";
+
+ public static final String ENV_CAMEL_K_MOUNT_PATH_SERVICEBINDINGS = "CAMEL_K_MOUNT_PATH_SERVICEBINDINGS";
+ public static final String PROPERTY_CAMEL_K_MOUNT_PATH_SERVICEBINDINGS = "camel.k.mount-path.servicebindings";
+ public static final String PATH_SERVICEBINDINGS = "_servicebindings";
+
+ private ApplicationConstants() {
+ }
+}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRecorder.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRecorder.java
index a70088ca2b..cdeddce5d4 100644
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRecorder.java
+++ b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRecorder.java
@@ -16,38 +16,18 @@
*/
package org.apache.camel.quarkus.k.runtime;
-import java.util.List;
-
-import io.quarkus.arc.runtime.BeanContainer;
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.annotations.Recorder;
-import org.apache.camel.main.MainListener;
-import org.apache.camel.main.RoutesCollector;
-import org.apache.camel.quarkus.k.core.Runtime;
-import org.apache.camel.quarkus.main.CamelMain;
+import org.apache.camel.spi.CamelContextCustomizer;
import org.apache.camel.spi.ModelReifierFactory;
-import org.slf4j.LoggerFactory;
@Recorder
public class ApplicationRecorder {
-
- public void version(String version) {
- LoggerFactory.getLogger(Runtime.class).info("Apache Camel K Runtime {}", version);
- }
-
- public RuntimeValue<MainListener> createMainListener(List<Runtime.Listener> listeners) {
- return new RuntimeValue<>(new Application.ListenerAdapter(listeners));
- }
-
- public void publishRuntime(RuntimeValue<CamelMain> main, BeanContainer container) {
- container.beanInstance(ApplicationProducers.class).setRuntime(new Application.Runtime(main.getValue()));
- }
-
- public RuntimeValue<RoutesCollector> createRoutesCollector() {
- return new RuntimeValue<>(new Application.NoRoutesCollector());
- }
-
public RuntimeValue<ModelReifierFactory> modelReifierFactory() {
return new RuntimeValue<>(new ApplicationModelReifierFactory());
}
+
+ public RuntimeValue<CamelContextCustomizer> shutdownCustomizer(ApplicationShutdownConfig config) {
+ return new RuntimeValue<>(new ApplicationShutdownCustomizer(config));
+ }
}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutes.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutes.java
index c7ad29ac1a..0ef37bc1d9 100644
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutes.java
+++ b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutes.java
@@ -18,9 +18,9 @@ package org.apache.camel.quarkus.k.runtime;
import java.util.Objects;
+import io.quarkus.arc.Unremovable;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
-import org.apache.camel.CamelContext;
import org.apache.camel.model.FromDefinition;
import org.apache.camel.model.RouteDefinition;
import org.slf4j.Logger;
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
/**
* A bean to hold routes related logic.
*/
+@Unremovable
@ApplicationScoped
public class ApplicationRoutes {
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationRoutes.class);
@@ -36,13 +37,6 @@ public class ApplicationRoutes {
@Inject
ApplicationRoutesConfig config;
- @Inject
- CamelContext context;
-
- public ApplicationRoutesConfig config() {
- return this.config;
- }
-
public void override(RouteDefinition definition) {
if (config.overrides().isEmpty()) {
return;
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutesConfig.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutesConfig.java
index 0169fc12f9..9ccff9bbad 100644
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutesConfig.java
+++ b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationRoutesConfig.java
@@ -19,9 +19,12 @@ package org.apache.camel.quarkus.k.runtime;
import java.util.List;
import java.util.Optional;
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
@ConfigMapping(prefix = "camel.k.routes")
+@ConfigRoot(phase = ConfigPhase.RUN_TIME)
public interface ApplicationRoutesConfig {
/**
* A list of {@link RouteOverride} items to override some aspect of a {@link org.apache.camel.model.RouteDefinition}.
@@ -35,7 +38,8 @@ public interface ApplicationRoutesConfig {
Optional<String> id();
/**
- * Override for the {@link org.apache.camel.model.FromDefinition} of a {@link org.apache.camel.model.RouteDefinition}.
+ * Override for the {@link org.apache.camel.model.FromDefinition} of a
+ * {@link org.apache.camel.model.RouteDefinition}.
*/
RouteInputOverride input();
}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationProducers.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationShutdownConfig.java
similarity index 59%
rename from extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationProducers.java
rename to extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationShutdownConfig.java
index 9e0509d550..3db39b7c38 100644
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationProducers.java
+++ b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationShutdownConfig.java
@@ -16,24 +16,18 @@
*/
package org.apache.camel.quarkus.k.runtime;
-import io.quarkus.arc.Unremovable;
-import jakarta.enterprise.context.ApplicationScoped;
-import jakarta.enterprise.inject.Produces;
-import jakarta.inject.Singleton;
-import org.apache.camel.quarkus.k.core.Runtime;
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
+import io.smallrye.config.ConfigMapping;
+import io.smallrye.config.WithDefault;
-@ApplicationScoped
-public class ApplicationProducers {
- private volatile Runtime runtime;
-
- public void setRuntime(Runtime runtime) {
- this.runtime = runtime;
- }
-
- @Unremovable
- @Singleton
- @Produces
- Runtime runtime() {
- return this.runtime;
- }
+@ConfigMapping(prefix = "camel.k.shutdown")
+@ConfigRoot(phase = ConfigPhase.RUN_TIME)
+public interface ApplicationShutdownConfig {
+ /**
+ * To specify how many messages to process by Camel before automatic terminating the JVM. If there are inflight
+ * messages, the shutdown is delayed till all the exchanges have been completed.
+ */
+ @WithDefault("0")
+ int maxMessages();
}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationShutdownCustomizer.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationShutdownCustomizer.java
new file mode 100644
index 0000000000..4b6058ff54
--- /dev/null
+++ b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/runtime/ApplicationShutdownCustomizer.java
@@ -0,0 +1,91 @@
+/*
+ * 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.quarkus.k.runtime;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import io.quarkus.runtime.Quarkus;
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.CamelContextCustomizer;
+import org.apache.camel.spi.CamelEvent;
+import org.apache.camel.support.EventNotifierSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ApplicationShutdownCustomizer implements CamelContextCustomizer {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationShutdownCustomizer.class);
+
+ private final ApplicationShutdownConfig config;
+
+ public ApplicationShutdownCustomizer(ApplicationShutdownConfig config) {
+ this.config = config;
+ }
+
+ @Override
+ public void configure(CamelContext camelContext) {
+ if (this.config.maxMessages() > 0) {
+ LOGGER.info("Configure the JVM to terminate after {} messages and none inflight", this.config.maxMessages());
+ camelContext.getManagementStrategy().addEventNotifier(new ShutdownEventHandler(camelContext, config));
+ }
+ }
+
+ private static final class ShutdownEventHandler extends EventNotifierSupport {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ShutdownEventHandler.class);
+
+ private final CamelContext context;
+ private final ApplicationShutdownConfig config;
+ private final AtomicInteger counter;
+ private final AtomicBoolean shutdownStarted;
+
+ ShutdownEventHandler(CamelContext context, ApplicationShutdownConfig config) {
+ this.context = context;
+ this.config = config;
+ this.counter = new AtomicInteger();
+ this.shutdownStarted = new AtomicBoolean();
+
+ }
+
+ @Override
+ public void notify(CamelEvent event) throws Exception {
+ final int currentCounter = this.counter.incrementAndGet();
+ final int currentInflight = context.getInflightRepository().size();
+
+ LOGGER.debug("CamelEvent received (max: {}, handled: {}, inflight: {})",
+ this.config.maxMessages(),
+ currentCounter,
+ currentInflight);
+
+ if (currentCounter < this.config.maxMessages() || currentInflight != 0) {
+ return;
+ }
+
+ if (!this.shutdownStarted.compareAndExchange(false, true)) {
+ LOGGER.info("Initiate runtime shutdown (max: {}, handled: {})",
+ this.config.maxMessages(),
+ currentCounter);
+
+ Quarkus.asyncExit();
+ }
+ }
+
+ @Override
+ public boolean isEnabled(CamelEvent event) {
+ return (event instanceof CamelEvent.ExchangeCompletedEvent || event instanceof CamelEvent.ExchangeFailedEvent);
+ }
+ }
+}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/Constants.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/Constants.java
deleted file mode 100644
index 3979ba7af6..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/Constants.java
+++ /dev/null
@@ -1,63 +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.quarkus.k.support;
-
-public final class Constants {
- public static final String ENV_CAMEL_K_ROUTES = "CAMEL_K_ROUTES";
- public static final String PROPERTY_CAMEL_K_ROUTES = "camel.k.routes";
-
- public static final String ENV_CAMEL_K_CONF = "CAMEL_K_CONF";
- public static final String PROPERTY_CAMEL_K_CONF = "camel.k.conf";
-
- public static final String ENV_CAMEL_K_CONF_D = "CAMEL_K_CONF_D";
- public static final String PROPERTY_CAMEL_K_CONF_D = "camel.k.conf.d";
-
- public static final String ENV_CAMEL_K_CUSTOMIZERS = "CAMEL_K_CUSTOMIZERS";
- public static final String PROPERTY_CAMEL_K_CUSTOMIZER = "camel.k.customizer";
-
- public static final String ENV_CAMEL_K_MOUNT_PATH_CONFIGMAPS = "CAMEL_K_MOUNT_PATH_CONFIGMAPS";
- public static final String PROPERTY_CAMEL_K_MOUNT_PATH_CONFIGMAPS = "camel.k.mount-path.configmaps";
-
- public static final String ENV_CAMEL_K_MOUNT_PATH_SECRETS = "CAMEL_K_MOUNT_PATH_SECRETS";
- public static final String PROPERTY_CAMEL_K_MOUNT_PATH_SECRETS = "camel.k.mount-path.secrets";
-
- public static final String SCHEME_REF = "ref";
- public static final String SCHEME_PREFIX_REF = SCHEME_REF + ":";
- public static final String SCHEME_CLASS = "class";
- public static final String SCHEME_PREFIX_CLASS = SCHEME_CLASS + ":";
- public static final String SCHEME_CLASSPATH = "classpath";
- public static final String SCHEME_PREFIX_CLASSPATH = SCHEME_CLASSPATH + ":";
- public static final String SCHEME_FILE = "file";
- public static final String SCHEME_PREFIX_FILE = SCHEME_FILE + ":";
-
- public static final String LOGGING_LEVEL_PREFIX = "logging.level.";
- public static final String SOURCE_LOADER_INTERCEPTOR_RESOURCE_PATH = "META-INF/services/org.apache.camel.quarkus.k/loader/interceptor/";
- public static final String CONTEXT_CUSTOMIZER_RESOURCE_PATH = "META-INF/services/org.apache.camel.quarkus.k/customizer/";
-
- public static final String ENABLE_CUSTOMIZER_PATTERN = "(camel\\.k\\.)?customizer\\.([\\w][\\w-]*)\\.enabled";
-
- public static final String PROPERTY_PREFIX_REST_COMPONENT_PROPERTY = "camel.rest.componentProperty.";
- public static final String PROPERTY_PREFIX_REST_ENDPOINT_PROPERTY = "camel.rest.endpointProperty.";
-
- public static final String CUSTOMIZER_PREFIX = "camel.k.customizer.";
- public static final String CUSTOMIZER_PREFIX_FALLBACK = "customizer.";
- public static final String LOADER_INTERCEPTOR_PREFIX = "camel.k.loader.interceptor.";
- public static final String LOADER_INTERCEPTOR_PREFIX_FALLBACK = "loader.interceptor.";
-
- private Constants() {
- }
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/DelegatingRuntime.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/DelegatingRuntime.java
deleted file mode 100644
index 2cc6221758..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/DelegatingRuntime.java
+++ /dev/null
@@ -1,80 +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.quarkus.k.support;
-
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ExtendedCamelContext;
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.quarkus.k.core.Runtime;
-import org.apache.camel.spi.Registry;
-
-public class DelegatingRuntime implements Runtime {
-
- private final Runtime runtime;
-
- public DelegatingRuntime(Runtime runtime) {
- this.runtime = runtime;
- }
-
- @Override
- public ExtendedCamelContext getExtendedCamelContext() {
- return runtime.getExtendedCamelContext();
- }
-
- @Override
- public Registry getRegistry() {
- return runtime.getRegistry();
- }
-
- @Override
- public void setProperties(Properties properties) {
- runtime.setProperties(properties);
- }
-
- @Override
- public void setProperties(Map<String, String> properties) {
- runtime.setProperties(properties);
- }
-
- @Override
- public void setProperties(String key, String value, String... keyVals) {
- runtime.setProperties(key, value, keyVals);
- }
-
- @Override
- public void addRoutes(RoutesBuilder builder) {
- runtime.addRoutes(builder);
- }
-
- @Override
- public void stop() throws Exception {
- runtime.stop();
- }
-
- @Override
- public void close() throws Exception {
- runtime.close();
- }
-
- @Override
- public CamelContext getCamelContext() {
- return runtime.getCamelContext();
- }
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/PropertiesSupport.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/PropertiesSupport.java
deleted file mode 100644
index 61cda7d5d2..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/PropertiesSupport.java
+++ /dev/null
@@ -1,93 +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.quarkus.k.support;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.function.Predicate;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Component;
-import org.apache.camel.ExtendedCamelContext;
-import org.apache.camel.spi.PropertiesComponent;
-import org.apache.camel.spi.PropertyConfigurer;
-import org.apache.camel.support.PluginHelper;
-import org.apache.camel.support.PropertyBindingSupport;
-import org.apache.camel.support.service.ServiceHelper;
-
-public final class PropertiesSupport {
-
- private PropertiesSupport() {
- }
-
- public static <T> T bindProperties(CamelContext context, T target, String prefix) {
- return bindProperties(context, target, prefix, false);
- }
-
- public static <T> T bindProperties(CamelContext context, T target, String prefix, boolean stripPrefix) {
- return bindProperties(context, target, k -> k.startsWith(prefix), prefix, stripPrefix);
- }
-
- public static <T> T bindProperties(CamelContext context, T target, Predicate<String> filter, String prefix) {
- return bindProperties(context, target, filter, prefix, false);
- }
-
- public static <T> T bindProperties(CamelContext context, T target, Predicate<String> filter, String prefix,
- boolean stripPrefix) {
- final PropertiesComponent component = context.getPropertiesComponent();
- final Properties propertiesWithPrefix = component.loadProperties(filter);
- final Map<String, Object> properties = new HashMap<>();
-
- propertiesWithPrefix.stringPropertyNames().forEach(
- name -> properties.put(
- stripPrefix ? name.substring(prefix.length()) : name,
- propertiesWithPrefix.getProperty(name)));
-
- PropertyConfigurer configurer = null;
- if (target instanceof Component) {
- // the component needs to be initialized to have the configurer ready
- ServiceHelper.initService(target);
- configurer = ((Component) target).getComponentPropertyConfigurer();
- }
-
- if (configurer == null) {
- String name = target.getClass().getName();
- if (target instanceof ExtendedCamelContext) {
- // special for camel context itself as we have an extended configurer
- name = ExtendedCamelContext.class.getName();
- }
-
- // see if there is a configurer for it
- configurer = PluginHelper.getConfigurerResolver(context.getCamelContextExtension()).resolvePropertyConfigurer(name,
- context);
- }
-
- PropertyBindingSupport.build()
- .withIgnoreCase(true)
- .withCamelContext(context)
- .withTarget(target)
- .withProperties(properties)
- .withRemoveParameters(true)
- .withOptionPrefix(stripPrefix ? null : prefix)
- .withConfigurer(configurer)
- .bind();
-
- return target;
- }
-
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/RouteBuilders.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/RouteBuilders.java
deleted file mode 100644
index e889f68bcd..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/RouteBuilders.java
+++ /dev/null
@@ -1,73 +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.quarkus.k.support;
-
-import java.io.Reader;
-
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.endpoint.EndpointRouteBuilder;
-import org.apache.camel.quarkus.k.core.Source;
-import org.apache.camel.util.function.ThrowingBiConsumer;
-import org.apache.camel.util.function.ThrowingConsumer;
-
-public final class RouteBuilders {
-
- private RouteBuilders() {
- }
-
- public static EndpointRouteBuilder endpoint(Source source,
- ThrowingBiConsumer<Reader, EndpointRouteBuilder, Exception> consumer) {
- return new EndpointRouteBuilder() {
- @Override
- public void configure() throws Exception {
- try (Reader reader = source.resolveAsReader(getContext())) {
- consumer.accept(reader, this);
- }
- }
- };
- }
-
- public static EndpointRouteBuilder endpoint(ThrowingConsumer<EndpointRouteBuilder, Exception> consumer) {
- return new EndpointRouteBuilder() {
- @Override
- public void configure() throws Exception {
- consumer.accept(this);
- }
- };
- }
-
- public static RoutesBuilder route(Source source, ThrowingBiConsumer<Reader, RouteBuilder, Exception> consumer) {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- try (Reader reader = source.resolveAsReader(getContext())) {
- consumer.accept(reader, this);
- }
- }
- };
- }
-
- public static RoutesBuilder route(ThrowingConsumer<RouteBuilder, Exception> consumer) {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- consumer.accept(this);
- }
- };
- }
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/RuntimeSupport.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/RuntimeSupport.java
deleted file mode 100644
index 51a3caabb5..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/RuntimeSupport.java
+++ /dev/null
@@ -1,341 +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.quarkus.k.support;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.nio.charset.MalformedInputException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.FileVisitResult;
-import java.nio.file.FileVisitor;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ExtendedCamelContext;
-import org.apache.camel.builder.RouteBuilderLifecycleStrategy;
-import org.apache.camel.quarkus.k.core.Source;
-import org.apache.camel.spi.CamelContextCustomizer;
-import org.apache.camel.spi.HasCamelContext;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class RuntimeSupport {
- private static final Logger LOGGER = LoggerFactory.getLogger(RuntimeSupport.class);
-
- private RuntimeSupport() {
- }
-
- // *********************************
- //
- // Helpers - Customizers
- //
- // *********************************
-
- public static List<CamelContextCustomizer> configureContextCustomizers(HasCamelContext hasCamelContext) {
- return configureContextCustomizers(hasCamelContext.getCamelContext());
- }
-
- public static List<CamelContextCustomizer> configureContextCustomizers(CamelContext context) {
- List<CamelContextCustomizer> appliedCustomizers = new ArrayList<>();
- Map<String, CamelContextCustomizer> customizers = lookupCustomizers(context);
-
- customizers.entrySet().stream()
- .sorted(Map.Entry.comparingByValue())
- .forEach(e -> {
- LOGGER.debug("Apply ContextCustomizer with id={} and type={}", e.getKey(),
- e.getValue().getClass().getName());
-
- PropertiesSupport.bindProperties(context, e.getValue(), Constants.CUSTOMIZER_PREFIX + e.getKey() + ".");
- PropertiesSupport.bindProperties(context, e.getValue(),
- Constants.CUSTOMIZER_PREFIX_FALLBACK + e.getKey() + ".");
-
- e.getValue().configure(context);
-
- appliedCustomizers.add(e.getValue());
- });
-
- return appliedCustomizers;
- }
-
- public static Map<String, CamelContextCustomizer> lookupCustomizers(CamelContext context) {
- Map<String, CamelContextCustomizer> customizers = new ConcurrentHashMap<>();
- Properties properties = context.getPropertiesComponent().loadProperties(
- n -> n.startsWith(Constants.CUSTOMIZER_PREFIX) || n.startsWith(Constants.CUSTOMIZER_PREFIX_FALLBACK));
-
- if (properties != null) {
- //
- // Lookup customizers listed in Constants.ENV_CAMEL_K_CUSTOMIZERS or Constants.PROPERTY_CAMEL_K_CUSTOMIZER
- // for backward compatibility
- //
- for (String customizerId : lookupCustomizerIDs(context)) {
- customizers.computeIfAbsent(customizerId, id -> lookupCustomizerByID(context, id));
- }
-
- Pattern pattern = Pattern.compile(Constants.ENABLE_CUSTOMIZER_PATTERN);
-
- properties.entrySet().stream()
- .filter(entry -> entry.getKey() instanceof String)
- .filter(entry -> entry.getValue() != null)
- .forEach(entry -> {
- final String key = (String) entry.getKey();
- final Object val = entry.getValue();
- final Matcher matcher = pattern.matcher(key);
-
- if (matcher.matches()) {
- String customizerId = null;
-
- if (matcher.groupCount() == 1) {
- customizerId = matcher.group(1);
- } else if (matcher.groupCount() == 2) {
- customizerId = matcher.group(2);
- }
-
- if (customizerId != null && Boolean.parseBoolean(String.valueOf(val))) {
- //
- // Do not override customizers eventually found
- // in the registry
- //
- customizers.computeIfAbsent(customizerId, id -> lookupCustomizerByID(context, id));
- }
- }
- });
- }
-
- return customizers;
- }
-
- public static CamelContextCustomizer lookupCustomizerByID(CamelContext context, String customizerId) {
- CamelContextCustomizer customizer = context.getRegistry().lookupByNameAndType(customizerId,
- CamelContextCustomizer.class);
- if (customizer == null) {
- customizer = context.getCamelContextExtension()
- .getFactoryFinder(Constants.CONTEXT_CUSTOMIZER_RESOURCE_PATH)
- .newInstance(customizerId, CamelContextCustomizer.class)
- .orElseThrow(() -> new RuntimeException("Error creating instance for customizer: " + customizerId));
-
- LOGGER.debug("Found customizer {} with id {} from service definition", customizer, customizerId);
- } else {
- LOGGER.debug("Found customizer {} with id {} from the registry", customizer, customizerId);
- }
-
- return customizer;
- }
-
- public static Set<String> lookupCustomizerIDs(CamelContext context) {
- Set<String> customizers = new TreeSet<>();
- String customizerIDs = System.getenv().getOrDefault(Constants.ENV_CAMEL_K_CUSTOMIZERS, "");
- if (ObjectHelper.isEmpty(customizerIDs)) {
- // TODO: getPropertiesComponent().resolveProperty() throws exception instead
- // of returning abd empty optional
- customizerIDs = context.getPropertiesComponent()
- .loadProperties(Constants.PROPERTY_CAMEL_K_CUSTOMIZER::equals)
- .getProperty(Constants.PROPERTY_CAMEL_K_CUSTOMIZER, "");
- }
-
- if (ObjectHelper.isNotEmpty(customizerIDs)) {
- for (String customizerId : customizerIDs.split(",", -1)) {
- customizers.add(customizerId);
- }
- }
- return customizers;
- }
-
- // *********************************
- //
- // Helpers - Interceptors
- //
- // *********************************
-
- public static List<RouteBuilderLifecycleStrategy> loadInterceptors(CamelContext context, Source source) {
- ExtendedCamelContext ecc = context.getCamelContextExtension();
- List<RouteBuilderLifecycleStrategy> answer = new ArrayList<>();
-
- for (String id : source.getInterceptors()) {
- try {
- // first check the registry
- RouteBuilderLifecycleStrategy interceptor = ecc.getRegistry()
- .lookupByNameAndType(id, RouteBuilderLifecycleStrategy.class);
-
- if (interceptor == null) {
- // then try with factory finder
- interceptor = ecc.getFactoryFinder(Constants.SOURCE_LOADER_INTERCEPTOR_RESOURCE_PATH)
- .newInstance(id, RouteBuilderLifecycleStrategy.class)
- .orElseThrow(
- () -> new IllegalArgumentException("Unable to find source loader interceptor for: " + id));
-
- LOGGER.debug("Found source loader interceptor {} from service definition", id);
- } else {
- LOGGER.debug("Found source loader interceptor {} from registry", id);
- }
-
- PropertiesSupport.bindProperties(context, interceptor, Constants.LOADER_INTERCEPTOR_PREFIX + id + ".");
- PropertiesSupport.bindProperties(context, interceptor, Constants.LOADER_INTERCEPTOR_PREFIX_FALLBACK + id + ".");
-
- answer.add(interceptor);
- } catch (Exception e) {
- throw new IllegalArgumentException("Unable to find source loader interceptor for: " + id, e);
- }
- }
-
- return answer;
- }
-
- // *********************************
- //
- // Helpers - Misc
- //
- // *********************************
-
- public static String getRuntimeVersion() {
- String version = null;
-
- InputStream is = null;
- // try to load from maven properties first
- try {
- Properties p = new Properties();
- is = RuntimeSupport.class.getResourceAsStream(
- "/META-INF/maven/org.apache.camel.quarkus/camel-quarkus-k-core-api/pom.properties");
- if (is != null) {
- p.load(is);
- version = p.getProperty("version", "");
- }
- } catch (Exception e) {
- // ignore
- } finally {
- if (is != null) {
- IOHelper.close(is);
- }
- }
-
- // fallback to using Java API
- if (version == null) {
- Package aPackage = RuntimeSupport.class.getPackage();
- if (aPackage != null) {
- version = aPackage.getImplementationVersion();
- if (version == null) {
- version = aPackage.getSpecificationVersion();
- }
- }
- }
-
- if (version == null) {
- // we could not compute the version so use a blank
- version = "";
- }
-
- return Objects.requireNonNull(version, "Could not determine Camel K Runtime version");
- }
-
- // *********************************
- //
- // Properties
- //
- // *********************************
-
- public static Map<String, String> loadApplicationProperties() {
- final String conf = System.getProperty(Constants.PROPERTY_CAMEL_K_CONF, System.getenv(Constants.ENV_CAMEL_K_CONF));
- final Map<String, String> properties = new HashMap<>();
-
- if (ObjectHelper.isEmpty(conf)) {
- return properties;
- }
-
- try {
- Path confPath = Paths.get(conf);
- if (Files.exists(confPath) && !Files.isDirectory(confPath)) {
- try (Reader reader = Files.newBufferedReader(confPath)) {
- Properties p = new Properties();
- p.load(reader);
- p.forEach((key, value) -> properties.put(String.valueOf(key), String.valueOf(value)));
- }
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- return properties;
- }
-
- public static Map<String, String> loadUserProperties() {
- final String conf = System.getProperty(Constants.PROPERTY_CAMEL_K_CONF_D, System.getenv(Constants.ENV_CAMEL_K_CONF_D));
- final Map<String, String> properties = new HashMap<>();
-
- if (ObjectHelper.isEmpty(conf)) {
- return properties;
- }
-
- FileVisitor<Path> visitor = new SimpleFileVisitor<>() {
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
- Objects.requireNonNull(file);
- Objects.requireNonNull(attrs);
-
- if (Files.isDirectory(file) || Files.isSymbolicLink(file)) {
- return FileVisitResult.CONTINUE;
- }
-
- if (file.toFile().getAbsolutePath().endsWith(".properties")) {
- try (Reader reader = Files.newBufferedReader(file)) {
- Properties p = new Properties();
- p.load(reader);
- p.forEach((key, value) -> properties.put(String.valueOf(key), String.valueOf(value)));
- }
- } else {
- try {
- properties.put(
- file.getFileName().toString(),
- Files.readString(file, StandardCharsets.UTF_8));
- } catch (MalformedInputException mie) {
- // Just skip if it is not a UTF-8 encoded file (ie a binary)
- LOGGER.info("Cannot transform {} into UTF-8 text, skipping.", file);
- }
- }
- return FileVisitResult.CONTINUE;
- }
- };
-
- Path root = Paths.get(conf);
-
- if (Files.exists(root)) {
- try {
- Files.walkFileTree(root, visitor);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- return properties;
- }
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/Sources.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/Sources.java
deleted file mode 100644
index faf3a6b7e0..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/Sources.java
+++ /dev/null
@@ -1,243 +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.quarkus.k.support;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.nio.charset.Charset;
-import java.util.Base64;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.zip.GZIPInputStream;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.quarkus.k.core.Source;
-import org.apache.camel.quarkus.k.core.SourceDefinition;
-import org.apache.camel.quarkus.k.core.SourceType;
-import org.apache.camel.spi.Resource;
-import org.apache.camel.support.ResourceHelper;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.URISupport;
-
-public final class Sources {
-
- private Sources() {
- }
-
- public static Source fromURI(String uri) throws Exception {
- return fromDefinition(computeDefinitionFromURI(uri));
- }
-
- public static SourceDefinition fromBytes(String id, String name, String language, String loader, List<String> interceptors,
- byte[] content) {
- SourceDefinition answer = new SourceDefinition();
- answer.setId(id);
- answer.setName(name);
- answer.setLanguage(language);
- answer.setLoader(loader);
- answer.setInterceptors(interceptors != null ? interceptors : Collections.emptyList());
- answer.setContent(content);
-
- return answer;
- }
-
- public static Source fromBytes(String name, String language, String loader, List<String> interceptors, byte[] content) {
- return fromDefinition(fromBytes(null, name, language, loader, interceptors, content));
- }
-
- public static Source fromBytes(String name, String language, String loader, byte[] content) {
- return fromDefinition(fromBytes(null, name, language, loader, null, content));
- }
-
- public static Source fromBytes(String language, byte[] content) {
- return fromDefinition(fromBytes(null, UUID.randomUUID().toString(), language, null, null, content));
- }
-
- public static Source fromDefinition(SourceDefinition definition) {
- if (definition.getLocation() == null && definition.getContent() == null) {
- throw new IllegalArgumentException("Either the source location or the source content should be set");
- }
- return new Source() {
- @Override
- public String getLocation() {
- return definition.getLocation();
- }
-
- @Override
- public String getId() {
- return ObjectHelper.supplyIfEmpty(definition.getId(), this::getName);
- }
-
- @Override
- public String getName() {
- String answer = definition.getName();
- if (ObjectHelper.isEmpty(answer) && ObjectHelper.isNotEmpty(definition.getLocation())) {
- answer = StringSupport.substringAfter(definition.getLocation(), ":");
- answer = StringSupport.substringBeforeLast(answer, ".");
-
- if (answer.contains("/")) {
- answer = StringSupport.substringAfterLast(answer, "/");
- }
- }
-
- return answer;
- }
-
- @Override
- public String getLanguage() {
- String answer = definition.getLanguage();
- if (ObjectHelper.isEmpty(answer) && ObjectHelper.isNotEmpty(definition.getLocation())) {
- answer = StringSupport.substringAfterLast(definition.getLocation(), ":");
- answer = StringSupport.substringAfterLast(answer, ".");
- }
-
- return answer;
- }
-
- @Override
- public SourceType getType() {
- return ObjectHelper.supplyIfEmpty(definition.getType(), () -> SourceType.source);
- }
-
- @Override
- public Optional<String> getLoader() {
- return Optional.ofNullable(definition.getLoader());
- }
-
- @Override
- public List<String> getInterceptors() {
- return ObjectHelper.supplyIfEmpty(definition.getInterceptors(), Collections::emptyList);
- }
-
- @Override
- public List<String> getPropertyNames() {
- return ObjectHelper.supplyIfEmpty(definition.getPropertyNames(), Collections::emptyList);
- }
-
- /**
- * Read the content of the source as {@link InputStream}.
- *
- * @param ctx the {@link CamelContext}
- * @return the {@link InputStream} representing the source content
- */
- @Override
- public InputStream resolveAsInputStream(CamelContext ctx) {
- try {
- InputStream is;
-
- if (definition.getContent() != null) {
- is = new ByteArrayInputStream(definition.getContent());
- } else {
- is = ResourceHelper.resolveMandatoryResourceAsInputStream(ctx, definition.getLocation());
- }
-
- return definition.isCompressed()
- ? new GZIPInputStream(Base64.getDecoder().wrap(is))
- : is;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- };
- }
-
- // ******************************
- //
- // Helpers
- //
- // ******************************
-
- public static Resource asResource(CamelContext camelContext, Source source) {
- return new Resource() {
- @Override
- public String getLocation() {
- return source.getLocation();
- }
-
- @Override
- public boolean exists() {
- return true;
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- return source.resolveAsInputStream(camelContext);
- }
-
- @Override
- public Reader getReader() throws Exception {
- return source.resolveAsReader(camelContext);
- }
-
- @Override
- public Reader getReader(Charset charset) throws Exception {
- return source.resolveAsReader(camelContext, charset);
- }
-
- @Override
- public String getScheme() {
- return source.getLocation();
- }
- };
- }
-
- public static SourceDefinition computeDefinitionFromURI(String uri) throws Exception {
- final String location = StringSupport.substringBefore(uri, "?");
-
- if (!location.startsWith(Constants.SCHEME_PREFIX_CLASSPATH) && !location.startsWith(Constants.SCHEME_PREFIX_FILE)) {
- throw new IllegalArgumentException("No valid resource format, expected scheme:path, found " + uri);
- }
-
- final String query = StringSupport.substringAfter(uri, "?");
- final Map<String, Object> params = URISupport.parseQuery(query);
-
- String language = (String) params.get("language");
- if (ObjectHelper.isEmpty(language)) {
- language = StringSupport.substringAfterLast(location, ":");
- language = StringSupport.substringAfterLast(language, ".");
- }
- if (ObjectHelper.isEmpty(language)) {
- throw new IllegalArgumentException("Unknown language " + language);
- }
-
- String name = (String) params.get("name");
- if (name == null) {
- name = StringSupport.substringAfter(location, ":");
- name = StringSupport.substringBeforeLast(name, ".");
-
- if (name.contains("/")) {
- name = StringSupport.substringAfterLast(name, "/");
- }
- }
-
- SourceDefinition answer = new SourceDefinition();
- answer.setId((String) params.get("id"));
- answer.setLocation(location);
- answer.setName(name);
- answer.setLanguage(language);
- answer.setLoader((String) params.get("loader"));
- answer.setInterceptors(StringSupport.split((String) params.get("interceptors"), ","));
- answer.setCompressed(Boolean.parseBoolean((String) params.get("compression")));
-
- return answer;
- }
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/SourcesSupport.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/SourcesSupport.java
deleted file mode 100644
index d88e115e1d..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/SourcesSupport.java
+++ /dev/null
@@ -1,187 +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.quarkus.k.support;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.camel.ExtendedCamelContext;
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.RouteBuilderLifecycleStrategy;
-import org.apache.camel.model.RouteDefinition;
-import org.apache.camel.model.RouteTemplateDefinition;
-import org.apache.camel.quarkus.k.core.Runtime;
-import org.apache.camel.quarkus.k.core.RuntimeAware;
-import org.apache.camel.quarkus.k.core.Source;
-import org.apache.camel.quarkus.k.core.SourceDefinition;
-import org.apache.camel.quarkus.k.listener.AbstractPhaseListener;
-import org.apache.camel.spi.Resource;
-import org.apache.camel.support.PluginHelper;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class SourcesSupport {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(SourcesSupport.class);
-
- private SourcesSupport() {
- }
-
- public static Runtime.Listener forRoutes(String... sources) {
- return new AbstractPhaseListener(Runtime.Phase.ConfigureRoutes) {
- @Override
- protected void accept(Runtime runtime) {
- loadSources(runtime, sources);
- }
- };
- }
-
- public static Runtime.Listener forRoutes(SourceDefinition... definitions) {
- return new AbstractPhaseListener(Runtime.Phase.ConfigureRoutes) {
- @Override
- protected void accept(Runtime runtime) {
- loadSources(runtime, definitions);
- }
- };
- }
-
- public static void loadSources(Runtime runtime, String... routes) {
- for (String route : routes) {
- if (ObjectHelper.isEmpty(route)) {
- continue;
- }
-
- LOGGER.info("Loading routes from: {}", route);
-
- try {
- load(runtime, Sources.fromURI(route));
- } catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
- }
- }
- }
-
- public static void loadSources(Runtime runtime, SourceDefinition... definitions) {
- for (SourceDefinition definition : definitions) {
- LOGGER.info("Loading routes from: {}", definition);
-
- load(runtime, Sources.fromDefinition(definition));
- }
- }
-
- public static void load(Runtime runtime, Source source) {
- final List<RouteBuilderLifecycleStrategy> interceptors;
-
- switch (source.getType()) {
- case source:
- interceptors = RuntimeSupport.loadInterceptors(runtime.getCamelContext(), source);
- interceptors.forEach(interceptor -> {
- if (interceptor instanceof RuntimeAware) {
- ((RuntimeAware) interceptor).setRuntime(runtime);
- }
- });
-
- break;
- case template:
- if (!source.getInterceptors().isEmpty()) {
- LOGGER.warn("Interceptors associated to the route template {} will be ignored", source.getName());
- }
-
- interceptors = List.of(new RouteBuilderLifecycleStrategy() {
- @Override
- public void afterConfigure(RouteBuilder builder) {
- List<RouteDefinition> routes = builder.getRouteCollection().getRoutes();
- List<RouteTemplateDefinition> templates = builder.getRouteTemplateCollection().getRouteTemplates();
-
- if (routes.size() != 1) {
- throw new IllegalArgumentException(
- "There should be a single route definition when configuring route templates, got "
- + routes.size());
- }
- if (!templates.isEmpty()) {
- throw new IllegalArgumentException(
- "There should not be any template definition when configuring route templates, got "
- + templates.size());
- }
-
- // create a new template from the source
- RouteTemplateDefinition templatesDefinition = builder.getRouteTemplateCollection()
- .routeTemplate(source.getId());
- templatesDefinition.setRoute(routes.get(0));
-
- source.getPropertyNames().forEach(templatesDefinition::templateParameter);
-
- // remove all routes definitions as they have been translated
- // in the related route template
- routes.clear();
- }
- });
- break;
- case errorHandler:
- if (!source.getInterceptors().isEmpty()) {
- LOGGER.warn("Interceptors associated to the error handler {} will be ignored", source.getName());
- }
-
- interceptors = List.of(new RouteBuilderLifecycleStrategy() {
- @Override
- public void afterConfigure(RouteBuilder builder) {
- List<RouteDefinition> routes = builder.getRouteCollection().getRoutes();
- List<RouteTemplateDefinition> templates = builder.getRouteTemplateCollection().getRouteTemplates();
-
- if (!routes.isEmpty()) {
- throw new IllegalArgumentException(
- "There should be no route definition when configuring error handler, got " + routes.size());
- }
- if (!templates.isEmpty()) {
- throw new IllegalArgumentException(
- "There should not be any template definition when configuring error handler, got "
- + templates.size());
- }
- if (builder.hasErrorHandlerFactory()) {
- LOGGER.debug("Setting default error handler builder factory as type {}",
- builder.getErrorHandlerFactory().getClass());
- runtime.getExtendedCamelContext().setErrorHandlerFactory(builder.getErrorHandlerFactory());
- }
- }
- });
- break;
- default:
- throw new IllegalArgumentException("Unknown source type: " + source.getType());
- }
-
- try {
- final Resource resource = Sources.asResource(runtime.getCamelContext(), source);
- final ExtendedCamelContext ecc = runtime.getExtendedCamelContext();
- final Collection<RoutesBuilder> builders = PluginHelper.getRoutesLoader(ecc).findRoutesBuilders(resource);
-
- builders.stream()
- .map(RouteBuilder.class::cast)
- .peek(b -> interceptors.forEach(b::addLifecycleInterceptor))
- .forEach(runtime::addRoutes);
- } catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
- }
- }
-
- public static void loadErrorHandlerSource(Runtime runtime, SourceDefinition errorHandlerSourceDefinition) {
- LOGGER.info("Loading error handler from: {}", errorHandlerSourceDefinition);
- load(runtime, Sources.fromDefinition(errorHandlerSourceDefinition));
- }
-}
diff --git a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/StringSupport.java b/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/StringSupport.java
deleted file mode 100644
index 370f6fc7f8..0000000000
--- a/extensions/camel-k/runtime/src/main/java/org/apache/camel/quarkus/k/support/StringSupport.java
+++ /dev/null
@@ -1,75 +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.quarkus.k.support;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.StringHelper;
-
-public final class StringSupport {
- private StringSupport() {
- }
-
- public static String substringBefore(String str, String separator) {
- String answer = StringHelper.before(str, separator);
- if (answer == null) {
- answer = str;
- }
-
- return answer;
- }
-
- public static String substringAfter(String str, String separator) {
- String answer = StringHelper.after(str, separator);
- if (answer == null) {
- answer = "";
- }
-
- return answer;
- }
-
- public static String substringAfterLast(String str, String separator) {
- if (ObjectHelper.isEmpty(str)) {
- return str;
- }
- if (ObjectHelper.isEmpty(separator)) {
- return "";
- }
- int pos = str.lastIndexOf(separator);
- if (pos == -1 || pos == str.length() - separator.length()) {
- return "";
- }
- return str.substring(pos + separator.length());
- }
-
- public static String substringBeforeLast(String str, String separator) {
- if (ObjectHelper.isEmpty(str) || ObjectHelper.isEmpty(separator)) {
- return str;
- }
- int pos = str.lastIndexOf(separator);
- if (pos == -1) {
- return str;
- }
- return str.substring(0, pos);
- }
-
- public static List<String> split(String input, String regex) {
- return input != null ? List.of(input.split(regex)) : Collections.emptyList();
- }
-}
diff --git a/extensions/camel-k/runtime/src/main/resources/META-INF/services/org.apache.camel.quarkus.k.core.Runtime$Listener b/extensions/camel-k/runtime/src/main/resources/META-INF/services/org.apache.camel.quarkus.k.core.Runtime$Listener
deleted file mode 100644
index bdd638af63..0000000000
--- a/extensions/camel-k/runtime/src/main/resources/META-INF/services/org.apache.camel.quarkus.k.core.Runtime$Listener
+++ /dev/null
@@ -1,19 +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.
-#
-
-org.apache.camel.quarkus.k.listener.ContextConfigurer
-org.apache.camel.quarkus.k.listener.SourcesConfigurer
diff --git a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/SourceTest.java b/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/SourceTest.java
deleted file mode 100644
index 7942c0295c..0000000000
--- a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/SourceTest.java
+++ /dev/null
@@ -1,54 +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.quarkus.k;
-
-import org.apache.camel.quarkus.k.core.SourceDefinition;
-import org.apache.camel.quarkus.k.support.Sources;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
-
-public class SourceTest {
- @Test
- public void testResourceWithoutScheme() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(
- () -> Sources.fromURI("routes.js"));
- }
-
- @Test
- public void testResourceWithIllegalScheme() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(
- () -> Sources.fromURI("http:routes.js"));
- }
-
- @Test
- public void testUnsupportedLanguage() {
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(
- () -> Sources.fromURI(" test"));
- }
-
- @Test
- public void sourceCanBeContructedFromLocation() {
- SourceDefinition definition = new SourceDefinition();
- definition.setLocation("classpath:MyRoutes.java");
-
- assertThat(Sources.fromDefinition(definition))
- .hasFieldOrPropertyWithValue("name", "MyRoutes")
- .hasFieldOrPropertyWithValue("language", "java");
- }
-}
diff --git a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/listener/PropertiesFunctionsConfigurerTest.java b/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/listener/PropertiesFunctionsConfigurerTest.java
deleted file mode 100644
index b715c6b991..0000000000
--- a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/listener/PropertiesFunctionsConfigurerTest.java
+++ /dev/null
@@ -1,55 +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.quarkus.k.listener;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.quarkus.k.core.Runtime;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-public class PropertiesFunctionsConfigurerTest {
-
- @Test
- public void testKubernetesFunction() {
- Runtime runtime = Runtime.on(new DefaultCamelContext());
- runtime.setProperties("my.property", "{{secret:my-secret/my-property}}");
-
- assertThat(runtime.getCamelContext().resolvePropertyPlaceholders("{{secret:my-secret/my-property}}"))
- .isEqualTo("my-secret-property");
- assertThat(runtime.getCamelContext().resolvePropertyPlaceholders("{{secret:none/my-property:my-default-secret}}"))
- .isEqualTo("my-default-secret");
- CamelContext context = runtime.getCamelContext();
-
- assertThatThrownBy(() -> context.resolvePropertyPlaceholders("{{secret:none/my-property}}"))
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("returned null value which is not allowed, from input");
-
- assertThat(runtime.getCamelContext().resolvePropertyPlaceholders("{{configmap:my-cm/my-property}}"))
- .isEqualTo("my-cm-property");
- assertThat(runtime.getCamelContext().resolvePropertyPlaceholders("{{configmap:my-cm/my-property:my-default-cm}}"))
- .isEqualTo("my-default-cm");
-
- assertThatThrownBy(() -> context.resolvePropertyPlaceholders("{{configmap:none/my-property}}"))
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("returned null value which is not allowed, from input");
-
- assertThat(runtime.getCamelContext().resolvePropertyPlaceholders("{{my.property}}")).isEqualTo("my-secret-property");
- }
-}
diff --git a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/listener/SourceConfigurerTest.java b/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/listener/SourceConfigurerTest.java
deleted file mode 100644
index 9a727d855e..0000000000
--- a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/listener/SourceConfigurerTest.java
+++ /dev/null
@@ -1,143 +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.quarkus.k.listener;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.quarkus.k.core.SourceType;
-import org.apache.camel.quarkus.k.support.PropertiesSupport;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-import static org.apache.camel.util.PropertiesHelper.asProperties;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class SourceConfigurerTest {
- @Test
- public void shouldLoadMultipleSources() {
- CamelContext context = new DefaultCamelContext();
- context.getPropertiesComponent().setInitialProperties(asProperties(
- "camel.k.sources[0].name", "templateName",
- "camel.k.sources[0].location", "classpath:MyTemplate.java",
- "camel.k.sources[0].type", "template",
- "camel.k.sources[1].name", "src",
- "camel.k.sources[1].location", "classpath:MySrc.java",
- "camel.k.sources[2].name", "err",
- "camel.k.sources[2].location", "classpath:Err.java",
- "camel.k.sources[2].type", "errorHandler"));
-
- SourcesConfigurer configuration = new SourcesConfigurer();
-
- PropertiesSupport.bindProperties(
- context,
- configuration,
- k -> k.startsWith(SourcesConfigurer.CAMEL_K_SOURCES_PREFIX),
- SourcesConfigurer.CAMEL_K_PREFIX);
-
- assertThat(configuration.getSources()).hasSize(3);
- }
-
- @Test
- public void shouldFailOnMultipleErrorHandlers() {
- CamelContext context = new DefaultCamelContext();
- context.getPropertiesComponent().setInitialProperties(asProperties(
- "camel.k.sources[0].name", "templateName0",
- "camel.k.sources[0].location", "classpath:MyTemplate1.java",
- "camel.k.sources[0].type", "template",
- "camel.k.sources[1].name", "err1",
- "camel.k.sources[1].location", "classpath:Err1.java",
- "camel.k.sources[1].type", "errorHandler",
- "camel.k.sources[2].name", "err2",
- "camel.k.sources[2].location", "classpath:Err2.java",
- "camel.k.sources[2].type", "errorHandler"));
-
- SourcesConfigurer configuration = new SourcesConfigurer();
-
- PropertiesSupport.bindProperties(
- context,
- configuration,
- k -> k.startsWith(SourcesConfigurer.CAMEL_K_SOURCES_PREFIX),
- SourcesConfigurer.CAMEL_K_PREFIX);
-
- assertThat(configuration.getSources()).hasSize(3);
- Assertions.assertThrows(IllegalArgumentException.class, () -> {
- SourcesConfigurer.checkUniqueErrorHandler(configuration.getSources());
- }, "java.lang.IllegalArgumentException: Expected only one error handler source type, got 2");
- }
-
- @Test
- public void shouldDefaultSourcesWithEmptyType() {
- CamelContext context = new DefaultCamelContext();
- context.getPropertiesComponent().setInitialProperties(asProperties(
- "camel.k.sources[0].name", "source0",
- "camel.k.sources[1].name", "source1",
- "camel.k.sources[2].name", "source2",
- "camel.k.sources[2].type", "source"));
-
- SourcesConfigurer configuration = new SourcesConfigurer();
-
- PropertiesSupport.bindProperties(
- context,
- configuration,
- k -> k.startsWith(SourcesConfigurer.CAMEL_K_SOURCES_PREFIX),
- SourcesConfigurer.CAMEL_K_PREFIX);
-
- assertThat(configuration.getSources().length).isEqualTo(3);
- assertThat(configuration.getSources()[0].getType()).isEqualTo(SourceType.source);
- assertThat(configuration.getSources()[1].getType()).isEqualTo(SourceType.source);
- assertThat(configuration.getSources()[2].getType()).isEqualTo(SourceType.source);
- }
-
- @Test
- public void shouldOrderSourcesByType() {
- CamelContext context = new DefaultCamelContext();
- context.getPropertiesComponent().setInitialProperties(asProperties(
- "camel.k.sources[0].name", "template1",
- "camel.k.sources[0].type", "template",
- "camel.k.sources[1].name", "source1",
- "camel.k.sources[1].type", "source",
- "camel.k.sources[2].name", "source2",
- "camel.k.sources[3].name", "errorHandler1",
- "camel.k.sources[3].type", "errorHandler"));
-
- SourcesConfigurer configuration = new SourcesConfigurer();
-
- PropertiesSupport.bindProperties(
- context,
- configuration,
- k -> k.startsWith(SourcesConfigurer.CAMEL_K_SOURCES_PREFIX),
- SourcesConfigurer.CAMEL_K_PREFIX);
- SourcesConfigurer.sortSources(configuration.getSources());
-
- assertThat(configuration.getSources()).hasSize(4);
- assertThat(configuration.getSources()[0].getName()).isEqualTo("errorHandler1");
- assertThat(configuration.getSources()[0].getType()).isEqualTo(SourceType.errorHandler);
- assertThat(configuration.getSources()[1].getName()).isEqualTo("template1");
- assertThat(configuration.getSources()[1].getType()).isEqualTo(SourceType.template);
- // Order for the same type does not matter
- assertThat(configuration.getSources()[2].getName()).contains("source");
- assertThat(configuration.getSources()[2].getType()).isEqualTo(SourceType.source);
- assertThat(configuration.getSources()[3].getName()).contains("source");
- assertThat(configuration.getSources()[3].getType()).isEqualTo(SourceType.source);
- }
-
- @Test
- public void shouldNotFailOnEmptySources() {
- SourcesConfigurer.sortSources(null);
- SourcesConfigurer.checkUniqueErrorHandler(null);
- }
-}
diff --git a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/runtime/PropertiesFunctionsConfigurerTest.java b/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/runtime/PropertiesFunctionsConfigurerTest.java
new file mode 100644
index 0000000000..7bc84f60cf
--- /dev/null
+++ b/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/runtime/PropertiesFunctionsConfigurerTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.quarkus.k.runtime;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class PropertiesFunctionsConfigurerTest {
+
+ @Test
+ public void testFunction() throws Exception {
+ try (CamelContext context = new DefaultCamelContext()) {
+ context.getPropertiesComponent().addInitialProperty("my.property", "{{secret:my-secret/my-property}}");
+
+ assertThat(context.resolvePropertyPlaceholders("{{secret:my-secret/my-property}}"))
+ .isEqualTo("my-secret-property");
+ assertThat(context.resolvePropertyPlaceholders("{{secret:none/my-property:my-default-secret}}"))
+ .isEqualTo("my-default-secret");
+
+ assertThatThrownBy(() -> context.resolvePropertyPlaceholders("{{secret:none/my-property}}"))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("returned null value which is not allowed, from input");
+
+ assertThat(context.resolvePropertyPlaceholders("{{configmap:my-cm/my-property}}"))
+ .isEqualTo("my-cm-property");
+ assertThat(context.resolvePropertyPlaceholders("{{configmap:my-cm/my-property:my-default-cm}}"))
+ .isEqualTo("my-default-cm");
+
+ assertThatThrownBy(() -> context.resolvePropertyPlaceholders("{{configmap:none/my-property}}"))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("returned null value which is not allowed, from input");
+
+ assertThat(context.resolvePropertyPlaceholders("{{my.property}}")).isEqualTo("my-secret-property");
+ assertThat(context.resolvePropertyPlaceholders("{{my-app-property}}")).isEqualTo("my-app-value");
+ }
+ }
+}
diff --git a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/NameCustomizer.java b/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/NameCustomizer.java
deleted file mode 100644
index e0033e3f1a..0000000000
--- a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/NameCustomizer.java
+++ /dev/null
@@ -1,45 +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.quarkus.k.support;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Ordered;
-import org.apache.camel.impl.engine.ExplicitCamelContextNameStrategy;
-import org.apache.camel.spi.CamelContextCustomizer;
-
-public final class NameCustomizer implements CamelContextCustomizer {
-
- private String name;
-
- public NameCustomizer() {
- this("default");
- }
-
- public NameCustomizer(String name) {
- this.name = name;
- }
-
- @Override
- public int getOrder() {
- return Ordered.HIGHEST;
- }
-
- @Override
- public void configure(CamelContext camelContext) {
- camelContext.setNameStrategy(new ExplicitCamelContextNameStrategy(name));
- }
-}
diff --git a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/PropertiesSupportTest.java b/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/PropertiesSupportTest.java
deleted file mode 100644
index 2c11d02d19..0000000000
--- a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/PropertiesSupportTest.java
+++ /dev/null
@@ -1,94 +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.quarkus.k.support;
-
-import java.util.List;
-import java.util.Objects;
-import java.util.function.Predicate;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.quarkus.k.core.SourceDefinition;
-import org.apache.camel.quarkus.k.listener.SourcesConfigurer;
-import org.junit.jupiter.api.Test;
-
-import static org.apache.camel.util.PropertiesHelper.asProperties;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class PropertiesSupportTest {
- @Test
- public void propertiesAreBoundToSourcesConfigurer() {
- CamelContext context = new DefaultCamelContext();
- context.getPropertiesComponent().setInitialProperties(asProperties(
- "camel.k.sources[0].name", "MyRoutesWithBeans",
- "camel.k.sources[0].location", "classpath:MyRoutesWithBeans.java",
- "camel.k.sources[1].name", "MyRoutesConfig",
- "camel.k.sources[1].location", "classpath:MyRoutesConfig.java",
- "camel.k.sources[1].property-names[0]", "foo",
- "camel.k.sources[1].property-names[1]", "bar"));
-
- SourcesConfigurer configuration = new SourcesConfigurer();
-
- PropertiesSupport.bindProperties(
- context,
- configuration,
- k -> k.startsWith(SourcesConfigurer.CAMEL_K_SOURCES_PREFIX),
- SourcesConfigurer.CAMEL_K_PREFIX);
-
- assertThat(configuration.getSources())
- .hasSize(2)
- .anyMatch(byNameAndLocation("MyRoutesWithBeans", "classpath:MyRoutesWithBeans.java")
- .and(d -> d.getPropertyNames() == null))
- .anyMatch(byNameAndLocation("MyRoutesConfig", "classpath:MyRoutesConfig.java")
- .and(d -> d.getPropertyNames() != null && d.getPropertyNames().containsAll(List.of("foo", "bar"))));
- }
-
- @Test
- public void propertiesWithGapsAreBoundToSourcesConfigurer() {
- CamelContext context = new DefaultCamelContext();
- context.getPropertiesComponent().setInitialProperties(asProperties(
- "camel.k.sources[0].name", "MyRoutesWithBeans",
- "camel.k.sources[0].location", "classpath:MyRoutesWithBeans.java",
- "camel.k.sources[2].name", "MyRoutesConfig",
- "camel.k.sources[2].location", "classpath:MyRoutesConfig.java"));
-
- SourcesConfigurer configuration = new SourcesConfigurer();
-
- PropertiesSupport.bindProperties(
- context,
- configuration,
- k -> k.startsWith(SourcesConfigurer.CAMEL_K_SOURCES_PREFIX),
- SourcesConfigurer.CAMEL_K_PREFIX);
-
- assertThat(configuration.getSources())
- .hasSize(3)
- .filteredOn(Objects::nonNull)
- .hasSize(2)
- .anyMatch(byNameAndLocation("MyRoutesWithBeans", "classpath:MyRoutesWithBeans.java"))
- .anyMatch(byNameAndLocation("MyRoutesConfig", "classpath:MyRoutesConfig.java"));
- }
-
- // ***************************
- //
- // Helpers
- //
- // ***************************
-
- private static Predicate<SourceDefinition> byNameAndLocation(String name, String location) {
- return def -> Objects.equals(def.getName(), name) && Objects.equals(def.getLocation(), location);
- }
-}
diff --git a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/RuntimeSupportTest.java b/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/RuntimeSupportTest.java
deleted file mode 100644
index 2843557f07..0000000000
--- a/extensions/camel-k/runtime/src/test/java/org/apache/camel/quarkus/k/support/RuntimeSupportTest.java
+++ /dev/null
@@ -1,194 +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.quarkus.k.support;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Ordered;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.impl.engine.ExplicitCamelContextNameStrategy;
-import org.apache.camel.spi.CamelContextCustomizer;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class RuntimeSupportTest {
-
- @Test
- public void testLoadCustomizersWithPropertiesFlags() {
- CamelContext context = new DefaultCamelContext();
-
- NameCustomizer customizer = new NameCustomizer("from-registry");
- context.getRegistry().bind("name", customizer);
-
- List<CamelContextCustomizer> customizers = RuntimeSupport.configureContextCustomizers(context);
- assertThat(context.getName()).isNotEqualTo("from-registry");
- assertThat(context.getName()).isNotEqualTo("default");
- assertThat(customizers).isEmpty();
-
- Properties properties = new Properties();
- properties.setProperty("camel.k.customizer.name.enabled", "true");
- context.getPropertiesComponent().setInitialProperties(properties);
-
- customizers = RuntimeSupport.configureContextCustomizers(context);
- assertThat(context.getName()).isEqualTo("from-registry");
- assertThat(customizers).hasSize(1);
- }
-
- @Test
- public void testLoadCustomizersWithList() {
- CamelContext context = new DefaultCamelContext();
-
- NameCustomizer customizer = new NameCustomizer("from-registry");
- context.getRegistry().bind("name", customizer);
-
- List<CamelContextCustomizer> customizers = RuntimeSupport.configureContextCustomizers(context);
- assertThat(context.getName()).isNotEqualTo("from-registry");
- assertThat(context.getName()).isNotEqualTo("default");
- assertThat(customizers).isEmpty();
-
- Properties properties = new Properties();
- properties.setProperty(Constants.PROPERTY_CAMEL_K_CUSTOMIZER, "name");
- context.getPropertiesComponent().setInitialProperties(properties);
-
- customizers = RuntimeSupport.configureContextCustomizers(context);
- assertThat(context.getName()).isEqualTo("from-registry");
- assertThat(customizers).hasSize(1);
- }
-
- @Test
- public void testLoadCustomizers() {
- CamelContext context = new DefaultCamelContext();
- context.getRegistry().bind("converters",
- (CamelContextCustomizer) camelContext -> camelContext.setLoadTypeConverters(true));
-
- List<CamelContextCustomizer> customizers = RuntimeSupport.configureContextCustomizers(context);
- assertThat(context.getName()).isNotEqualTo("from-registry");
- assertThat(context.getName()).isNotEqualTo("default");
- assertThat(context.isLoadTypeConverters()).isFalse();
- assertThat(customizers).isEmpty();
-
- Properties properties = new Properties();
- properties.setProperty("camel.k.customizer.name.enabled", "true");
- context.getPropertiesComponent().setInitialProperties(properties);
-
- customizers = RuntimeSupport.configureContextCustomizers(context);
- assertThat(context.getName()).isEqualTo("default");
- assertThat(customizers).hasSize(1);
-
- properties.setProperty("camel.k.customizer.converters.enabled", "true");
- context.getPropertiesComponent().setInitialProperties(properties);
-
- customizers = RuntimeSupport.configureContextCustomizers(context);
- assertThat(context.getName()).isEqualTo("default");
- assertThat(context.isLoadTypeConverters()).isTrue();
- assertThat(customizers).hasSize(2);
- }
-
- @Test
- public void testLoadCustomizersFallback() {
- CamelContext context = new DefaultCamelContext();
- context.getRegistry().bind("converters",
- (CamelContextCustomizer) camelContext -> camelContext.setLoadTypeConverters(true));
-
- List<CamelContextCustomizer> customizers = RuntimeSupport.configureContextCustomizers(context);
- assertThat(context.getName()).isNotEqualTo("from-registry");
- assertThat(context.getName()).isNotEqualTo("default");
- assertThat(context.isLoadTypeConverters()).isFalse();
- assertThat(customizers).isEmpty();
-
- Properties properties = new Properties();
- properties.setProperty("customizer.name.enabled", "true");
- context.getPropertiesComponent().setInitialProperties(properties);
-
- customizers = RuntimeSupport.configureContextCustomizers(context);
- assertThat(context.getName()).isEqualTo("default");
- assertThat(customizers).hasSize(1);
-
- properties.setProperty("customizer.converters.enabled", "true");
- properties.setProperty("customizer.converters.enabled", "true");
- context.getPropertiesComponent().setInitialProperties(properties);
-
- customizers = RuntimeSupport.configureContextCustomizers(context);
- assertThat(context.getName()).isEqualTo("default");
- assertThat(context.isLoadTypeConverters()).isTrue();
- assertThat(customizers).hasSize(2);
- }
-
- @Test
- public void testLoadCustomizerOrder() {
- DefaultCamelContext context = new DefaultCamelContext();
- context.getCamelContextExtension().setName("camel");
- context.getRegistry().bind("c1", new CamelContextCustomizer() {
- @Override
- public int getOrder() {
- return Ordered.LOWEST;
- }
-
- @Override
- public void configure(CamelContext camelContext) {
- camelContext.setNameStrategy(new ExplicitCamelContextNameStrategy(camelContext.getName() + "-c1"));
- }
- });
- context.getRegistry().bind("c2", new CamelContextCustomizer() {
- @Override
- public int getOrder() {
- return Ordered.HIGHEST;
- }
-
- @Override
- public void configure(CamelContext camelContext) {
- camelContext.setNameStrategy(new ExplicitCamelContextNameStrategy(camelContext.getName() + "-c2"));
- }
- });
- context.getRegistry().bind("c3", new CamelContextCustomizer() {
- @Override
- public void configure(CamelContext camelContext) {
- camelContext.setNameStrategy(new ExplicitCamelContextNameStrategy(camelContext.getName() + "-c3"));
- }
- });
-
- Properties properties = new Properties();
- properties.setProperty("camel.k.customizer.c1.enabled", "true");
- properties.setProperty("camel.k.customizer.c2.enabled", "true");
- properties.setProperty("camel.k.customizer.c3.enabled", "true");
-
- context.getPropertiesComponent().setInitialProperties(properties);
-
- List<CamelContextCustomizer> customizers = RuntimeSupport.configureContextCustomizers(context);
- assertThat(customizers).hasSize(3);
- assertThat(context.getName()).isEqualTo("camel-c2-c3-c1");
- }
-
- @Test
- public void shouldLoadUsePropertiesFromTextConfigMap() {
- System.setProperty(Constants.PROPERTY_CAMEL_K_CONF_D, getClass().getResource("/configmaps/my-cm").getFile());
- Map<String, String> loadedProperties = RuntimeSupport.loadUserProperties();
- assertThat(loadedProperties).hasSize(1);
- assertThat(loadedProperties.get("my-property")).isEqualTo("my-cm-property");
- }
-
- @Test
- public void shouldSkipLoadUsePropertiesFromBinaryConfigMap() {
- System.setProperty(Constants.PROPERTY_CAMEL_K_CONF_D, getClass().getResource("/configmaps/my-binary-cm").getFile());
- Map<String, String> loadedProperties = RuntimeSupport.loadUserProperties();
- assertThat(loadedProperties).isEmpty();
- }
-}
diff --git a/extensions/camel-k/runtime/src/test/resources/META-INF/services/org.apache.camel.quarkus.k/customizer/name b/extensions/camel-k/runtime/src/test/resources/META-INF/services/org.apache.camel.quarkus.k/customizer/name
deleted file mode 100644
index 26286751d8..0000000000
--- a/extensions/camel-k/runtime/src/test/resources/META-INF/services/org.apache.camel.quarkus.k/customizer/name
+++ /dev/null
@@ -1,18 +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.
-#
-
-class=org.apache.camel.quarkus.k.support.NameCustomizer
\ No newline at end of file
diff --git a/extensions/camel-k/runtime/src/test/resources/configmaps/my-binary-cm/my-property.zip b/extensions/camel-k/runtime/src/test/resources/conf.d/_configmaps/my-binary-cm/my-property.zip
similarity index 100%
rename from extensions/camel-k/runtime/src/test/resources/configmaps/my-binary-cm/my-property.zip
rename to extensions/camel-k/runtime/src/test/resources/conf.d/_configmaps/my-binary-cm/my-property.zip
diff --git a/extensions/camel-k/runtime/src/test/resources/conf.d/_configmaps/my-cm/application.properties b/extensions/camel-k/runtime/src/test/resources/conf.d/_configmaps/my-cm/application.properties
new file mode 100644
index 0000000000..8d192092f3
--- /dev/null
+++ b/extensions/camel-k/runtime/src/test/resources/conf.d/_configmaps/my-cm/application.properties
@@ -0,0 +1,2 @@
+
+my-app-property = my-app-value
\ No newline at end of file
diff --git a/extensions/camel-k/runtime/src/test/resources/configmaps/my-cm/my-property b/extensions/camel-k/runtime/src/test/resources/conf.d/_configmaps/my-cm/my-property
similarity index 100%
rename from extensions/camel-k/runtime/src/test/resources/configmaps/my-cm/my-property
rename to extensions/camel-k/runtime/src/test/resources/conf.d/_configmaps/my-cm/my-property
diff --git a/extensions/camel-k/runtime/src/test/resources/secrets/my-secret/my-property b/extensions/camel-k/runtime/src/test/resources/conf.d/_secrets/my-secret/my-property
similarity index 100%
rename from extensions/camel-k/runtime/src/test/resources/secrets/my-secret/my-property
rename to extensions/camel-k/runtime/src/test/resources/conf.d/_secrets/my-secret/my-property
diff --git a/extensions/camel-k/runtime/src/test/resources/my-cp-resource.txt b/extensions/camel-k/runtime/src/test/resources/my-cp-resource.txt
deleted file mode 100644
index 64ec491e4d..0000000000
--- a/extensions/camel-k/runtime/src/test/resources/my-cp-resource.txt
+++ /dev/null
@@ -1 +0,0 @@
-my cp content
\ No newline at end of file
diff --git a/extensions/camel-k/runtime/src/test/resources/my-file-resource.txt b/extensions/camel-k/runtime/src/test/resources/my-file-resource.txt
deleted file mode 100644
index 63d3cca605..0000000000
--- a/extensions/camel-k/runtime/src/test/resources/my-file-resource.txt
+++ /dev/null
@@ -1 +0,0 @@
-my file content
\ No newline at end of file
diff --git a/integration-tests/camel-k-runtime-model-reifier/src/main/resources/application.properties b/integration-tests/camel-k-runtime-model-reifier/src/main/resources/application.properties
index 4408fe3062..bf774dcd7f 100644
--- a/integration-tests/camel-k-runtime-model-reifier/src/main/resources/application.properties
+++ b/integration-tests/camel-k-runtime-model-reifier/src/main/resources/application.properties
@@ -27,4 +27,4 @@ quarkus.kubernetes-client.devservices.enabled = false
# visible in the logs for troubleshooting
quarkus.log.category."org.apache.camel.quarkus.k.runtime.ApplicationRoutes".level = DEBUG
-quarkus.native.resources.includes = routes.yaml
\ No newline at end of file
+quarkus.native.resources.includes = routes/*.yaml
\ No newline at end of file
diff --git a/integration-tests/camel-k-runtime-model-reifier/src/main/resources/routes.yaml b/integration-tests/camel-k-runtime-model-reifier/src/main/resources/routes/test-route-001.yaml
similarity index 100%
rename from integration-tests/camel-k-runtime-model-reifier/src/main/resources/routes.yaml
rename to integration-tests/camel-k-runtime-model-reifier/src/main/resources/routes/test-route-001.yaml
diff --git a/integration-tests/camel-k-runtime-model-reifier/src/test/java/org/apache/camel/quarkus/k/it/WithRoutesOverridesTest.java b/integration-tests/camel-k-runtime-model-reifier/src/test/java/org/apache/camel/quarkus/k/it/WithRoutesOverridesTest.java
index 346f0ac547..2f4867ced4 100644
--- a/integration-tests/camel-k-runtime-model-reifier/src/test/java/org/apache/camel/quarkus/k/it/WithRoutesOverridesTest.java
+++ b/integration-tests/camel-k-runtime-model-reifier/src/test/java/org/apache/camel/quarkus/k/it/WithRoutesOverridesTest.java
@@ -62,6 +62,9 @@ public class WithRoutesOverridesTest {
@Override
public Map<String, String> start() {
return CollectionHelper.mapOf(
+ // routes
+ "camel.main.routes-include-pattern", "classpath:routes/test-route-001.yaml",
+ // overrides
"camel.k.routes.overrides[0].input.from", "direct:r1",
"camel.k.routes.overrides[0].input.with", "direct:r1override",
"camel.k.routes.overrides[1].id", "r2invalid",
@@ -75,9 +78,7 @@ public class WithRoutesOverridesTest {
"camel.k.routes.overrides[3].input.with", "direct:r4override",
"camel.k.routes.overrides[4].input.with", "direct:r5invalid",
"camel.k.routes.overrides[5].id", "r5",
- "camel.k.routes.overrides[5].input.with", "direct:r5override",
- "camel.k.sources[0].location", "classpath:routes.yaml",
- "camel.k.sources[0].type", "source");
+ "camel.k.routes.overrides[5].input.with", "direct:r5override");
}
@Override
diff --git a/extensions/camel-k/deployment/pom.xml b/integration-tests/camel-k-runtime-shutdown/pom.xml
similarity index 51%
copy from extensions/camel-k/deployment/pom.xml
copy to integration-tests/camel-k-runtime-shutdown/pom.xml
index d27ae857b9..0584f253e2 100644
--- a/extensions/camel-k/deployment/pom.xml
+++ b/integration-tests/camel-k-runtime-shutdown/pom.xml
@@ -18,140 +18,149 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-camel-k-parent</artifactId>
+ <artifactId>camel-quarkus-build-parent-it</artifactId>
<version>3.9.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
+ <relativePath>../../poms/build-parent-it/pom.xml</relativePath>
</parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-quarkus-integration-test-camel-k-runtime-shutdown</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Camel K Runtime Shutdown</name>
+ <description>Integration tests for Camel Quarkus K Runtime Shutdown extension</description>
- <artifactId>camel-quarkus-camel-k-deployment</artifactId>
- <name>Camel Quarkus :: Camel K :: Deployment</name>
+ <properties>
+ <quarkus.runner.jar>${project.build.directory}/quarkus-app/quarkus-run.jar</quarkus.runner.jar>
+ </properties>
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-core-deployment</artifactId>
+ <artifactId>camel-quarkus-camel-k</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-camel-k</artifactId>
+ <artifactId>camel-quarkus-yaml-dsl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-kubernetes-deployment</artifactId>
+ <artifactId>camel-quarkus-timer</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-bean-deployment</artifactId>
+ <artifactId>camel-quarkus-log</artifactId>
</dependency>
<dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
- <artifactId>quarkus-junit5-internal</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.rest-assured</groupId>
- <artifactId>rest-assured</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
+ <artifactId>quarkus-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-groovy-dsl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-java-joor-dsl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-js-dsl</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-jsh-dsl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-kotlin-dsl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-yaml-dsl</artifactId>
- <scope>test</scope>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
+
+ <!-- test dependencies -->
<dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-xml-io-dsl</artifactId>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-direct</artifactId>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-jackson</artifactId>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-log</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-jsonb</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-resteasy-jsonb</artifactId>
+ <artifactId>camel-quarkus-integration-tests-process-executor-support</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <annotationProcessorPaths>
- <path>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-extension-processor</artifactId>
- <version>${quarkus.version}</version>
- </path>
- </annotationProcessorPaths>
- </configuration>
- </plugin>
- </plugins>
- </build>
<profiles>
+ <profile>
+ <id>full</id>
+ <activation>
+ <property>
+ <name>!quickly</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <!-- Move surefire:test to integration-test phase to be able to run
+ java -jar target/*runner.jar from a test -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <phase>integration-test</phase>
+ <configuration>
+ <systemPropertyVariables>
+ <quarkus.runner>${quarkus.runner.jar}</quarkus.runner>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ <quarkus.runner.jar>${project.build.directory}/${project.artifactId}-${project.version}-native-image-source-jar/${project.artifactId}-${project.version}-runner.jar</quarkus.runner.jar>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+ <quarkus.runner>${project.build.directory}/${project.artifactId}-${project.version}-runner</quarkus.runner>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
<profile>
<id>virtualDependencies</id>
<activation>
@@ -163,7 +172,7 @@
<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-direct-deployment</artifactId>
+ <artifactId>camel-quarkus-camel-k-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
@@ -176,72 +185,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-groovy-dsl-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-jackson-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-java-joor-dsl-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-js-dsl-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-jsh-dsl-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-kotlin-dsl-deployment</artifactId>
+ <artifactId>camel-quarkus-direct-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
@@ -267,7 +211,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-xml-io-dsl-deployment</artifactId>
+ <artifactId>camel-quarkus-timer-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
@@ -293,5 +237,16 @@
</dependency>
</dependencies>
</profile>
+ <profile>
+ <id>skip-testcontainers-tests</id>
+ <activation>
+ <property>
+ <name>skip-testcontainers-tests</name>
+ </property>
+ </activation>
+ <properties>
+ <skipTests>true</skipTests>
+ </properties>
+ </profile>
</profiles>
</project>
diff --git a/integration-tests/camel-k-runtime-model-reifier/src/main/resources/application.properties b/integration-tests/camel-k-runtime-shutdown/src/main/resources/application.properties
similarity index 81%
copy from integration-tests/camel-k-runtime-model-reifier/src/main/resources/application.properties
copy to integration-tests/camel-k-runtime-shutdown/src/main/resources/application.properties
index 4408fe3062..7a5f7c982a 100644
--- a/integration-tests/camel-k-runtime-model-reifier/src/main/resources/application.properties
+++ b/integration-tests/camel-k-runtime-shutdown/src/main/resources/application.properties
@@ -20,11 +20,10 @@
#
quarkus.banner.enabled = false
+# enable debug logggin for camle-k to gather some additional details
+quarkus.log.category."org.apache.camel.quarkus.k.runtime".level = DEBUG
+
# disable kubernetes dev services as none of the test requires it.
quarkus.kubernetes-client.devservices.enabled = false
-# enable logging for ApplicationRoutes so the routes endpoint override will be
-# visible in the logs for troubleshooting
-quarkus.log.category."org.apache.camel.quarkus.k.runtime.ApplicationRoutes".level = DEBUG
-
-quarkus.native.resources.includes = routes.yaml
\ No newline at end of file
+quarkus.native.resources.includes = routes/*.yaml
\ No newline at end of file
diff --git a/extensions/camel-k/deployment/src/test/resources/routes.yaml b/integration-tests/camel-k-runtime-shutdown/src/main/resources/routes/test-route-001.yaml
similarity index 64%
rename from extensions/camel-k/deployment/src/test/resources/routes.yaml
rename to integration-tests/camel-k-runtime-shutdown/src/main/resources/routes/test-route-001.yaml
index be866f3300..f6e0dcb451 100644
--- a/extensions/camel-k/deployment/src/test/resources/routes.yaml
+++ b/integration-tests/camel-k-runtime-shutdown/src/main/resources/routes/test-route-001.yaml
@@ -16,10 +16,25 @@
#
- route:
- id: yaml
from:
- uri: 'direct:yaml'
+ uri: 'timer:once'
+ parameters:
+ delay: '1s'
+ repeatCount: '1'
steps:
- - marshal:
- json: {}
- - to: 'log:yaml'
+ - wireTap:
+ uri: "direct:in"
+ - delay:
+ constant: '250'
+ - log:
+ message: 'Once done'
+- route:
+ from:
+ uri: 'direct:in'
+ steps:
+ - delay:
+ constant: '3000'
+ - setBody:
+ simple: 'Hello {{greeted.subject}}!'
+ - log:
+ message: '${body}'
diff --git a/extensions/camel-k/deployment/src/test/resources/routes.kts b/integration-tests/camel-k-runtime-shutdown/src/test/java/org/apache/camel/quarkus/k/it/RuntimeShutdownIT.java
similarity index 88%
rename from extensions/camel-k/deployment/src/test/resources/routes.kts
rename to integration-tests/camel-k-runtime-shutdown/src/test/java/org/apache/camel/quarkus/k/it/RuntimeShutdownIT.java
index fba70eee0b..605e8efa74 100644
--- a/extensions/camel-k/deployment/src/test/resources/routes.kts
+++ b/integration-tests/camel-k-runtime-shutdown/src/test/java/org/apache/camel/quarkus/k/it/RuntimeShutdownIT.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.camel.quarkus.k.it;
-from("direct:kotlin")
- .routeId("kotlin")
- .to("log:kotlin")
\ No newline at end of file
+public class RuntimeShutdownIT extends RuntimeShutdownTest {
+}
diff --git a/integration-tests/camel-k-runtime-shutdown/src/test/java/org/apache/camel/quarkus/k/it/RuntimeShutdownTest.java b/integration-tests/camel-k-runtime-shutdown/src/test/java/org/apache/camel/quarkus/k/it/RuntimeShutdownTest.java
new file mode 100644
index 0000000000..0c8ee6d786
--- /dev/null
+++ b/integration-tests/camel-k-runtime-shutdown/src/test/java/org/apache/camel/quarkus/k/it/RuntimeShutdownTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.quarkus.k.it;
+
+import java.io.IOException;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.camel.quarkus.test.support.process.QuarkusProcessExecutor;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
+import org.zeroturnaround.exec.InvalidExitValueException;
+import org.zeroturnaround.exec.ProcessResult;
+
+@DisabledIfSystemProperty(named = "quarkus.runner", matches = ".*runner.jar", disabledReason = "https://github.com/apache/camel-quarkus/issues/4218")
+public class RuntimeShutdownTest {
+
+ @Test
+ void testStopsAfterFirstMessage()
+ throws InvalidExitValueException, IOException, InterruptedException, TimeoutException {
+
+ QuarkusProcessExecutor executor = new QuarkusProcessExecutor(
+ "-Dgreeted.subject=Joe",
+ "-Dcamel.k.shutdown.max-messages=1",
+ "-Dcamel.main.routes-include-pattern=classpath:routes/test-route-001.yaml");
+
+ ProcessResult result = executor.execute();
+
+ Assertions.assertThat(result.getExitValue()).isEqualTo(0);
+ Assertions.assertThat(result.outputUTF8()).contains("Hello Joe!");
+ Assertions.assertThat(result.outputUTF8()).contains("Once done");
+ Assertions.assertThat(result.outputUTF8()).contains("Initiate runtime shutdown (max: 1, handled: 2)");
+ }
+}
diff --git a/integration-tests/camel-k-runtime/src/main/java/org/apache/camel/quarkus/k/it/Application.java b/integration-tests/camel-k-runtime/src/main/java/org/apache/camel/quarkus/k/it/Application.java
index 49fffdb8d4..68cd303257 100644
--- a/integration-tests/camel-k-runtime/src/main/java/org/apache/camel/quarkus/k/it/Application.java
+++ b/integration-tests/camel-k-runtime/src/main/java/org/apache/camel/quarkus/k/it/Application.java
@@ -16,26 +16,24 @@
*/
package org.apache.camel.quarkus.k.it;
-import java.util.Collections;
-import java.util.Map;
+import java.util.stream.Collectors;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonObject;
+import jakarta.json.bind.Jsonb;
+import jakarta.json.bind.JsonbBuilder;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
-import org.apache.camel.component.properties.PropertiesComponent;
-import org.apache.camel.main.BaseMainSupport;
+import org.apache.camel.Route;
import org.apache.camel.model.Model;
-import org.apache.camel.quarkus.k.core.Runtime;
-import org.apache.camel.quarkus.main.CamelMain;
-
-import static org.apache.camel.quarkus.k.runtime.Application.instance;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.model.rest.RestDefinition;
@Path("/camel-k")
@ApplicationScoped
@@ -49,38 +47,21 @@ public class Application {
@Produces(MediaType.APPLICATION_JSON)
public JsonObject inspect() {
return Json.createObjectBuilder()
- .add(
- "camel-context",
- instance(CamelContext.class).map(Object::getClass).map(Class::getName).orElse(""))
- .add(
- "camel-k-runtime",
- instance(Runtime.class).map(Object::getClass).map(Class::getName).orElse(""))
- .add(
- "routes-collector",
- instance(CamelMain.class).map(BaseMainSupport::getRoutesCollector).map(Object::getClass)
- .map(Class::getName).orElse(""))
- .add(
- "global-options",
- Json.createObjectBuilder(
- instance(CamelMain.class)
- .map(BaseMainSupport::getCamelContext)
- .map(CamelContext::getGlobalOptions)
- .orElseGet(Collections::emptyMap))
- .build())
.add("model-reifier-factory", Json.createValue(
camelContext.getCamelContextExtension().getContextPlugin(Model.class)
.getModelReifierFactory().getClass().getName()))
- .build();
- }
-
- @GET
- @Path("/inspect/context")
- @Produces(MediaType.APPLICATION_JSON)
- public JsonObject inspectContext() {
- return Json.createObjectBuilder()
- .add("message-history", camelContext.isMessageHistory())
- .add("load-type-converters", camelContext.isLoadTypeConverters())
- .add("name", camelContext.getName())
+ .add("routes", Json.createArrayBuilder(
+ camelContext.getRoutes().stream()
+ .map(Route::getId)
+ .collect(Collectors.toList())))
+ .add("route-definitions", Json.createArrayBuilder(
+ camelContext.getCamelContextExtension().getContextPlugin(Model.class).getRouteDefinitions().stream()
+ .map(RouteDefinition::getId)
+ .collect(Collectors.toList())))
+ .add("rest-definitions", Json.createArrayBuilder(
+ camelContext.getCamelContextExtension().getContextPlugin(Model.class).getRestDefinitions().stream()
+ .map(RestDefinition::getId)
+ .collect(Collectors.toList())))
.build();
}
@@ -88,24 +69,29 @@ public class Application {
@Path("/property/{name}")
@Produces(MediaType.TEXT_PLAIN)
public String property(@PathParam("name") String name) {
- return instance(CamelContext.class)
- .map(CamelContext::getPropertiesComponent)
- .map(PropertiesComponent.class::cast)
- .flatMap(pc -> pc.resolveProperty(name)).orElse("");
+ return camelContext.getPropertiesComponent().resolveProperty(name).orElse("");
}
- @SuppressWarnings("unchecked")
@GET
@Path("/properties")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject properties() {
return Json.createObjectBuilder(
- instance(CamelContext.class)
- .map(CamelContext::getPropertiesComponent)
- .map(PropertiesComponent.class::cast)
- .map(PropertiesComponent::loadProperties)
- .map(Map.class::cast)
- .orElseGet(Collections::emptyMap))
+ camelContext.getPropertiesComponent().loadPropertiesAsMap())
.build();
}
+
+ @GET
+ @Path("/registry/beans/{name}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public String bean(@PathParam("name") String name) throws Exception {
+ Object bean = camelContext.getRegistry().lookupByName(name);
+ if (bean == null) {
+ throw new IllegalArgumentException("Bean with name: " + name + " not found");
+ }
+
+ try (Jsonb jsonb = JsonbBuilder.create()) {
+ return jsonb.toJson(bean);
+ }
+ }
}
diff --git a/integration-tests/camel-k-runtime/src/main/java/org/apache/camel/quarkus/k/it/RuntimeInspector.java b/integration-tests/camel-k-runtime/src/main/java/org/apache/camel/quarkus/k/it/RuntimeInspector.java
deleted file mode 100644
index cb186d1c88..0000000000
--- a/integration-tests/camel-k-runtime/src/main/java/org/apache/camel/quarkus/k/it/RuntimeInspector.java
+++ /dev/null
@@ -1,111 +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.quarkus.k.it;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import jakarta.enterprise.context.ApplicationScoped;
-import jakarta.inject.Inject;
-import jakarta.json.Json;
-import jakarta.json.JsonArray;
-import jakarta.json.JsonObject;
-import jakarta.json.bind.Jsonb;
-import jakarta.json.bind.JsonbBuilder;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.PathParam;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import org.apache.camel.CamelContext;
-import org.apache.camel.Route;
-import org.apache.camel.model.Model;
-import org.apache.camel.model.RouteDefinition;
-import org.apache.camel.model.ToDefinition;
-import org.apache.camel.model.rest.RestDefinition;
-import org.eclipse.microprofile.config.Config;
-
-import static org.apache.camel.model.ProcessorDefinitionHelper.filterTypeInOutputs;
-
-@Path("/camel-k/runtime")
-@ApplicationScoped
-public class RuntimeInspector {
- @Inject
- CamelContext camelContext;
- @Inject
- Config config;
-
- @GET
- @Path("/inspect")
- @Produces(MediaType.APPLICATION_JSON)
- public JsonObject inspect() {
- return Json.createObjectBuilder()
- .add("routes", Json.createArrayBuilder(
- camelContext.getRoutes().stream()
- .map(Route::getId)
- .collect(Collectors.toList())))
- .add("route-definitions", Json.createArrayBuilder(
- camelContext.getCamelContextExtension().getContextPlugin(Model.class).getRouteDefinitions().stream()
- .map(RouteDefinition::getId)
- .collect(Collectors.toList())))
- .add("rest-definitions", Json.createArrayBuilder(
- camelContext.getCamelContextExtension().getContextPlugin(Model.class).getRestDefinitions().stream()
- .map(RestDefinition::getId)
- .collect(Collectors.toList())))
- .build();
- }
-
- @GET
- @Path("/property/{name}")
- @Produces(MediaType.TEXT_PLAIN)
- public String property(@PathParam("name") String name) {
- return config.getValue(name, String.class);
- }
-
- @GET
- @Path("/registry/beans/{name}")
- @Produces(MediaType.APPLICATION_JSON)
- public String bean(@PathParam("name") String name) throws Exception {
- Object bean = camelContext.getRegistry().lookupByName(name);
- if (bean == null) {
- throw new IllegalArgumentException("Bean with name: " + name + " not found");
- }
-
- try (Jsonb jsonb = JsonbBuilder.create()) {
- return jsonb.toJson(bean);
- }
- }
-
- @GET
- @Path("/route-outputs/{name}")
- @Produces(MediaType.APPLICATION_JSON)
- public JsonArray routeOutputs(@PathParam("name") String name) {
- RouteDefinition def = camelContext.getCamelContextExtension().getContextPlugin(Model.class).getRouteDefinition(name);
- if (def == null) {
- throw new IllegalArgumentException("RouteDefinition with name: " + name + " not found");
- }
-
- Collection<ToDefinition> toDefinitions = filterTypeInOutputs(def.getOutputs(), ToDefinition.class);
-
- List<String> endpoints = toDefinitions.stream()
- .map(td -> td.getEndpointUri())
- .collect(Collectors.toList());
-
- return Json.createArrayBuilder(endpoints).build();
- }
-}
diff --git a/integration-tests/camel-k-runtime/src/main/resources/application.properties b/integration-tests/camel-k-runtime/src/main/resources/application.properties
index 97e58669af..7b84816467 100644
--- a/integration-tests/camel-k-runtime/src/main/resources/application.properties
+++ b/integration-tests/camel-k-runtime/src/main/resources/application.properties
@@ -21,4 +21,7 @@
quarkus.banner.enabled = false
# disable kubernetes dev services as none of the test requires it.
-quarkus.kubernetes-client.devservices.enabled = false
\ No newline at end of file
+quarkus.kubernetes-client.devservices.enabled = false
+
+# include routes as now they are loaded using the camel.main.routes-include-pattern property
+quarkus.native.resources.includes = routes/*.xml,routes/*.yaml
\ No newline at end of file
diff --git a/integration-tests/camel-k-runtime/src/test/resources/rests.xml b/integration-tests/camel-k-runtime/src/main/resources/routes/rests.xml
similarity index 100%
rename from integration-tests/camel-k-runtime/src/test/resources/rests.xml
rename to integration-tests/camel-k-runtime/src/main/resources/routes/rests.xml
diff --git a/integration-tests/camel-k-runtime/src/test/resources/routes-with-beans.yaml b/integration-tests/camel-k-runtime/src/main/resources/routes/routes-with-beans.yaml
similarity index 100%
rename from integration-tests/camel-k-runtime/src/test/resources/routes-with-beans.yaml
rename to integration-tests/camel-k-runtime/src/main/resources/routes/routes-with-beans.yaml
diff --git a/integration-tests/camel-k-runtime/src/test/resources/routes-with-expression.xml b/integration-tests/camel-k-runtime/src/main/resources/routes/routes-with-expression.xml
similarity index 100%
rename from integration-tests/camel-k-runtime/src/test/resources/routes-with-expression.xml
rename to integration-tests/camel-k-runtime/src/main/resources/routes/routes-with-expression.xml
diff --git a/integration-tests/camel-k-runtime/src/test/resources/routes.xml b/integration-tests/camel-k-runtime/src/main/resources/routes/routes.xml
similarity index 100%
rename from integration-tests/camel-k-runtime/src/test/resources/routes.xml
rename to integration-tests/camel-k-runtime/src/main/resources/routes/routes.xml
diff --git a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeCustomizerFallbackIT.java b/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeCustomizerFallbackIT.java
deleted file mode 100644
index 31ba970ed9..0000000000
--- a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeCustomizerFallbackIT.java
+++ /dev/null
@@ -1,23 +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.quarkus.k.it;
-
-import io.quarkus.test.junit.QuarkusIntegrationTest;
-
-@QuarkusIntegrationTest
-public class RuntimeCustomizerFallbackIT extends RuntimeCustomizerFallbackTest {
-}
diff --git a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeCustomizerFallbackTest.java b/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeCustomizerFallbackTest.java
deleted file mode 100644
index 6e8025f76f..0000000000
--- a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeCustomizerFallbackTest.java
+++ /dev/null
@@ -1,58 +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.quarkus.k.it;
-
-import java.util.Map;
-
-import io.quarkus.test.junit.QuarkusTestProfile;
-import io.restassured.path.json.JsonPath;
-import jakarta.ws.rs.core.MediaType;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-import static io.restassured.RestAssured.given;
-import static org.apache.camel.util.CollectionHelper.mapOf;
-import static org.assertj.core.api.Assertions.assertThat;
-
-@Disabled("https://github.com/apache/camel-quarkus/issues/5235")
-//@TestProfile(RuntimeCustomizerFallbackTest.Profile.class)
-//@QuarkusTest
-public class RuntimeCustomizerFallbackTest {
- @Test
- public void testContextCustomizerFromPropertiesFallback() {
- JsonPath p = given()
- .accept(MediaType.APPLICATION_JSON)
- .get("/camel-k/inspect/context")
- .then()
- .statusCode(200)
- .extract()
- .body()
- .jsonPath();
-
- assertThat(p.getBoolean("message-history")).isFalse();
- assertThat(p.getBoolean("load-type-converters")).isFalse();
- }
-
- public static class Profile implements QuarkusTestProfile {
- @Override
- public Map<String, String> getConfigOverrides() {
- return mapOf(
- "customizer.test.enabled", "true",
- "customizer.test.message-history", "false");
- }
- }
-}
diff --git a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeCustomizerIT.java b/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeCustomizerIT.java
deleted file mode 100644
index 991bc91f56..0000000000
--- a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeCustomizerIT.java
+++ /dev/null
@@ -1,23 +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.quarkus.k.it;
-
-import io.quarkus.test.junit.QuarkusIntegrationTest;
-
-@QuarkusIntegrationTest
-public class RuntimeCustomizerIT extends RuntimeCustomizerTest {
-}
diff --git a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeCustomizerTest.java b/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeCustomizerTest.java
deleted file mode 100644
index 6560a9f224..0000000000
--- a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeCustomizerTest.java
+++ /dev/null
@@ -1,58 +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.quarkus.k.it;
-
-import java.util.Map;
-
-import io.quarkus.test.junit.QuarkusTestProfile;
-import io.restassured.path.json.JsonPath;
-import jakarta.ws.rs.core.MediaType;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-import static io.restassured.RestAssured.given;
-import static org.apache.camel.util.CollectionHelper.mapOf;
-import static org.assertj.core.api.Assertions.assertThat;
-
-@Disabled("https://github.com/apache/camel-quarkus/issues/5235")
-//@TestProfile(RuntimeCustomizerTest.Profile.class)
-//@QuarkusTest
-public class RuntimeCustomizerTest {
- @Test
- public void testContextCustomizerFromProperties() {
- JsonPath p = given()
- .accept(MediaType.APPLICATION_JSON)
- .get("/camel-k/inspect/context")
- .then()
- .statusCode(200)
- .extract()
- .body()
- .jsonPath();
-
- assertThat(p.getBoolean("message-history")).isFalse();
- assertThat(p.getBoolean("load-type-converters")).isFalse();
- }
-
- public static class Profile implements QuarkusTestProfile {
- @Override
- public Map<String, String> getConfigOverrides() {
- return mapOf(
- "camel.k.customizer.test.enabled", "true",
- "camel.k.customizer.test.message-history", "false");
- }
- }
-}
diff --git a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeTest.java b/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeTest.java
index 7b527a3ed2..65fb19af80 100644
--- a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeTest.java
+++ b/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeTest.java
@@ -25,14 +25,14 @@ import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Comparator;
import java.util.Map;
+import java.util.Objects;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.path.json.JsonPath;
import jakarta.ws.rs.core.MediaType;
-import org.apache.camel.quarkus.core.FastCamelContext;
-import org.apache.camel.quarkus.k.runtime.Application;
+import org.apache.camel.quarkus.k.runtime.ApplicationConstants;
import org.apache.camel.quarkus.k.runtime.ApplicationModelReifierFactory;
import org.junit.jupiter.api.Test;
@@ -54,42 +54,59 @@ public class RuntimeTest {
.body()
.jsonPath();
- assertThat(p.getString("camel-context"))
- .isEqualTo(FastCamelContext.class.getName());
- assertThat(p.getString("camel-k-runtime"))
- .isEqualTo(Application.Runtime.class.getName());
- assertThat(p.getString("routes-collector"))
- .isEqualTo(Application.NoRoutesCollector.class.getName());
assertThat(p.getString("model-reifier-factory"))
.isEqualTo(ApplicationModelReifierFactory.class.getName());
}
+ @Test
+ public void properties() {
+ given().get("/camel-k/property/my-property").then().statusCode(200).body(is("my-test-value"));
+ given().get("/camel-k/property/root.key").then().statusCode(200).body(is("root.value"));
+ given().get("/camel-k/property/001.key").then().statusCode(200).body(is("001.value"));
+ given().get("/camel-k/property/002.key").then().statusCode(200).body(is("002.value"));
+ given().get("/camel-k/property/a.key").then().statusCode(200).body(is("a.root"));
+ given().get("/camel-k/property/flat-property").then().statusCode(200).body(is("flat-value"));
+ }
+
public static class Resources implements QuarkusTestResourceLifecycleManager {
private static final Path TEMP_DIR = Paths.get("target/test-classes/camel-k-runtime"); // Specify your temporary directory here
@Override
public Map<String, String> start() {
Path confd = TEMP_DIR.resolve("conf.d");
+ Path cfgmaps = confd.resolve("_configmaps");
+
+ try {
+ Files.createDirectories(cfgmaps);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
for (int i = 1; i <= 3; i++) {
String path = String.format("00%d", i);
- Path confdSubDir = confd.resolve(path);
- confdSubDir.toFile().mkdirs();
+ Path confdSubDir = cfgmaps.resolve(path);
+
+ try {
+ Files.createDirectories(confdSubDir);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
String file = i < 3 ? "conf.properties" : "flat-property";
- copyResourceToTemp("conf.d/" + path + "/" + file, confdSubDir.resolve(file).toAbsolutePath());
+ copyResourceToTemp("conf.d/_configmaps/" + path + "/" + file, confdSubDir.resolve(file).toAbsolutePath());
}
Path confProperties = TEMP_DIR.resolve("conf.properties");
copyResourceToTemp("conf.properties", confProperties.toAbsolutePath());
return Map.of(
- "CAMEL_K_CONF", confProperties.toAbsolutePath().toString(),
- "CAMEL_K_CONF_D", confd.toAbsolutePath().toString());
+ ApplicationConstants.PROPERTY_CAMEL_K_CONF, confProperties.toAbsolutePath().toString(),
+ ApplicationConstants.PROPERTY_CAMEL_K_CONF_D, confd.toAbsolutePath().toString());
}
private void copyResourceToTemp(String resourceName, Path destination) {
try (InputStream stream = getClass().getClassLoader().getResourceAsStream(resourceName)) {
+ Objects.requireNonNull(stream);
Files.copy(stream, destination, StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
throw new RuntimeException("Failed to copy resource " + resourceName + " to temporary directory", e);
@@ -108,14 +125,4 @@ public class RuntimeTest {
}
}
}
-
- @Test
- public void properties() {
- given().get("/camel-k/property/my-property").then().statusCode(200).body(is("my-test-value"));
- given().get("/camel-k/property/root.key").then().statusCode(200).body(is("root.value"));
- given().get("/camel-k/property/001.key").then().statusCode(200).body(is("001.value"));
- given().get("/camel-k/property/002.key").then().statusCode(200).body(is("002.value"));
- given().get("/camel-k/property/a.key").then().statusCode(200).body(is("a.002"));
- given().get("/camel-k/property/flat-property").then().statusCode(200).body(is("flat-value"));
- }
}
diff --git a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeWithXmlTest.java b/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeWithXmlTest.java
index 30d2c66e72..10a3766ae0 100644
--- a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeWithXmlTest.java
+++ b/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeWithXmlTest.java
@@ -16,19 +16,11 @@
*/
package org.apache.camel.quarkus.k.it;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.Comparator;
import java.util.Map;
-import io.quarkus.test.common.QuarkusTestResource;
-import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.QuarkusTestProfile;
+import io.quarkus.test.junit.TestProfile;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import jakarta.ws.rs.core.MediaType;
@@ -37,13 +29,13 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@QuarkusTest
-@QuarkusTestResource(RuntimeWithXmlTest.Resources.class)
+@TestProfile(RuntimeWithXmlTest.Profile.class)
public class RuntimeWithXmlTest {
@Test
public void inspect() {
JsonPath p = RestAssured.given()
.accept(MediaType.APPLICATION_JSON)
- .get("/camel-k/runtime/inspect")
+ .get("/camel-k/inspect")
.then()
.statusCode(200)
.extract()
@@ -56,55 +48,21 @@ public class RuntimeWithXmlTest {
.contains("xml-rest-greetings");
}
- public static class Resources implements QuarkusTestResourceLifecycleManager {
- private static final Path TEMP_DIR = Paths.get("target/test-classes/camel-k-runtime-xml"); // Specify your temporary directory here
-
+ public static class Profile implements QuarkusTestProfile {
@Override
- public Map<String, String> start() {
- // Create the temporary directory if it doesn't exist
- File tempDir = TEMP_DIR.toFile();
- tempDir.mkdirs();
-
- // Copy the XML files from the classpath to the temporary directory
- copyResourceToTemp("routes.xml");
- copyResourceToTemp("rests.xml");
- copyResourceToTemp("routes-with-expression.xml");
-
- // Set the path to the temporary directory
- final String res = tempDir.getAbsolutePath();
+ public Map<String, String> getConfigOverrides() {
// Return the configuration
return Map.of(
// sources
- "camel.k.sources[0].location", "file:" + res + "/routes.xml",
- "camel.k.sources[0].type", "source",
- "camel.k.sources[1].location", "file:" + res + "/rests.xml",
- "camel.k.sources[1].type", "source",
- "camel.k.sources[2].location", "file:" + res + "/routes-with-expression.xml",
- "camel.k.sources[2].type", "source",
+ "camel.main.routes-include-pattern", String.join(
+ ",",
+ "classpath:routes/routes.xml",
+ "classpath:routes/rests.xml",
+ "classpath:routes/routes-with-expression.xml"),
// misc
"the.body", "10");
}
- private void copyResourceToTemp(String resourceName) {
- try (InputStream stream = getClass().getClassLoader().getResourceAsStream(resourceName)) {
- Path tempPath = TEMP_DIR.resolve(resourceName);
- Files.copy(stream, tempPath, StandardCopyOption.REPLACE_EXISTING);
- } catch (Exception e) {
- throw new RuntimeException("Failed to copy resource " + resourceName + " to temporary directory", e);
- }
- }
-
- @Override
- public void stop() {
- try {
- Files.walk(TEMP_DIR)
- .sorted(Comparator.reverseOrder())
- .map(Path::toFile)
- .forEach(File::delete);
- } catch (IOException e) {
- // Ignored
- }
- }
}
}
diff --git a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeWithYamlTest.java b/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeWithYamlTest.java
index a04e5186e0..49fd629270 100644
--- a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeWithYamlTest.java
+++ b/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/RuntimeWithYamlTest.java
@@ -16,19 +16,11 @@
*/
package org.apache.camel.quarkus.k.it;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.Comparator;
import java.util.Map;
-import io.quarkus.test.common.QuarkusTestResource;
-import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.QuarkusTestProfile;
+import io.quarkus.test.junit.TestProfile;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.quarkus.k.it.yaml.MyProcessor;
import org.junit.jupiter.api.Test;
@@ -39,73 +31,39 @@ import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
@QuarkusTest
-@QuarkusTestResource(RuntimeWithYamlTest.Resources.class)
+@TestProfile(RuntimeWithYamlTest.Profile.class)
public class RuntimeWithYamlTest {
@Test
public void inspect() {
given()
.accept(MediaType.APPLICATION_JSON)
- .get("/camel-k/runtime/inspect")
+ .get("/camel-k/inspect")
.then()
.statusCode(200)
.body("route-definitions", hasItem("my-yaml-route"));
given()
.accept(MediaType.APPLICATION_JSON)
- .get("/camel-k/runtime/registry/beans/my-bean")
+ .get("/camel-k/registry/beans/my-bean")
.then()
.statusCode(200)
.body("name", is("my-bean-name"));
given()
.accept(MediaType.APPLICATION_JSON)
- .get("/camel-k/runtime/registry/beans/myProcessor")
+ .get("/camel-k/registry/beans/myProcessor")
.then()
.statusCode(200);
}
- public static class Resources implements QuarkusTestResourceLifecycleManager {
- private static final Path TEMP_DIR = Paths.get("target/test-classes/camel-k-runtime-yaml"); // Specify your temporary directory here
-
+ public static class Profile implements QuarkusTestProfile {
@Override
- public Map<String, String> start() {
- // Create the temporary directory if it doesn't exist
- File tempDir = TEMP_DIR.toFile();
- tempDir.mkdirs();
-
- // Copy the XML files from the classpath to the temporary directory
- copyResourceToTemp("routes-with-beans.yaml");
-
- // Set the path to the temporary directory
- final String res = tempDir.getAbsolutePath();
-
+ public Map<String, String> getConfigOverrides() {
return mapOf(
// sources
- "camel.k.sources[3].location", "file:" + res + "/routes-with-beans.yaml",
- "camel.k.sources[3].type", "source",
+ "camel.main.routes-include-pattern", "classpath:routes/routes-with-beans.yaml",
// misc
"camel.beans.myProcessor", "#class:" + MyProcessor.class.getName());
}
-
- private void copyResourceToTemp(String resourceName) {
- try (InputStream stream = getClass().getClassLoader().getResourceAsStream(resourceName)) {
- Path tempPath = TEMP_DIR.resolve(resourceName);
- Files.copy(stream, tempPath, StandardCopyOption.REPLACE_EXISTING);
- } catch (Exception e) {
- throw new RuntimeException("Failed to copy resource " + resourceName + " to temporary directory", e);
- }
- }
-
- @Override
- public void stop() {
- try {
- Files.walk(TEMP_DIR)
- .sorted(Comparator.reverseOrder())
- .map(Path::toFile)
- .forEach(File::delete);
- } catch (IOException e) {
- // Ignored
- }
- }
}
}
diff --git a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/TestCustomizer.java b/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/TestCustomizer.java
deleted file mode 100644
index c02e079756..0000000000
--- a/integration-tests/camel-k-runtime/src/test/java/org/apache/camel/quarkus/k/it/TestCustomizer.java
+++ /dev/null
@@ -1,50 +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.quarkus.k.it;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.impl.engine.ExplicitCamelContextNameStrategy;
-import org.apache.camel.spi.CamelContextCustomizer;
-
-public class TestCustomizer implements CamelContextCustomizer {
-
- private String name;
- private boolean messageHistory = true;
-
- public TestCustomizer() {
- this("default");
- }
-
- public TestCustomizer(String name) {
- this.name = name;
- }
-
- public boolean isMessageHistory() {
- return messageHistory;
- }
-
- public void setMessageHistory(boolean messageHistory) {
- this.messageHistory = messageHistory;
- }
-
- @Override
- public void configure(CamelContext camelContext) {
- camelContext.setNameStrategy(new ExplicitCamelContextNameStrategy(name));
- camelContext.setMessageHistory(messageHistory);
- camelContext.setLoadTypeConverters(false);
- }
-}
diff --git a/integration-tests/camel-k-runtime/src/test/resources/META-INF/services/org.apache.camel.quarkus.k/customizer/test b/integration-tests/camel-k-runtime/src/test/resources/META-INF/services/org.apache.camel.quarkus.k/customizer/test
deleted file mode 100644
index ea826819d6..0000000000
--- a/integration-tests/camel-k-runtime/src/test/resources/META-INF/services/org.apache.camel.quarkus.k/customizer/test
+++ /dev/null
@@ -1,18 +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.
-#
-
-class=org.apache.camel.quarkus.k.it.TestCustomizer
\ No newline at end of file
diff --git a/integration-tests/camel-k-runtime/src/test/resources/conf.d/001/conf.properties b/integration-tests/camel-k-runtime/src/test/resources/conf.d/_configmaps/001/conf.properties
similarity index 100%
rename from integration-tests/camel-k-runtime/src/test/resources/conf.d/001/conf.properties
rename to integration-tests/camel-k-runtime/src/test/resources/conf.d/_configmaps/001/conf.properties
diff --git a/integration-tests/camel-k-runtime/src/test/resources/conf.d/002/conf.properties b/integration-tests/camel-k-runtime/src/test/resources/conf.d/_configmaps/002/conf.properties
similarity index 100%
rename from integration-tests/camel-k-runtime/src/test/resources/conf.d/002/conf.properties
rename to integration-tests/camel-k-runtime/src/test/resources/conf.d/_configmaps/002/conf.properties
diff --git a/integration-tests/camel-k-runtime/src/test/resources/conf.d/003/flat-property b/integration-tests/camel-k-runtime/src/test/resources/conf.d/_configmaps/003/flat-property
similarity index 100%
rename from integration-tests/camel-k-runtime/src/test/resources/conf.d/003/flat-property
rename to integration-tests/camel-k-runtime/src/test/resources/conf.d/_configmaps/003/flat-property
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index f1b7407186..1c4744b6a4 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -71,6 +71,7 @@
<module>caffeine</module>
<module>camel-k-runtime</module>
<module>camel-k-runtime-model-reifier</module>
+ <module>camel-k-runtime-shutdown</module>
<module>cassandraql</module>
<module>cbor</module>
<module>compression-grouped</module>
diff --git a/poms/bom-test/pom.xml b/poms/bom-test/pom.xml
index 59202140a2..447f8228c0 100644
--- a/poms/bom-test/pom.xml
+++ b/poms/bom-test/pom.xml
@@ -132,16 +132,6 @@
<artifactId>camel-quarkus-integration-tests-support-azure</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-integration-test-support-camel-k-loader-inspector</artifactId>
- <version>${camel-quarkus.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-integration-test-support-camel-k-runtime-inspector</artifactId>
- <version>${camel-quarkus.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-jdbc</artifactId>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 23a9a75125..f2c2cf2988 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -6596,31 +6596,6 @@
<artifactId>avro-ipc-netty</artifactId>
<version>${avro.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.groovy</groupId>
- <artifactId>groovy</artifactId>
- <version>${groovy.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.groovy</groupId>
- <artifactId>groovy-json</artifactId>
- <version>${groovy.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.groovy</groupId>
- <artifactId>groovy-test</artifactId>
- <version>${groovy.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.groovy</groupId>
- <artifactId>groovy-xml</artifactId>
- <version>${groovy.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.groovy</groupId>
- <artifactId>groovy-yaml</artifactId>
- <version>${groovy.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml
index 834a19e390..6335aa1bc5 100644
--- a/poms/bom/src/main/generated/flattened-full-pom.xml
+++ b/poms/bom/src/main/generated/flattened-full-pom.xml
@@ -6519,31 +6519,6 @@
<artifactId>avro-ipc-netty</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<version>1.11.3</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
</dependency>
- <dependency>
- <groupId>org.apache.groovy</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <artifactId>groovy</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <version>4.0.18</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- </dependency>
- <dependency>
- <groupId>org.apache.groovy</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <artifactId>groovy-json</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <version>4.0.18</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- </dependency>
- <dependency>
- <groupId>org.apache.groovy</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <artifactId>groovy-test</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <version>4.0.18</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- </dependency>
- <dependency>
- <groupId>org.apache.groovy</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <artifactId>groovy-xml</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <version>4.0.18</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- </dependency>
- <dependency>
- <groupId>org.apache.groovy</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <artifactId>groovy-yaml</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <version>4.0.18</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- </dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<artifactId>httpclient5</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
@@ -7470,6 +7445,11 @@
<artifactId>cxf-tools-wsdlto-frontend-jaxws</artifactId><!-- io.quarkiverse.cxf:quarkus-cxf-bom:3.8.0 -->
<version>4.0.3</version><!-- io.quarkiverse.cxf:quarkus-cxf-bom:3.8.0 -->
</dependency>
+ <dependency>
+ <groupId>org.apache.groovy</groupId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ <artifactId>groovy</artifactId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ <version>4.0.18</version><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ </dependency>
<dependency>
<groupId>org.apache.groovy</groupId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
<artifactId>groovy-ant</artifactId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
@@ -7535,6 +7515,11 @@
<artifactId>groovy-jmx</artifactId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
<version>4.0.18</version><!-- org.apache.groovy:groovy-bom:4.0.18 -->
</dependency>
+ <dependency>
+ <groupId>org.apache.groovy</groupId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ <artifactId>groovy-json</artifactId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ <version>4.0.18</version><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ </dependency>
<dependency>
<groupId>org.apache.groovy</groupId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
<artifactId>groovy-jsr223</artifactId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
@@ -7575,6 +7560,11 @@
<artifactId>groovy-templates</artifactId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
<version>4.0.18</version><!-- org.apache.groovy:groovy-bom:4.0.18 -->
</dependency>
+ <dependency>
+ <groupId>org.apache.groovy</groupId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ <artifactId>groovy-test</artifactId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ <version>4.0.18</version><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ </dependency>
<dependency>
<groupId>org.apache.groovy</groupId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
<artifactId>groovy-test-junit5</artifactId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
@@ -7595,6 +7585,16 @@
<artifactId>groovy-typecheckers</artifactId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
<version>4.0.18</version><!-- org.apache.groovy:groovy-bom:4.0.18 -->
</dependency>
+ <dependency>
+ <groupId>org.apache.groovy</groupId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ <artifactId>groovy-xml</artifactId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ <version>4.0.18</version><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ </dependency>
+ <dependency>
+ <groupId>org.apache.groovy</groupId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ <artifactId>groovy-yaml</artifactId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ <version>4.0.18</version><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ </dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId><!-- software.amazon.awssdk:bom:2.24.9 -->
<artifactId>codegen-lite-maven-plugin</artifactId><!-- software.amazon.awssdk:bom:2.24.9 -->
diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml b/poms/bom/src/main/generated/flattened-reduced-pom.xml
index 40962381f8..b6163c2bfd 100644
--- a/poms/bom/src/main/generated/flattened-reduced-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml
@@ -6459,11 +6459,6 @@
<artifactId>antlr-runtime</artifactId>
<version>3.5.2</version>
</dependency>
- <dependency>
- <groupId>org.apache.groovy</groupId>
- <artifactId>groovy</artifactId>
- <version>4.0.18</version>
- </dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
@@ -7330,6 +7325,11 @@
<artifactId>cxf-tools-wsdlto-frontend-jaxws</artifactId>
<version>4.0.3</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.groovy</groupId>
+ <artifactId>groovy</artifactId>
+ <version>4.0.18</version>
+ </dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>annotations</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
index f764381d2d..4556c4b856 100644
--- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
@@ -6459,11 +6459,6 @@
<artifactId>antlr-runtime</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<version>3.5.2</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
</dependency>
- <dependency>
- <groupId>org.apache.groovy</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <artifactId>groovy</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <version>4.0.18</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- </dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<artifactId>httpclient5</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
@@ -7330,6 +7325,11 @@
<artifactId>cxf-tools-wsdlto-frontend-jaxws</artifactId><!-- io.quarkiverse.cxf:quarkus-cxf-bom:3.8.0 -->
<version>4.0.3</version><!-- io.quarkiverse.cxf:quarkus-cxf-bom:3.8.0 -->
</dependency>
+ <dependency>
+ <groupId>org.apache.groovy</groupId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ <artifactId>groovy</artifactId><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ <version>4.0.18</version><!-- org.apache.groovy:groovy-bom:4.0.18 -->
+ </dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId><!-- software.amazon.awssdk:bom:2.24.9 -->
<artifactId>annotations</artifactId><!-- software.amazon.awssdk:bom:2.24.9 -->
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index d1400f4f66..c9e97cce1c 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -210,6 +210,7 @@ group-13:
- box
- camel-k-runtime
- camel-k-runtime-model-reifier
+ - camel-k-runtime-shutdown
- fhir
- github
- google
diff --git a/tooling/test-list/pom.xml b/tooling/test-list/pom.xml
index 9cbf3efc72..e854f003cf 100644
--- a/tooling/test-list/pom.xml
+++ b/tooling/test-list/pom.xml
@@ -65,6 +65,7 @@
<exclude>main-unknown-args-ignore/pom.xml</exclude>
<exclude>messaging/pom.xml</exclude>
<exclude>quartz-clustered/pom.xml</exclude>
+ <exclude>camel-k-runtime-shutdown/pom.xml</exclude>
</excludes>
</fileSet>
</fileSets>