This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch 3.40.x in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 2883471aae126b3ecc3ffeb1c44553fd126f0f03 Author: James Netherton <[email protected]> AuthorDate: Wed Nov 11 14:49:14 2026 +0000 Autowire the Quarkus Qute Engine into QuteComponent Mark QuteComponent.quteEngine as autowired so that Camel injects the Quarkus Qute Engine bean from the registry. This replaces the dedicated recorder and build step. Co-authored-by: Claude Opus 5.5 <[email protected]> --- .../component/qute/QuteComponentConfigurer.java | 5 +++ .../org/apache/camel/component/qute/qute.json | 2 +- .../apache/camel/component/qute/QuteComponent.java | 2 +- .../component/qute/deployment/QuteProcessor.java | 16 ---------- .../quarkus/component/qute/CamelQuteRecorder.java | 36 ---------------------- .../quarkus/component/qute/it/QuteResource.java | 16 ++++++++++ .../camel/quarkus/component/qute/it/QuteTest.java | 8 +++++ 7 files changed, 31 insertions(+), 54 deletions(-) diff --git a/extensions/qute/component/src/generated/java/org/apache/camel/component/qute/QuteComponentConfigurer.java b/extensions/qute/component/src/generated/java/org/apache/camel/component/qute/QuteComponentConfigurer.java index a2759d032f7..da8b8fde5fa 100644 --- a/extensions/qute/component/src/generated/java/org/apache/camel/component/qute/QuteComponentConfigurer.java +++ b/extensions/qute/component/src/generated/java/org/apache/camel/component/qute/QuteComponentConfigurer.java @@ -35,6 +35,11 @@ public class QuteComponentConfigurer extends PropertyConfigurerSupport implement } } + @Override + public String[] getAutowiredNames() { + return new String[]{"quteEngine"}; + } + @Override public Class<?> getOptionType(String name, boolean ignoreCase) { switch (ignoreCase ? name.toLowerCase() : name) { diff --git a/extensions/qute/component/src/generated/resources/META-INF/org/apache/camel/component/qute/qute.json b/extensions/qute/component/src/generated/resources/META-INF/org/apache/camel/component/qute/qute.json index 324bb49203c..6daa4a5b89b 100644 --- a/extensions/qute/component/src/generated/resources/META-INF/org/apache/camel/component/qute/qute.json +++ b/extensions/qute/component/src/generated/resources/META-INF/org/apache/camel/component/qute/qute.json @@ -27,7 +27,7 @@ "allowTemplateFromHeader": { "index": 0, "kind": "property", "displayName": "Allow Template From Header", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential se [...] "lazyStartProducer": { "index": 1, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...] "autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] - "quteEngine": { "index": 3, "kind": "property", "displayName": "Qute Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "io.quarkus.qute.Engine", "deprecated": false, "autowired": false, "secret": false, "description": "To use the Engine otherwise a new engine is created" } + "quteEngine": { "index": 3, "kind": "property", "displayName": "Qute Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "io.quarkus.qute.Engine", "deprecated": false, "autowired": true, "secret": false, "description": "To use the Engine otherwise a new engine is created" } }, "headers": { "CamelQuteResourceUri": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A URI for the template resource to use instead of the endpoint configured one.", "constantName": "org.apache.camel.component.qute.QuteConstants#QUTE_RESOURCE_URI" }, diff --git a/extensions/qute/component/src/main/java/org/apache/camel/component/qute/QuteComponent.java b/extensions/qute/component/src/main/java/org/apache/camel/component/qute/QuteComponent.java index 99c5ee64ffb..0c7531581f8 100644 --- a/extensions/qute/component/src/main/java/org/apache/camel/component/qute/QuteComponent.java +++ b/extensions/qute/component/src/main/java/org/apache/camel/component/qute/QuteComponent.java @@ -30,7 +30,7 @@ public class QuteComponent extends DefaultComponent { @Metadata(defaultValue = "false") private boolean allowTemplateFromHeader; - @Metadata(label = "advanced") + @Metadata(label = "advanced", autowired = true) private Engine quteEngine; public QuteComponent() { diff --git a/extensions/qute/deployment/src/main/java/org/apache/camel/quarkus/component/qute/deployment/QuteProcessor.java b/extensions/qute/deployment/src/main/java/org/apache/camel/quarkus/component/qute/deployment/QuteProcessor.java index dc34b22bca5..045dfc6e85f 100644 --- a/extensions/qute/deployment/src/main/java/org/apache/camel/quarkus/component/qute/deployment/QuteProcessor.java +++ b/extensions/qute/deployment/src/main/java/org/apache/camel/quarkus/component/qute/deployment/QuteProcessor.java @@ -16,14 +16,8 @@ */ package org.apache.camel.quarkus.component.qute.deployment; -import io.quarkus.arc.deployment.BeanContainerBuildItem; import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.annotations.ExecutionTime; -import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.FeatureBuildItem; -import org.apache.camel.component.qute.QuteComponent; -import org.apache.camel.quarkus.component.qute.CamelQuteRecorder; -import org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeBeanBuildItem; class QuteProcessor { @@ -33,14 +27,4 @@ class QuteProcessor { FeatureBuildItem feature() { return new FeatureBuildItem(FEATURE); } - - @Record(ExecutionTime.STATIC_INIT) - @BuildStep - CamelRuntimeBeanBuildItem quteComponent(CamelQuteRecorder recorder, BeanContainerBuildItem beanContainer) { - // set the "real" Qute engine to the Camel Qute component - return new CamelRuntimeBeanBuildItem( - "qute", - QuteComponent.class.getName(), - recorder.createQuteComponent(beanContainer.getValue())); - } } diff --git a/extensions/qute/runtime/src/main/java/org/apache/camel/quarkus/component/qute/CamelQuteRecorder.java b/extensions/qute/runtime/src/main/java/org/apache/camel/quarkus/component/qute/CamelQuteRecorder.java deleted file mode 100644 index e9a5f944da5..00000000000 --- a/extensions/qute/runtime/src/main/java/org/apache/camel/quarkus/component/qute/CamelQuteRecorder.java +++ /dev/null @@ -1,36 +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.component.qute; - -import io.quarkus.arc.runtime.BeanContainer; -import io.quarkus.qute.Engine; -import io.quarkus.runtime.RuntimeValue; -import io.quarkus.runtime.annotations.Recorder; -import org.apache.camel.component.qute.QuteComponent; - -@Recorder -public class CamelQuteRecorder { - - public RuntimeValue<QuteComponent> createQuteComponent(BeanContainer beanContainer) { - Engine quteEngine = beanContainer.beanInstance(Engine.class); - - QuteComponent component = new QuteComponent(); - component.setQuteEngine(quteEngine); - - return new RuntimeValue<>(component); - } -} diff --git a/integration-tests/qute/src/main/java/org/apache/camel/quarkus/component/qute/it/QuteResource.java b/integration-tests/qute/src/main/java/org/apache/camel/quarkus/component/qute/it/QuteResource.java index a5172c4a8a0..83e94dc183e 100644 --- a/integration-tests/qute/src/main/java/org/apache/camel/quarkus/component/qute/it/QuteResource.java +++ b/integration-tests/qute/src/main/java/org/apache/camel/quarkus/component/qute/it/QuteResource.java @@ -19,6 +19,8 @@ package org.apache.camel.quarkus.component.qute.it; import java.util.HashMap; import java.util.Map; +import io.quarkus.arc.Arc; +import io.quarkus.qute.Engine; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.ws.rs.GET; @@ -28,8 +30,10 @@ import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import jakarta.ws.rs.QueryParam; import jakarta.ws.rs.core.MediaType; +import org.apache.camel.CamelContext; import org.apache.camel.CamelExecutionException; import org.apache.camel.ProducerTemplate; +import org.apache.camel.component.qute.QuteComponent; import org.apache.camel.component.qute.QuteConstants; @Path("/qute") @@ -39,6 +43,18 @@ public class QuteResource { @Inject ProducerTemplate producerTemplate; + @Inject + CamelContext context; + + @Path("/engine") + @GET + @Produces(MediaType.TEXT_PLAIN) + public boolean isQuarkusEngine() { + Engine engine = Arc.container().instance(Engine.class).get(); + QuteComponent component = context.getComponent("qute", QuteComponent.class); + return engine != null && component.getQuteEngine() == engine; + } + @Path("/template") @POST @Produces(MediaType.TEXT_PLAIN) diff --git a/integration-tests/qute/src/test/java/org/apache/camel/quarkus/component/qute/it/QuteTest.java b/integration-tests/qute/src/test/java/org/apache/camel/quarkus/component/qute/it/QuteTest.java index 6fd10515492..646a7f65894 100644 --- a/integration-tests/qute/src/test/java/org/apache/camel/quarkus/component/qute/it/QuteTest.java +++ b/integration-tests/qute/src/test/java/org/apache/camel/quarkus/component/qute/it/QuteTest.java @@ -32,6 +32,14 @@ class QuteTest { .body(is("Hello World")); } + @Test + public void quarkusEngineAutowired() { + RestAssured.get("/qute/engine") + .then() + .statusCode(200) + .body(is("true")); + } + @Test public void testInvalidTemplatePath() { RestAssured.get("/qute/template/invalid/path")
