You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ji...@apache.org on 2023/09/21 14:55:27 UTC
[camel-quarkus] branch camel-main updated (b2d0a89921 -> edc1dcb822)
This is an automated email from the ASF dual-hosted git repository.
jiriondrusek pushed a change to branch camel-main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
from b2d0a89921 Add initial support for request validation in rest-openapi extension
new 206cfa4d6e Fix Quarkus recorder serialization issues for RouteTemplateDefinition resources
new 97fc8f384b Fixed converters comiplation error CAMEL-19398 + generated files
new edc1dcb822 Fixed enablement of typeConverter statisctics because of CAMEL-19398
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../ROOT/pages/reference/extensions/core.adoc | 12 +++
.../quarkus/core/deployment/CamelProcessor.java | 4 +-
...ContextDefaultTypeConverterStatisticsTest.java} | 8 +-
.../core/runtime/src/main/doc/configuration.adoc | 11 +++
.../apache/camel/quarkus/core/CamelRecorder.java | 4 +-
.../camel/quarkus/core/FastTypeConverter.java | 4 +-
.../kamelet/deployment/KameletProcessor.java | 19 +++-
.../kamelet/KameletClasspathResource.java | 109 +++++++++++++++++++++
.../core/converter/it/ConverterResource.java | 9 +-
.../src/main/resources/application.properties | 2 +
.../quarkus/core/converter/it/ConverterTest.java | 29 +++---
pom.xml | 6 +-
poms/bom/src/main/generated/flattened-full-pom.xml | 2 +-
.../src/main/generated/flattened-reduced-pom.xml | 2 +-
.../generated/flattened-reduced-verbose-pom.xml | 2 +-
15 files changed, 182 insertions(+), 41 deletions(-)
copy extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/{CamelContextDefaultStrategyTest.java => CamelContextDefaultTypeConverterStatisticsTest.java} (81%)
create mode 100644 extensions/kamelet/runtime/src/main/java/org/apache/camel/quarkus/component/kamelet/KameletClasspathResource.java
[camel-quarkus] 02/03: Fixed converters comiplation error CAMEL-19398 + generated files
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiriondrusek pushed a commit to branch camel-main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 97fc8f384b490497337886d8b79d2ee3a295ab29
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Thu Sep 21 11:21:53 2023 +0200
Fixed converters comiplation error CAMEL-19398 + generated files
---
.../main/java/org/apache/camel/quarkus/core/FastTypeConverter.java | 2 +-
.../apache/camel/quarkus/core/converter/it/ConverterResource.java | 2 +-
pom.xml | 6 +++---
poms/bom/src/main/generated/flattened-full-pom.xml | 2 +-
poms/bom/src/main/generated/flattened-reduced-pom.xml | 2 +-
poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml | 2 +-
6 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastTypeConverter.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastTypeConverter.java
index f4587dc151..ba77525189 100644
--- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastTypeConverter.java
+++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastTypeConverter.java
@@ -25,7 +25,7 @@ public class FastTypeConverter extends DefaultTypeConverter {
private static final Logger LOG = LoggerFactory.getLogger(FastTypeConverter.class);
public FastTypeConverter() {
- super(null, null, null, false);
+ super(null, null, null, false, false);
}
@Override
diff --git a/integration-test-groups/foundation/type-converter/src/main/java/org/apache/camel/quarkus/core/converter/it/ConverterResource.java b/integration-test-groups/foundation/type-converter/src/main/java/org/apache/camel/quarkus/core/converter/it/ConverterResource.java
index d6c19940eb..295d47a34b 100644
--- a/integration-test-groups/foundation/type-converter/src/main/java/org/apache/camel/quarkus/core/converter/it/ConverterResource.java
+++ b/integration-test-groups/foundation/type-converter/src/main/java/org/apache/camel/quarkus/core/converter/it/ConverterResource.java
@@ -94,7 +94,7 @@ public class ConverterResource {
@POST
@Produces(MediaType.TEXT_PLAIN)
public void cnverterSetStatisticsEnabled(boolean value) {
- context.getTypeConverterRegistry().getStatistics().setStatisticsEnabled(value);
+ context.setTypeConverterStatisticsEnabled(value);
if (value) {
context.getTypeConverterRegistry().getStatistics().reset();
}
diff --git a/pom.xml b/pom.xml
index 215bf28020..f2fbd43dca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -98,9 +98,9 @@
<github-api.version>1.313</github-api.version><!-- Used in a Groovy script bellow -->
<google-auth-library.version>1.19.0</google-auth-library.version><!-- @sync com.google.cloud:google-cloud-pubsub:${google-cloud-pubsub.version} dep:com.google.auth:google-auth-library-oauth2-http -->
<google-oauth-client.version>${google-oauth-client-version}</google-oauth-client.version>
- <google-cloud-bom.version>0.203.0</google-cloud-bom.version><!-- @sync com.google.cloud:libraries-bom:${google-cloud-bom-version} dep:com.google.cloud:google-cloud-bom -->
- <google-cloud-pubsub-bom.version>1.124.1</google-cloud-pubsub-bom.version><!-- @sync com.google.cloud:google-cloud-bom:${google-cloud-bom.version} dep:com.google.cloud:google-cloud-pubsub-bom -->
- <google-cloud-pubsub.version>1.124.1</google-cloud-pubsub.version><!-- @sync com.google.cloud:google-cloud-pubsub-bom:${google-cloud-pubsub-bom.version} dep:com.google.cloud:google-cloud-pubsub -->
+ <google-cloud-bom.version>0.204.0</google-cloud-bom.version><!-- @sync com.google.cloud:libraries-bom:${google-cloud-bom-version} dep:com.google.cloud:google-cloud-bom -->
+ <google-cloud-pubsub-bom.version>1.125.0</google-cloud-pubsub-bom.version><!-- @sync com.google.cloud:google-cloud-bom:${google-cloud-bom.version} dep:com.google.cloud:google-cloud-pubsub-bom -->
+ <google-cloud-pubsub.version>1.125.0</google-cloud-pubsub.version><!-- @sync com.google.cloud:google-cloud-pubsub-bom:${google-cloud-pubsub-bom.version} dep:com.google.cloud:google-cloud-pubsub -->
<graalvm.version>23.0.1</graalvm.version><!-- @sync io.quarkus:quarkus-bom:${quarkus.version} dep:org.graalvm.sdk:graal-sdk -->
<groovy.version>4.0.13</groovy.version><!-- @sync io.quarkiverse.groovy:quarkus-groovy-parent:${quarkiverse-groovy.version} prop:groovy.version -->
<grpc.version>1.57.2</grpc.version><!-- @sync io.quarkus:quarkus-bom:${quarkus.version} dep:io.grpc:grpc-core -->
diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml
index 77cb608e38..3f9f2109dc 100644
--- a/poms/bom/src/main/generated/flattened-full-pom.xml
+++ b/poms/bom/src/main/generated/flattened-full-pom.xml
@@ -6040,7 +6040,7 @@
<dependency>
<groupId>com.google.cloud</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<artifactId>google-cloud-pubsub</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <version>1.124.1</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <version>1.125.0</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<exclusions>
<exclusion>
<groupId>com.google.android</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml b/poms/bom/src/main/generated/flattened-reduced-pom.xml
index 3ce0fcb576..7ad6f24d40 100644
--- a/poms/bom/src/main/generated/flattened-reduced-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml
@@ -6040,7 +6040,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
- <version>1.124.1</version>
+ <version>1.125.0</version>
<exclusions>
<exclusion>
<groupId>com.google.android</groupId>
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 32b6a67f39..0827476684 100644
--- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
@@ -6040,7 +6040,7 @@
<dependency>
<groupId>com.google.cloud</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<artifactId>google-cloud-pubsub</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
- <version>1.124.1</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <version>1.125.0</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<exclusions>
<exclusion>
<groupId>com.google.android</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
[camel-quarkus] 03/03: Fixed enablement of typeConverter statisctics because of CAMEL-19398
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiriondrusek pushed a commit to branch camel-main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit edc1dcb8227a92af5f5f38737143bf5c7b5734c4
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Thu Sep 21 16:50:09 2023 +0200
Fixed enablement of typeConverter statisctics because of CAMEL-19398
---
.../ROOT/pages/reference/extensions/core.adoc | 12 +++++++
.../quarkus/core/deployment/CamelProcessor.java | 4 ++-
...lContextDefaultTypeConverterStatisticsTest.java | 39 ++++++++++++++++++++++
.../core/runtime/src/main/doc/configuration.adoc | 11 ++++++
.../apache/camel/quarkus/core/CamelRecorder.java | 4 +--
.../camel/quarkus/core/FastTypeConverter.java | 4 +--
.../core/converter/it/ConverterResource.java | 9 ++---
.../src/main/resources/application.properties | 2 ++
.../quarkus/core/converter/it/ConverterTest.java | 29 +++++++---------
9 files changed, 86 insertions(+), 28 deletions(-)
diff --git a/docs/modules/ROOT/pages/reference/extensions/core.adoc b/docs/modules/ROOT/pages/reference/extensions/core.adoc
index 08a263e7f8..626220fcfe 100644
--- a/docs/modules/ROOT/pages/reference/extensions/core.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/core.adoc
@@ -123,6 +123,18 @@ camel.beans.customBeanWithSetterInjection.counter = 123
As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
+[id="extensions-core-configuration-enabling-type-converter-statistics"]
+==== Enabling type converter statistics
+
+Set configuration property `camel.main.typeConverterStatisticsEnabled` to `true` in order to enable type converter statistics.
+[source,properties]
+---
+camel.main.typeConverterStatisticsEnabled = true
+---
+
+Suggested configuration from Camel `org.apache.camel.CamelContext#setTypeConverterStatisticsEnabled(Boolean)` does not have any effect on camel-quarkus.
+
+
[width="100%",cols="80,5,15",options="header"]
|===
diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java
index 38de8686c4..405854bf25 100644
--- a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java
+++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java
@@ -234,7 +234,9 @@ class CamelProcessor {
IndexView index = combinedIndex.getIndex();
- RuntimeValue<TypeConverterRegistry> typeConverterRegistry = recorder.createTypeConverterRegistry();
+ Boolean val = CamelSupport.getOptionalConfigValue("camel.main.typeConverterStatisticsEnabled", Boolean.class, false);
+
+ RuntimeValue<TypeConverterRegistry> typeConverterRegistry = recorder.createTypeConverterRegistry(val);
//
// This should be simplified by searching for classes implementing TypeConverterLoader but that
diff --git a/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/CamelContextDefaultTypeConverterStatisticsTest.java b/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/CamelContextDefaultTypeConverterStatisticsTest.java
new file mode 100644
index 0000000000..b691e816d3
--- /dev/null
+++ b/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/CamelContextDefaultTypeConverterStatisticsTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.core.deployment;
+
+import io.quarkus.test.QuarkusUnitTest;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class CamelContextDefaultTypeConverterStatisticsTest {
+ @RegisterExtension
+ static final QuarkusUnitTest CONFIG = new QuarkusUnitTest();
+
+ @Inject
+ CamelContext camelContext;
+
+ @Test
+ public void testDefaultTypeConverterStatistics() {
+ assertThat(camelContext.getTypeConverterRegistry().getStatistics().getClass().getSimpleName())
+ .isEqualTo("NoopTypeConverterStatistics");
+ }
+}
diff --git a/extensions-core/core/runtime/src/main/doc/configuration.adoc b/extensions-core/core/runtime/src/main/doc/configuration.adoc
index 68827731fd..beba713a4a 100644
--- a/extensions-core/core/runtime/src/main/doc/configuration.adoc
+++ b/extensions-core/core/runtime/src/main/doc/configuration.adoc
@@ -61,3 +61,14 @@ camel.beans.customBeanWithSetterInjection.counter = 123
---
As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
+
+==== Enabling type converter statistics
+
+Set configuration property `camel.main.typeConverterStatisticsEnabled` to `true` in order to enable type converter statistics.
+[source,properties]
+---
+camel.main.typeConverterStatisticsEnabled = true
+---
+
+Suggested configuration from Camel `org.apache.camel.CamelContext#setTypeConverterStatisticsEnabled(Boolean)` does not have any effect on camel-quarkus.
+
diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java
index 20f51df4af..d20bf5aeae 100644
--- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java
+++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java
@@ -66,8 +66,8 @@ public class CamelRecorder {
return new RuntimeValue<>(new RuntimeRegistry(beanQualifierResolvers));
}
- public RuntimeValue<TypeConverterRegistry> createTypeConverterRegistry() {
- return new RuntimeValue<>(new FastTypeConverter());
+ public RuntimeValue<TypeConverterRegistry> createTypeConverterRegistry(boolean typeConvertersatisticsEnabled) {
+ return new RuntimeValue<>(new FastTypeConverter(typeConvertersatisticsEnabled));
}
public void addTypeConverterLoader(RuntimeValue<TypeConverterRegistry> registry, RuntimeValue<TypeConverterLoader> loader) {
diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastTypeConverter.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastTypeConverter.java
index ba77525189..41aee346eb 100644
--- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastTypeConverter.java
+++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastTypeConverter.java
@@ -24,8 +24,8 @@ import org.slf4j.LoggerFactory;
public class FastTypeConverter extends DefaultTypeConverter {
private static final Logger LOG = LoggerFactory.getLogger(FastTypeConverter.class);
- public FastTypeConverter() {
- super(null, null, null, false, false);
+ public FastTypeConverter(boolean typeConvertersatisticsEnabled) {
+ super(null, null, null, true, typeConvertersatisticsEnabled);
}
@Override
diff --git a/integration-test-groups/foundation/type-converter/src/main/java/org/apache/camel/quarkus/core/converter/it/ConverterResource.java b/integration-test-groups/foundation/type-converter/src/main/java/org/apache/camel/quarkus/core/converter/it/ConverterResource.java
index 295d47a34b..7bbd00a44f 100644
--- a/integration-test-groups/foundation/type-converter/src/main/java/org/apache/camel/quarkus/core/converter/it/ConverterResource.java
+++ b/integration-test-groups/foundation/type-converter/src/main/java/org/apache/camel/quarkus/core/converter/it/ConverterResource.java
@@ -90,14 +90,11 @@ public class ConverterResource {
return context.getTypeConverter().convertTo(MyNullablePair.class, input);
}
- @Path("/setStatisticsEnabled")
+ @Path("/resetStatistics")
@POST
@Produces(MediaType.TEXT_PLAIN)
- public void cnverterSetStatisticsEnabled(boolean value) {
- context.setTypeConverterStatisticsEnabled(value);
- if (value) {
- context.getTypeConverterRegistry().getStatistics().reset();
- }
+ public void converterResetStatistics() {
+ context.getTypeConverterRegistry().getStatistics().reset();
}
@Path("/getStatisticsHit")
diff --git a/integration-test-groups/foundation/type-converter/src/main/resources/application.properties b/integration-test-groups/foundation/type-converter/src/main/resources/application.properties
index b6ff2229d0..871983a1f6 100644
--- a/integration-test-groups/foundation/type-converter/src/main/resources/application.properties
+++ b/integration-test-groups/foundation/type-converter/src/main/resources/application.properties
@@ -16,3 +16,5 @@
## ---------------------------------------------------------------------------
quarkus.log.file.enable = true
quarkus.log.file.path = target/quarkus.log
+
+camel.main.typeConverterStatisticsEnabled = true
\ No newline at end of file
diff --git a/integration-test-groups/foundation/type-converter/src/test/java/org/apache/camel/quarkus/core/converter/it/ConverterTest.java b/integration-test-groups/foundation/type-converter/src/test/java/org/apache/camel/quarkus/core/converter/it/ConverterTest.java
index d7d3c3edf1..30083cf0e5 100644
--- a/integration-test-groups/foundation/type-converter/src/test/java/org/apache/camel/quarkus/core/converter/it/ConverterTest.java
+++ b/integration-test-groups/foundation/type-converter/src/test/java/org/apache/camel/quarkus/core/converter/it/ConverterTest.java
@@ -42,24 +42,20 @@ public class ConverterTest {
@Test
void testConverterToNull() {
- enableStatistics(true);
+ resetStatistics();
testConverterReturningNull("/converter/myNullablePair", "null");
RestAssured.when().get("/converter/getStatisticsHit").then().body("hit", is(1), "miss", is(0));
-
- enableStatistics(false);
}
@Test
void testNotRegisteredConverter() {
- enableStatistics(true);
+ resetStatistics();
testConverterReturningNull("/converter/myNotRegisteredPair", "a:b");
RestAssured.when().get("/converter/getStatisticsHit").then().body("hit", is(0), "miss", is(1));
-
- enableStatistics(false);
}
@Test
@@ -87,22 +83,12 @@ public class ConverterTest {
@Test
void testConverterGetStatistics() {
- enableStatistics(true);
+ resetStatistics();
//cause 1 hit
testConverterFromAnnotation();
RestAssured.when().get("/converter/getStatisticsHit").then().body("hit", is(1), "miss", is(0));
-
- enableStatistics(false);
- }
-
- private void enableStatistics(boolean b) {
- RestAssured.given()
- .contentType(ContentType.TEXT).body(b)
- .post("/converter/setStatisticsEnabled")
- .then()
- .statusCode(204);
}
private void testConverterReturningNull(String url, String body) {
@@ -125,4 +111,13 @@ public class ConverterTest {
response.body("key", is(expectedKey), "val", is(expectedValue));
}
}
+
+ private void resetStatistics() {
+ //reset statistics
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .post("/converter/resetStatistics")
+ .then()
+ .statusCode(204);
+ }
}
[camel-quarkus] 01/03: Fix Quarkus recorder serialization issues for RouteTemplateDefinition resources
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiriondrusek pushed a commit to branch camel-main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 206cfa4d6e3236efc16ca3912258676c70630d69
Author: James Netherton <ja...@gmail.com>
AuthorDate: Wed Sep 20 16:02:46 2023 +0100
Fix Quarkus recorder serialization issues for RouteTemplateDefinition resources
---
.../kamelet/deployment/KameletProcessor.java | 19 +++-
.../kamelet/KameletClasspathResource.java | 109 +++++++++++++++++++++
2 files changed, 125 insertions(+), 3 deletions(-)
diff --git a/extensions/kamelet/deployment/src/main/java/org/apache/camel/quarkus/component/kamelet/deployment/KameletProcessor.java b/extensions/kamelet/deployment/src/main/java/org/apache/camel/quarkus/component/kamelet/deployment/KameletProcessor.java
index 0880e515c5..4e91db5f8b 100644
--- a/extensions/kamelet/deployment/src/main/java/org/apache/camel/quarkus/component/kamelet/deployment/KameletProcessor.java
+++ b/extensions/kamelet/deployment/src/main/java/org/apache/camel/quarkus/component/kamelet/deployment/KameletProcessor.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.quarkus.component.kamelet.deployment;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -35,6 +36,7 @@ import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.model.RouteTemplateDefinition;
+import org.apache.camel.quarkus.component.kamelet.KameletClasspathResource;
import org.apache.camel.quarkus.component.kamelet.KameletConfiguration;
import org.apache.camel.quarkus.component.kamelet.KameletRecorder;
import org.apache.camel.quarkus.core.deployment.spi.CamelContextCustomizerBuildItem;
@@ -104,9 +106,20 @@ class KameletProcessor {
}
}
- //quick workaround for #5230
- //remove references to Resources, because the list is serialized; resources are loaded later in the recorder
- definitions.stream().forEach(rd -> rd.setResource(null));
+ // Use Quarkus recorder serialization friendly KameletClasspathResource instead of the default Resource
+ definitions.forEach(definition -> {
+ try {
+ Resource originalResource = definition.getResource();
+ KameletClasspathResource kameletResource = new KameletClasspathResource();
+ kameletResource.setScheme(originalResource.getScheme());
+ kameletResource.setLocation(originalResource.getLocation());
+ kameletResource.setExists(originalResource.exists());
+ kameletResource.setData(originalResource.getInputStream().readAllBytes());
+ definition.setResource(kameletResource);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ });
return new CamelContextCustomizerBuildItem(
recorder.createTemplateLoaderCustomizer(definitions));
diff --git a/extensions/kamelet/runtime/src/main/java/org/apache/camel/quarkus/component/kamelet/KameletClasspathResource.java b/extensions/kamelet/runtime/src/main/java/org/apache/camel/quarkus/component/kamelet/KameletClasspathResource.java
new file mode 100644
index 0000000000..357e86c0e1
--- /dev/null
+++ b/extensions/kamelet/runtime/src/main/java/org/apache/camel/quarkus/component/kamelet/KameletClasspathResource.java
@@ -0,0 +1,109 @@
+/*
+ * 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.component.kamelet;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Objects;
+
+import org.apache.camel.spi.Resource;
+
+/**
+ * Mutable & Quarkus recorder serialization friendly implementation for Kamelet classpath resources
+ */
+public class KameletClasspathResource implements Resource {
+ private String scheme;
+ private String location;
+ private boolean exists;
+ private byte[] data;
+ private InputStream inputStream;
+
+ @Override
+ public String getScheme() {
+ return scheme;
+ }
+
+ public void setScheme(String scheme) {
+ this.scheme = scheme;
+ }
+
+ @Override
+ public String getLocation() {
+ return this.location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ @Override
+ public boolean exists() {
+ return exists;
+ }
+
+ public void setExists(boolean exists) {
+ this.exists = exists;
+ }
+
+ public byte[] getData() {
+ return this.data;
+ }
+
+ public void setData(byte[] data) {
+ this.inputStream = null;
+ this.data = data;
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ if (this.data == null) {
+ throw new IOException("No resource content was defined");
+ }
+ if (this.inputStream == null) {
+ this.inputStream = new ByteArrayInputStream(this.data);
+ }
+ return inputStream;
+ }
+
+ @Override
+ public String toString() {
+ String prefix = scheme + ":";
+ if (location.startsWith(prefix)) {
+ return "Resource[" + location + "]";
+ } else {
+ return "Resource[" + prefix + location + "]";
+ }
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ Resource that = (Resource) o;
+ return scheme.equals(that.getScheme()) && location.equals(that.getLocation());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(scheme, location);
+ }
+}