You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2020/09/22 13:26:24 UTC
[camel-k-runtime] branch master updated: Failed to start Kamelet
#493
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
The following commit(s) were added to refs/heads/master by this push:
new dcf99c9 Failed to start Kamelet #493
dcf99c9 is described below
commit dcf99c97c41d2534aa310ef6c2454e6fcaabd736
Author: Luca Burgazzoli <lb...@gmail.com>
AuthorDate: Tue Sep 22 13:32:27 2020 +0200
Failed to start Kamelet #493
---
.github/workflows/ci-build.yml | 1 +
.../quarkus/deployment/DeploymentProcessor.java | 10 --
.../k/core/quarkus/deployment/Application.java | 7 -
.../camel/k/core/quarkus/deployment/CoreTest.java | 11 --
.../camel/k/loader/java/quarkus/Application.java | 8 +
.../camel/k/loader/java/java/JavaLoaderTest.java | 13 ++
.../camel-k-quarkus-itests-runtime-kamelet/pom.xml | 167 +++++++++++++++++++++
.../apache/camel/k/quarkus/it}/Application.java | 23 ++-
.../src/main/resources/application.properties | 23 +++
.../org/apache/camel/k/quarkus/it/RuntimeIT.java | 23 +++
.../apache/camel/k/quarkus/it/RuntimeTest.java} | 36 +----
.../src/test/resources/routes.properties | 30 ++++
.../src/test/resources/routes/route.yaml | 21 +++
.../src/test/resources/routes/set-body.yaml | 22 +++
camel-k-quarkus/camel-k-quarkus-itests/pom.xml | 3 +-
.../deployment/JavaSourceLoaderProcessor.java} | 30 ++--
.../java/quarkus/JavaSourceLoaderRecorder.java} | 4 +-
.../org/apache/camel/k/support/SourcesSupport.java | 48 +++---
18 files changed, 362 insertions(+), 118 deletions(-)
diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml
index f7e591d..7a0dc49 100644
--- a/.github/workflows/ci-build.yml
+++ b/.github/workflows/ci-build.yml
@@ -111,6 +111,7 @@ jobs:
native-image-project:
- :camel-k-quarkus-itests-core
- :camel-k-quarkus-itests-runtime
+ - :camel-k-quarkus-itests-runtime-kamelet
- :camel-k-quarkus-itests-cron
- :camel-k-quarkus-itests-master
- :camel-k-quarkus-itests-kamelet
diff --git a/camel-k-quarkus/camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus/deployment/DeploymentProcessor.java b/camel-k-quarkus/camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus/deployment/DeploymentProcessor.java
index d34c875..c89b608 100644
--- a/camel-k-quarkus/camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus/deployment/DeploymentProcessor.java
+++ b/camel-k-quarkus/camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus/deployment/DeploymentProcessor.java
@@ -21,8 +21,6 @@ import java.util.stream.Collectors;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
-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;
@@ -30,8 +28,6 @@ import org.apache.camel.k.Constants;
import org.apache.camel.k.ContextCustomizer;
import org.apache.camel.k.SourceDefinition;
import org.apache.camel.k.SourceLoader;
-import org.apache.camel.k.core.quarkus.RuntimeRecorder;
-import org.apache.camel.quarkus.core.deployment.spi.CamelContextCustomizerBuildItem;
import org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination;
import org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem;
import org.apache.camel.spi.StreamCachingStrategy;
@@ -99,10 +95,4 @@ public class DeploymentProcessor {
StreamCachingStrategy.SpoolRule.class)
);
}
-
- @Record(ExecutionTime.STATIC_INIT)
- @BuildStep
- void customizeContext(RuntimeRecorder recorder, BuildProducer<CamelContextCustomizerBuildItem> customizers) {
- customizers.produce(new CamelContextCustomizerBuildItem(recorder.registerCompositeClassLoader()));
- }
}
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/main/java/org/apache/camel/k/core/quarkus/deployment/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/main/java/org/apache/camel/k/core/quarkus/deployment/Application.java
index cba95a2..78e00f5 100644
--- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/main/java/org/apache/camel/k/core/quarkus/deployment/Application.java
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/main/java/org/apache/camel/k/core/quarkus/deployment/Application.java
@@ -51,11 +51,4 @@ public class Application {
.add("services", builder)
.build();
}
-
- @GET
- @Path("/application-classloader")
- @Produces(MediaType.TEXT_PLAIN)
- public String getApplicationClassloader() {
- return camelContext.getApplicationContextClassLoader().getClass().getName();
- }
}
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/test/java/org/apache/camel/k/core/quarkus/deployment/CoreTest.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/test/java/org/apache/camel/k/core/quarkus/deployment/CoreTest.java
index cd3e13b..0b5f77a 100644
--- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/test/java/org/apache/camel/k/core/quarkus/deployment/CoreTest.java
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/test/java/org/apache/camel/k/core/quarkus/deployment/CoreTest.java
@@ -48,15 +48,4 @@ public class CoreTest {
SourcesConfigurer.class.getName()
);
}
-
- @DisabledOnNativeImage
- @Test
- public void testClassLoader() {
- RestAssured.given()
- .accept(MediaType.TEXT_PLAIN)
- .get("/test/application-classloader")
- .then()
- .statusCode(200)
- .body(is(CompositeClassloader.class.getName()));
- }
}
\ No newline at end of file
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/java/org/apache/camel/k/loader/java/quarkus/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/java/org/apache/camel/k/loader/java/quarkus/Application.java
index 3cd6dce..df7cac3 100644
--- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/java/org/apache/camel/k/loader/java/quarkus/Application.java
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/java/org/apache/camel/k/loader/java/quarkus/Application.java
@@ -19,6 +19,7 @@ package org.apache.camel.k.loader.java.quarkus;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.json.JsonObject;
+import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@@ -42,4 +43,11 @@ public class Application {
public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception {
return LoaderSupport.inspectSource(context, name, "java", code);
}
+
+ @GET
+ @Path("/application-classloader")
+ @Produces(MediaType.TEXT_PLAIN)
+ public String getApplicationClassloader() {
+ return context.getApplicationContextClassLoader().getClass().getName();
+ }
}
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/test/java/org/apache/camel/k/loader/java/java/JavaLoaderTest.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/test/java/org/apache/camel/k/loader/java/java/JavaLoaderTest.java
index 34a6e7c..65c8794 100644
--- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/test/java/org/apache/camel/k/loader/java/java/JavaLoaderTest.java
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/test/java/org/apache/camel/k/loader/java/java/JavaLoaderTest.java
@@ -25,10 +25,12 @@ import io.quarkus.test.junit.DisabledOnNativeImage;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
+import org.apache.camel.k.CompositeClassloader;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.hamcrest.Matchers.is;
@DisabledOnNativeImage
@QuarkusTest
@@ -56,4 +58,15 @@ public class JavaLoaderTest {
assertThat(p.getList("routes", String.class)).contains("java");
assertThat(p.getList("endpoints", String.class)).contains("direct://java", "log://java");
}
+
+ @DisabledOnNativeImage
+ @Test
+ public void testClassLoader() {
+ RestAssured.given()
+ .accept(MediaType.TEXT_PLAIN)
+ .get("/test/application-classloader")
+ .then()
+ .statusCode(200)
+ .body(is(CompositeClassloader.class.getName()));
+ }
}
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/pom.xml
new file mode 100644
index 0000000..a929068
--- /dev/null
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/pom.xml
@@ -0,0 +1,167 @@
+<?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.
+
+-->
+<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">
+ <parent>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-itests</artifactId>
+ <version>1.5.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-k-quarkus-itests-runtime-kamelet</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-runtime-quarkus</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-kamelet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-loader-yaml</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jsonb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jsonb</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</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>
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>${build-helper-maven-plugin-version}</version>
+ <executions>
+ <execution>
+ <id>reserve-network-port</id>
+ <goals>
+ <goal>reserve-network-port</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <portNames>
+ <portName>test.http.port.jvm</portName>
+ <portName>test.http.port.native</portName>
+ </portNames>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <version>${quarkus-version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <environmentVariables>
+ <ROUTES_DIR>${project.basedir}/src/test/resources/routes</ROUTES_DIR>
+ <CAMEL_K_CONF>${project.basedir}/src/test/resources/routes.properties</CAMEL_K_CONF>
+ </environmentVariables>
+ <systemProperties>
+ <quarkus.http.test-port>${test.http.port.jvm}</quarkus.http.test-port>
+ <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ </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>
+ <environmentVariables>
+ <ROUTES_DIR>${project.basedir}/src/test/resources/routes</ROUTES_DIR>
+ <CAMEL_K_CONF>${project.basedir}/src/test/resources/routes.properties</CAMEL_K_CONF>
+ </environmentVariables>
+ <systemProperties>
+ <quarkus.http.test-port>${test.http.port.native}</quarkus.http.test-port>
+ <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/java/org/apache/camel/k/loader/java/quarkus/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/main/java/org/apache/camel/k/quarkus/it/Application.java
similarity index 64%
copy from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/java/org/apache/camel/k/loader/java/quarkus/Application.java
copy to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/main/java/org/apache/camel/k/quarkus/it/Application.java
index 3cd6dce..d9f338f 100644
--- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-loader-java/src/main/java/org/apache/camel/k/loader/java/quarkus/Application.java
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/main/java/org/apache/camel/k/quarkus/it/Application.java
@@ -14,32 +14,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.k.loader.java.quarkus;
+package org.apache.camel.k.quarkus.it;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
-import javax.json.JsonObject;
-import javax.ws.rs.POST;
+import javax.ws.rs.GET;
import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
-import org.apache.camel.CamelContext;
-import org.apache.camel.Consume;
-import org.apache.camel.k.loader.support.LoaderSupport;
+import org.apache.camel.FluentProducerTemplate;
@Path("/test")
@ApplicationScoped
public class Application {
@Inject
- CamelContext context;
+ FluentProducerTemplate template;
- @POST
- @Path("/load-routes/{name}")
- @Consume(MediaType.TEXT_PLAIN)
- @Produces(MediaType.APPLICATION_JSON)
- public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception {
- return LoaderSupport.inspectSource(context, name, "java", code);
+ @GET
+ @Path("/execute")
+ @Produces(MediaType.TEXT_PLAIN)
+ public String execute() {
+ return template.to("direct:process").request(String.class);
}
}
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/main/resources/application.properties
new file mode 100644
index 0000000..5b8f41a
--- /dev/null
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/main/resources/application.properties
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# Quarkus
+#
+quarkus.log.console.enable = true
+quarkus.banner.enabled = false
+
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/java/org/apache/camel/k/quarkus/it/RuntimeIT.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/java/org/apache/camel/k/quarkus/it/RuntimeIT.java
new file mode 100644
index 0000000..29f1c17
--- /dev/null
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/java/org/apache/camel/k/quarkus/it/RuntimeIT.java
@@ -0,0 +1,23 @@
+/*
+ * 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.k.quarkus.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+public class RuntimeIT extends RuntimeTest {
+}
\ No newline at end of file
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/test/java/org/apache/camel/k/core/quarkus/deployment/CoreTest.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/java/org/apache/camel/k/quarkus/it/RuntimeTest.java
similarity index 52%
copy from camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/test/java/org/apache/camel/k/core/quarkus/deployment/CoreTest.java
copy to camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/java/org/apache/camel/k/quarkus/it/RuntimeTest.java
index cd3e13b..1b74c43 100644
--- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-core/src/test/java/org/apache/camel/k/core/quarkus/deployment/CoreTest.java
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/java/org/apache/camel/k/quarkus/it/RuntimeTest.java
@@ -14,49 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.k.core.quarkus.deployment;
+package org.apache.camel.k.quarkus.it;
import javax.ws.rs.core.MediaType;
-import io.quarkus.test.junit.DisabledOnNativeImage;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
-import io.restassured.path.json.JsonPath;
-import org.apache.camel.k.CompositeClassloader;
-import org.apache.camel.k.listener.ContextConfigurer;
-import org.apache.camel.k.listener.SourcesConfigurer;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
@QuarkusTest
-public class CoreTest {
+public class RuntimeTest {
@Test
- public void testServices() {
- JsonPath p = RestAssured.given()
- .accept(MediaType.APPLICATION_JSON)
- .get("/test/services")
- .then()
- .statusCode(200)
- .extract()
- .body()
- .jsonPath();
-
- assertThat(p.getList("services", String.class)).contains(
- ContextConfigurer.class.getName(),
- SourcesConfigurer.class.getName()
- );
- }
-
- @DisabledOnNativeImage
- @Test
- public void testClassLoader() {
+ public void invoke() {
RestAssured.given()
.accept(MediaType.TEXT_PLAIN)
- .get("/test/application-classloader")
+ .get("/test/execute")
.then()
- .statusCode(200)
- .body(is(CompositeClassloader.class.getName()));
+ .statusCode(200)
+ .body(is("template"));
}
}
\ No newline at end of file
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/resources/routes.properties b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/resources/routes.properties
new file mode 100644
index 0000000..19f71fb
--- /dev/null
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/resources/routes.properties
@@ -0,0 +1,30 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+
+#
+# camel-k - sources (templates)
+#
+camel.k.sources[0].location = file:{{env:ROUTES_DIR}}/set-body.yaml
+camel.k.sources[0].type = template
+camel.k.sources[0].property-names[0] = bodyValue
+
+#
+# camel-k - sources (routes)
+#
+camel.k.sources[1].location = file:{{env:ROUTES_DIR}}/route.yaml
+camel.k.sources[1].type = source
\ No newline at end of file
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/resources/routes/route.yaml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/resources/routes/route.yaml
new file mode 100644
index 0000000..41f648a
--- /dev/null
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/resources/routes/route.yaml
@@ -0,0 +1,21 @@
+#
+# 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:
+ uri: "direct:process"
+ steps:
+ - to: "kamelet:set-body?bodyValue=template"
\ No newline at end of file
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/resources/routes/set-body.yaml b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/resources/routes/set-body.yaml
new file mode 100644
index 0000000..55347e9
--- /dev/null
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime-kamelet/src/test/resources/routes/set-body.yaml
@@ -0,0 +1,22 @@
+#
+# 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:
+ uri: "direct:{{routeId}}"
+ steps:
+ - set-body:
+ constant: "{{bodyValue}}"
\ No newline at end of file
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/pom.xml b/camel-k-quarkus/camel-k-quarkus-itests/pom.xml
index dd4ddf1..e75e73e 100644
--- a/camel-k-quarkus/camel-k-quarkus-itests/pom.xml
+++ b/camel-k-quarkus/camel-k-quarkus-itests/pom.xml
@@ -30,7 +30,6 @@
<modules>
<module>camel-k-quarkus-itests-core</module>
- <module>camel-k-quarkus-itests-runtime</module>
<module>camel-k-quarkus-itests-cron</module>
<module>camel-k-quarkus-itests-master</module>
<module>camel-k-quarkus-itests-kamelet</module>
@@ -43,6 +42,8 @@
<module>camel-k-quarkus-itests-loader-xml</module>
<module>camel-k-quarkus-itests-loader-yaml</module>
<module>camel-k-quarkus-itests-polyglot</module>
+ <module>camel-k-quarkus-itests-runtime</module>
+ <module>camel-k-quarkus-itests-runtime-kamelet</module>
</modules>
</project>
diff --git a/camel-k-quarkus/camel-k-quarkus-core/runtime/src/main/java/org/apache/camel/k/core/quarkus/RuntimeRecorder.java b/camel-k-quarkus/camel-k-quarkus-loader-java/deployment/src/main/java/org/apache/camel/k/loader/java/quarkus/deployment/JavaSourceLoaderProcessor.java
similarity index 50%
copy from camel-k-quarkus/camel-k-quarkus-core/runtime/src/main/java/org/apache/camel/k/core/quarkus/RuntimeRecorder.java
copy to camel-k-quarkus/camel-k-quarkus-loader-java/deployment/src/main/java/org/apache/camel/k/loader/java/quarkus/deployment/JavaSourceLoaderProcessor.java
index aae6a37..29da5d4 100644
--- a/camel-k-quarkus/camel-k-quarkus-core/runtime/src/main/java/org/apache/camel/k/core/quarkus/RuntimeRecorder.java
+++ b/camel-k-quarkus/camel-k-quarkus-loader-java/deployment/src/main/java/org/apache/camel/k/loader/java/quarkus/deployment/JavaSourceLoaderProcessor.java
@@ -14,25 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.k.core.quarkus;
+package org.apache.camel.k.loader.java.quarkus.deployment;
-import io.quarkus.runtime.RuntimeValue;
-import io.quarkus.runtime.annotations.Recorder;
-import org.apache.camel.CamelContext;
-import org.apache.camel.k.CompositeClassloader;
-import org.apache.camel.quarkus.core.CamelContextCustomizer;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
+import org.apache.camel.k.loader.java.quarkus.JavaSourceLoaderRecorder;
+import org.apache.camel.quarkus.core.deployment.spi.CamelContextCustomizerBuildItem;
-@Recorder
-public class RuntimeRecorder {
- public RuntimeValue<CamelContextCustomizer> registerCompositeClassLoader() {
- return new RuntimeValue<>(new CamelContextCustomizer() {
- @Override
- public void customize(CamelContext context) {
- final ClassLoader oldLoader = context.getApplicationContextClassLoader();
- final ClassLoader newLoader = CompositeClassloader.wrap(oldLoader);
-
- context.setApplicationContextClassLoader(newLoader);
- }
- });
+public class JavaSourceLoaderProcessor {
+ @Record(ExecutionTime.STATIC_INIT)
+ @BuildStep
+ void customizeContext(JavaSourceLoaderRecorder recorder, BuildProducer<CamelContextCustomizerBuildItem> customizers) {
+ customizers.produce(new CamelContextCustomizerBuildItem(recorder.registerCompositeClassLoader()));
}
}
diff --git a/camel-k-quarkus/camel-k-quarkus-core/runtime/src/main/java/org/apache/camel/k/core/quarkus/RuntimeRecorder.java b/camel-k-quarkus/camel-k-quarkus-loader-java/runtime/src/main/java/org/apache/camel/k/loader/java/quarkus/JavaSourceLoaderRecorder.java
similarity index 94%
rename from camel-k-quarkus/camel-k-quarkus-core/runtime/src/main/java/org/apache/camel/k/core/quarkus/RuntimeRecorder.java
rename to camel-k-quarkus/camel-k-quarkus-loader-java/runtime/src/main/java/org/apache/camel/k/loader/java/quarkus/JavaSourceLoaderRecorder.java
index aae6a37..78d36e8 100644
--- a/camel-k-quarkus/camel-k-quarkus-core/runtime/src/main/java/org/apache/camel/k/core/quarkus/RuntimeRecorder.java
+++ b/camel-k-quarkus/camel-k-quarkus-loader-java/runtime/src/main/java/org/apache/camel/k/loader/java/quarkus/JavaSourceLoaderRecorder.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.k.core.quarkus;
+package org.apache.camel.k.loader.java.quarkus;
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.annotations.Recorder;
@@ -23,7 +23,7 @@ import org.apache.camel.k.CompositeClassloader;
import org.apache.camel.quarkus.core.CamelContextCustomizer;
@Recorder
-public class RuntimeRecorder {
+public class JavaSourceLoaderRecorder {
public RuntimeValue<CamelContextCustomizer> registerCompositeClassLoader() {
return new RuntimeValue<>(new CamelContextCustomizer() {
@Override
diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/SourcesSupport.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/SourcesSupport.java
index 88dda22..971e796 100644
--- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/SourcesSupport.java
+++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/SourcesSupport.java
@@ -128,32 +128,30 @@ public final class SourcesSupport {
new SourceLoader.Interceptor() {
@Override
public RoutesBuilder afterLoad(SourceLoader loader, Source source, RoutesBuilder builder) {
- return SourcesSupport.afterConfigure(builder, rb -> {
- rb.addLifecycleInterceptor(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, got " + routes.size());
- }
- if (!templates.isEmpty()) {
- throw new IllegalArgumentException("There should not be any template, 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();
+ return SourcesSupport.afterConfigure(
+ builder,
+ rb -> {
+ List<RouteDefinition> routes = rb.getRouteCollection().getRoutes();
+ List<RouteTemplateDefinition> templates = rb.getRouteTemplateCollection().getRouteTemplates();
+
+ if (routes.size() != 1) {
+ throw new IllegalArgumentException("There should be a single route definition, got " + routes.size());
}
- });
- });
+ if (!templates.isEmpty()) {
+ throw new IllegalArgumentException("There should not be any template, got " + templates.size());
+ }
+
+ // create a new template from the source
+ RouteTemplateDefinition templatesDefinition = rb.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();
+ }
+ );
}
}
);