From a69d73d92778dbd5a1c5923cd468b40d5ba73c14 Mon Sep 17 00:00:00 2001 From: mweissdigchg <74358275+mweissdigchg@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:44:11 +0200 Subject: [PATCH] added camel-quarkus-javascript (#6369) --- catalog/pom.xml | 13 +++ docs/modules/ROOT/examples/languages/js.yml | 13 +++ docs/modules/ROOT/nav.adoc | 1 + .../reference/extensions/javascript.adoc | 41 +++++++ extensions-jvm/javascript/deployment/pom.xml | 63 +++++++++++ .../deployment/JavascriptProcessor.java | 46 ++++++++ extensions-jvm/javascript/pom.xml | 39 +++++++ extensions-jvm/javascript/runtime/pom.xml | 100 ++++++++++++++++++ .../resources/META-INF/quarkus-extension.yaml | 33 ++++++ extensions-jvm/pom.xml | 1 + integration-tests-jvm/javascript/pom.xml | 84 +++++++++++++++ .../javascript/it/JavascriptResource.java | 50 +++++++++ .../javascript/it/JavascriptTest.java | 34 ++++++ integration-tests-jvm/pom.xml | 1 + poms/bom/pom.xml | 15 +++ .../src/main/generated/flattened-full-pom.xml | 15 +++ .../main/generated/flattened-reduced-pom.xml | 15 +++ .../flattened-reduced-verbose-pom.xml | 15 +++ 18 files changed, 579 insertions(+) create mode 100644 docs/modules/ROOT/examples/languages/js.yml create mode 100644 docs/modules/ROOT/pages/reference/extensions/javascript.adoc create mode 100644 extensions-jvm/javascript/deployment/pom.xml create mode 100644 extensions-jvm/javascript/deployment/src/main/java/org/apache/camel/quarkus/component/javascript/deployment/JavascriptProcessor.java create mode 100644 extensions-jvm/javascript/pom.xml create mode 100644 extensions-jvm/javascript/runtime/pom.xml create mode 100644 extensions-jvm/javascript/runtime/src/main/resources/META-INF/quarkus-extension.yaml create mode 100644 integration-tests-jvm/javascript/pom.xml create mode 100644 integration-tests-jvm/javascript/src/main/java/org/apache/camel/quarkus/component/javascript/it/JavascriptResource.java create mode 100644 integration-tests-jvm/javascript/src/test/java/org/apache/camel/quarkus/component/javascript/it/JavascriptTest.java diff --git a/catalog/pom.xml b/catalog/pom.xml index 7abd52b0614c..7aff46766d1b 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -1982,6 +1982,19 @@ + + org.apache.camel.quarkus + camel-quarkus-javascript + ${project.version} + pom + test + + + * + * + + + org.apache.camel.quarkus camel-quarkus-jaxb diff --git a/docs/modules/ROOT/examples/languages/js.yml b/docs/modules/ROOT/examples/languages/js.yml new file mode 100644 index 000000000000..15261954d617 --- /dev/null +++ b/docs/modules/ROOT/examples/languages/js.yml @@ -0,0 +1,13 @@ +# Do not edit directly! +# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +cqArtifactId: camel-quarkus-javascript +cqArtifactIdBase: javascript +cqNativeSupported: false +cqStatus: Preview +cqDeprecated: false +cqJvmSince: 3.14.0 +cqNativeSince: n/a +cqCamelPartName: js +cqCamelPartTitle: JavaScript +cqCamelPartDescription: Evaluates a JavaScript expression. +cqExtensionPageTitle: JavaScript diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 6da7470cc05a..1a6542a8837f 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -180,6 +180,7 @@ *** xref:reference/extensions/jacksonxml.adoc[JacksonXML] *** xref:reference/extensions/jasypt.adoc[Jasypt] *** xref:reference/extensions/java-joor-dsl.adoc[Java jOOR DSL] +*** xref:reference/extensions/javascript.adoc[JavaScript] *** xref:reference/extensions/js-dsl.adoc[JavaScript DSL] *** xref:reference/extensions/jsh-dsl.adoc[JavaShell DSL] *** xref:reference/extensions/jfr.adoc[Jfr] diff --git a/docs/modules/ROOT/pages/reference/extensions/javascript.adoc b/docs/modules/ROOT/pages/reference/extensions/javascript.adoc new file mode 100644 index 000000000000..2c937598fe83 --- /dev/null +++ b/docs/modules/ROOT/pages/reference/extensions/javascript.adoc @@ -0,0 +1,41 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +[id="extensions-javascript"] += JavaScript +:linkattrs: +:cq-artifact-id: camel-quarkus-javascript +:cq-native-supported: false +:cq-status: Preview +:cq-status-deprecation: Preview +:cq-description: Evaluates a JavaScript expression. +:cq-deprecated: false +:cq-jvm-since: 3.14.0 +:cq-native-since: n/a + +ifeval::[{doc-show-badges} == true] +[.badges] +[.badge-key]##JVM since##[.badge-supported]##3.14.0## [.badge-key]##Native##[.badge-unsupported]##unsupported## +endif::[] + +Evaluates a JavaScript expression. + +[id="extensions-javascript-whats-inside"] +== What's inside + +* xref:{cq-camel-components}:languages:js-language.adoc[JavaScript language] + +Please refer to the above link for usage and configuration details. + +[id="extensions-javascript-maven-coordinates"] +== Maven coordinates + +[source,xml] +---- + + org.apache.camel.quarkus + camel-quarkus-javascript + +---- +ifeval::[{doc-show-user-guide-link} == true] +Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. +endif::[] diff --git a/extensions-jvm/javascript/deployment/pom.xml b/extensions-jvm/javascript/deployment/pom.xml new file mode 100644 index 000000000000..d708d866272f --- /dev/null +++ b/extensions-jvm/javascript/deployment/pom.xml @@ -0,0 +1,63 @@ + + + + 4.0.0 + + org.apache.camel.quarkus + camel-quarkus-javascript-parent + 3.14.0-SNAPSHOT + ../pom.xml + + + camel-quarkus-javascript-deployment + Camel Quarkus :: JavaScript :: Deployment + + + + org.apache.camel.quarkus + camel-quarkus-core-deployment + + + org.apache.camel.quarkus + camel-quarkus-javascript + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${quarkus.version} + + + + + + + + diff --git a/extensions-jvm/javascript/deployment/src/main/java/org/apache/camel/quarkus/component/javascript/deployment/JavascriptProcessor.java b/extensions-jvm/javascript/deployment/src/main/java/org/apache/camel/quarkus/component/javascript/deployment/JavascriptProcessor.java new file mode 100644 index 000000000000..facad4b998dc --- /dev/null +++ b/extensions-jvm/javascript/deployment/src/main/java/org/apache/camel/quarkus/component/javascript/deployment/JavascriptProcessor.java @@ -0,0 +1,46 @@ +/* + * 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.javascript.deployment; + +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 io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; +import org.apache.camel.quarkus.core.JvmOnlyRecorder; +import org.jboss.logging.Logger; + +class JavascriptProcessor { + + private static final Logger LOG = Logger.getLogger(JavascriptProcessor.class); + private static final String FEATURE = "camel-javascript"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + /** + * Remove this once this extension starts supporting the native mode. + */ + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) + @Record(value = ExecutionTime.RUNTIME_INIT) + void warnJvmInNative(JvmOnlyRecorder recorder) { + JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time + recorder.warnJvmInNative(FEATURE); // warn at runtime + } +} diff --git a/extensions-jvm/javascript/pom.xml b/extensions-jvm/javascript/pom.xml new file mode 100644 index 000000000000..1aae36ea016a --- /dev/null +++ b/extensions-jvm/javascript/pom.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + + org.apache.camel.quarkus + camel-quarkus-extensions-jvm + 3.14.0-SNAPSHOT + ../pom.xml + + + camel-quarkus-javascript-parent + Camel Quarkus :: JavaScript + pom + + + deployment + runtime + + diff --git a/extensions-jvm/javascript/runtime/pom.xml b/extensions-jvm/javascript/runtime/pom.xml new file mode 100644 index 000000000000..b4b2c22a5715 --- /dev/null +++ b/extensions-jvm/javascript/runtime/pom.xml @@ -0,0 +1,100 @@ + + + + 4.0.0 + + org.apache.camel.quarkus + camel-quarkus-javascript-parent + 3.14.0-SNAPSHOT + ../pom.xml + + + camel-quarkus-javascript + Camel Quarkus :: JavaScript :: Runtime + Evaluates a JavaScript expression. + + + 3.14.0 + + + + + org.apache.camel.quarkus + camel-quarkus-core + + + org.apache.camel + camel-javascript + + + + + + + io.quarkus + quarkus-extension-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${quarkus.version} + + + + + + + + + + + full + + + !quickly + + + + + + org.apache.camel.quarkus + camel-quarkus-maven-plugin + + + update-extension-doc-page + + update-extension-doc-page + + process-classes + + + + + + + + diff --git a/extensions-jvm/javascript/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions-jvm/javascript/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 000000000000..b5b586f95e5f --- /dev/null +++ b/extensions-jvm/javascript/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,33 @@ +# +# 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. +# + +# This is a generated file. Do not edit directly! +# To re-generate, run the following command from the top level directory: +# +# mvn -N cq:update-quarkus-metadata +# +--- +name: "Camel JavaScript" +description: "Evaluates a JavaScript expression" +metadata: + icon-url: "https://raw.githubusercontent.com/apache/camel-website/main/antora-ui-camel/src/img/logo-d.svg" + unlisted: true + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/javascript.html" + categories: + - "integration" + status: + - "preview" diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml index f92e1141aabb..6176020e0e2d 100644 --- a/extensions-jvm/pom.xml +++ b/extensions-jvm/pom.xml @@ -70,6 +70,7 @@ iec60870 ignite irc + javascript jcr jgroups jgroups-raft diff --git a/integration-tests-jvm/javascript/pom.xml b/integration-tests-jvm/javascript/pom.xml new file mode 100644 index 000000000000..0649a91049fc --- /dev/null +++ b/integration-tests-jvm/javascript/pom.xml @@ -0,0 +1,84 @@ + + + + 4.0.0 + + org.apache.camel.quarkus + camel-quarkus-build-parent-it + 3.14.0-SNAPSHOT + ../../poms/build-parent-it/pom.xml + + + camel-quarkus-integration-test-javascript + Camel Quarkus :: Integration Tests :: JavaScript + Integration tests for Camel Quarkus JavaScript extension + + + + org.apache.camel.quarkus + camel-quarkus-javascript + + + io.quarkus + quarkus-resteasy + + + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + + + + virtualDependencies + + + !noVirtualDependencies + + + + + + org.apache.camel.quarkus + camel-quarkus-javascript-deployment + ${project.version} + pom + test + + + * + * + + + + + + + diff --git a/integration-tests-jvm/javascript/src/main/java/org/apache/camel/quarkus/component/javascript/it/JavascriptResource.java b/integration-tests-jvm/javascript/src/main/java/org/apache/camel/quarkus/component/javascript/it/JavascriptResource.java new file mode 100644 index 000000000000..ca8a6c07ed9e --- /dev/null +++ b/integration-tests-jvm/javascript/src/main/java/org/apache/camel/quarkus/component/javascript/it/JavascriptResource.java @@ -0,0 +1,50 @@ +/* + * 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.javascript.it; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import org.apache.camel.CamelContext; +import org.jboss.logging.Logger; + +@Path("/javascript") +@ApplicationScoped +public class JavascriptResource { + + private static final Logger LOG = Logger.getLogger(JavascriptResource.class); + + private static final String LANGUAGE_JS = "js"; + @Inject + CamelContext context; + + @Path("/load/language/js") + @GET + @Produces(MediaType.TEXT_PLAIN) + public Response loadLanguageJs() throws Exception { + /* This is an autogenerated test */ + if (context.resolveLanguage(LANGUAGE_JS) != null) { + return Response.ok().build(); + } + LOG.warnf("Could not load [%s] from the Camel context", LANGUAGE_JS); + return Response.status(500, LANGUAGE_JS + " could not be loaded from the Camel context").build(); + } +} diff --git a/integration-tests-jvm/javascript/src/test/java/org/apache/camel/quarkus/component/javascript/it/JavascriptTest.java b/integration-tests-jvm/javascript/src/test/java/org/apache/camel/quarkus/component/javascript/it/JavascriptTest.java new file mode 100644 index 000000000000..6d8e10517560 --- /dev/null +++ b/integration-tests-jvm/javascript/src/test/java/org/apache/camel/quarkus/component/javascript/it/JavascriptTest.java @@ -0,0 +1,34 @@ +/* + * 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.javascript.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class JavascriptTest { + + @Test + public void loadLanguageJs() { + /* A simple autogenerated test */ + RestAssured.get("/javascript/load/language/js") + .then() + .statusCode(200); + } + +} diff --git a/integration-tests-jvm/pom.xml b/integration-tests-jvm/pom.xml index 361ec20c2d97..6cbf9655393b 100644 --- a/integration-tests-jvm/pom.xml +++ b/integration-tests-jvm/pom.xml @@ -69,6 +69,7 @@ iec60870 ignite irc + javascript jcr jgroups jgroups-raft diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index eba2b6d20b6b..16981ea32b7f 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -1556,6 +1556,11 @@ camel-java-joor-dsl ${camel.version} + + org.apache.camel + camel-javascript + ${camel.version} + org.apache.camel camel-jaxb @@ -4386,6 +4391,16 @@ camel-quarkus-java-joor-dsl-deployment ${camel-quarkus.version} + + org.apache.camel.quarkus + camel-quarkus-javascript + ${camel-quarkus.version} + + + org.apache.camel.quarkus + camel-quarkus-javascript-deployment + ${camel-quarkus.version} + org.apache.camel.quarkus camel-quarkus-jaxb diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml index 94fc628e7aeb..b669c4067d33 100644 --- a/poms/bom/src/main/generated/flattened-full-pom.xml +++ b/poms/bom/src/main/generated/flattened-full-pom.xml @@ -1493,6 +1493,11 @@ camel-java-joor-dsl 4.7.0 + + org.apache.camel + camel-javascript + 4.7.0 + org.apache.camel camel-jaxb @@ -4311,6 +4316,16 @@ camel-quarkus-java-joor-dsl-deployment 3.14.0-SNAPSHOT + + org.apache.camel.quarkus + camel-quarkus-javascript + 3.14.0-SNAPSHOT + + + org.apache.camel.quarkus + camel-quarkus-javascript-deployment + 3.14.0-SNAPSHOT + org.apache.camel.quarkus camel-quarkus-jaxb diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml b/poms/bom/src/main/generated/flattened-reduced-pom.xml index 617341ff68b2..d25ba5a9fa78 100644 --- a/poms/bom/src/main/generated/flattened-reduced-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml @@ -1493,6 +1493,11 @@ camel-java-joor-dsl 4.7.0 + + org.apache.camel + camel-javascript + 4.7.0 + org.apache.camel camel-jaxb @@ -4311,6 +4316,16 @@ camel-quarkus-java-joor-dsl-deployment 3.14.0-SNAPSHOT + + org.apache.camel.quarkus + camel-quarkus-javascript + 3.14.0-SNAPSHOT + + + org.apache.camel.quarkus + camel-quarkus-javascript-deployment + 3.14.0-SNAPSHOT + org.apache.camel.quarkus camel-quarkus-jaxb 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 a0fb8d5f5320..e16bbef347a4 100644 --- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml @@ -1493,6 +1493,11 @@ camel-java-joor-dsl 4.7.0 + + org.apache.camel + camel-javascript + 4.7.0 + org.apache.camel camel-jaxb @@ -4311,6 +4316,16 @@ camel-quarkus-java-joor-dsl-deployment 3.14.0-SNAPSHOT + + org.apache.camel.quarkus + camel-quarkus-javascript + 3.14.0-SNAPSHOT + + + org.apache.camel.quarkus + camel-quarkus-javascript-deployment + 3.14.0-SNAPSHOT + org.apache.camel.quarkus camel-quarkus-jaxb