diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 38eda62fea..6b20938958 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -28,9 +28,6 @@ ** xref:languages/yaml.adoc[YAML] ** xref:languages/xml.adoc[XML] ** xref:languages/groovy.adoc[Groovy] -** xref:languages/javascript.adoc[Javascript] -** xref:languages/jsh.adoc[JSheel] -** xref:languages/kotlin.adoc[Kotlin] * xref:configuration/configuration.adoc[Configuration] ** xref:configuration/dependencies.adoc[Dependencies] ** xref:configuration/build-time-properties.adoc[Build time properties] diff --git a/docs/modules/ROOT/pages/languages/javascript.adoc b/docs/modules/ROOT/pages/languages/javascript.adoc deleted file mode 100644 index 6ea5b8b705..0000000000 --- a/docs/modules/ROOT/pages/languages/javascript.adoc +++ /dev/null @@ -1,38 +0,0 @@ -= Writing Integrations in JavaScript - -[WARNING] -==== -The JavaScript DSL is experimental. -==== - -An integration written in JavaScript looks very similar to a Java one: - -[source,js] -.hello.js ----- -function proc(e) { - e.getIn().setBody('Hello Camel K!') -} - -from('timer:tick') - .process(proc) - .to('log:info') ----- - -To run it, you need just to execute: - -``` -kamel run hello.js -``` - -For JavaScript integrations, Camel K does not yet provide an enhanced DSL, but you can access to some global bounded objects such as a writable registry and the camel context so to set the property _exchangeFormatter_ of the _LogComponent_ as done in previous example, you can do something like: - -[source,js] ----- - -l = context.getComponent('log', true, false) -l.exchangeFormatter = function(e) { - return "log - body=" + e.in.body + ", headers=" + e.in.headers -} ----- - diff --git a/docs/modules/ROOT/pages/languages/jsh.adoc b/docs/modules/ROOT/pages/languages/jsh.adoc deleted file mode 100644 index 1de6a14282..0000000000 --- a/docs/modules/ROOT/pages/languages/jsh.adoc +++ /dev/null @@ -1,25 +0,0 @@ -= Writing Integrations in Java - -[WARNING] -==== -The JShell DSL is experimental. -==== - -Using Java and JShell to write an integration to be deployed using Camel K is no different from defining your routing rules in Camel with the only difference that you do not need to implement or extend a RouteBuilder but you can access the current builder thx to the built-in `builder` variable. - -[source,java] -.example.jsh ----- -builder.from("timer:tick") - .setBody() - .constant("Hello Camel K!") - .to("log:info");- ----- - -You can run it with the standard command: - -``` -kamel run example.jsh -``` - - diff --git a/docs/modules/ROOT/pages/languages/kotlin.adoc b/docs/modules/ROOT/pages/languages/kotlin.adoc deleted file mode 100644 index 697b68760b..0000000000 --- a/docs/modules/ROOT/pages/languages/kotlin.adoc +++ /dev/null @@ -1,124 +0,0 @@ -= Writing Integrations in Kotlin - -[WARNING] -==== -The Kotlin DSL is experimental. -==== - -An integration written in Kotlin looks very similar to a Java one except it can leverages Kotlin's language enhancements over Java: - -[source,kotlin] ----- -from("timer:tick") - .process { e -> e.getIn().body = "Hello Camel K!" } - .to("log:info") ----- - -You can run it with the standard command: - -``` -kamel run example.kts -``` - -Camel K extends the Camel Java DSL making it easier to configure the context in which the integration runs using the top level _context_ block - -[source,kotlin] ----- -context { - // configure the context here -} ----- - -At the moment, the enhanced DSL provides a way to bind items to the registry, to configure the components the context creates and some improvements over the REST DSL. - -== Beans DSL - -To register beans as you would do with a Camel registry you can use the Beans DSL - -[source,kotlin] ----- -beans { - bean("dataSource") { <1> - driverClassName = "org.h2.Driver" - url = "jdbc:h2:mem:camel" - username = "sa" - password = "" - } - - bean("filterStrategy") { <1> - org.apache.camel.support.DefaultHeaderFilterStrategy() - } - - processor("myProcessor") { <2> - it.getIn().body = "Hello" - } - - predicate("myPredicate") { <3> - false - } -} ----- -<1> bind beans to the context for the database and filter strategy -<2> define a custom processor to be used later in the routes by ref -<3> define a custom predicate to be used later in the routes by ref - - -== Components Configuration - -Components can be configured within the _components_ block inside the _camel_ one: - -[source,kotlin] ----- -camel { - components { - - component("seda") { //<1> - queueSize = 1234 - concurrentConsumers = 12 - } - - component("mySeda") { // <2> - queueSize = 4321 - concurrentConsumers = 21 - } - - component("log") { // <3> - setExchangeFormatter { - e: Exchange -> "" + e.getIn().body - } - } - } -} ----- -<1> configure the properties of a component whit type _SedaComponent_ and name _seda_ -<2> configure the properties of a component with type SedaComponent and name _mySeda_, note that as _mySeda_ does not represent a valid component scheme, a new component of the required type will be instantiated. -<3> configure the properties of the component whit name _log_ - -[NOTE] -==== -As for Groovy, you can provide your custom extension to the DSL -==== - -== Rest Endpoints - -Integrations REST endpoints can be configured using the top level _rest_ block: - -[source,kotlin] ----- -rest { - configuration { // <1> - host = "my-host" - port = "9192" - } - - path("/my/path") { // <2> - get("/get") { - consumes("application/json") - produces("application/json") - to("direct:get") - } - } -} ----- -<1> Configure the rest engine -<2> Configure the rest endpoint for the base path '/my/path' diff --git a/docs/modules/ROOT/pages/languages/languages.adoc b/docs/modules/ROOT/pages/languages/languages.adoc index 6a28886b72..6352b0d189 100644 --- a/docs/modules/ROOT/pages/languages/languages.adoc +++ b/docs/modules/ROOT/pages/languages/languages.adoc @@ -12,9 +12,6 @@ Camel K supports multiple languages for writing integrations: | xref:languages/xml.adoc[XML] | Integrations written in plain XML DSL are supported (Spring XML with or Blueprint XML with not supported) | xref:languages/yaml.adoc[YAML] | Integrations written in YAML DSL are supported | xref:languages/groovy.adoc[Groovy] | Groovy `.groovy` files are supported (experimental) -| xref:languages/kotlin.adoc[Kotlin] | Kotlin Script `.kts` files are supported (experimental) -| xref:languages/jsh.adoc[JShell] | JShell (Java Shell) `.jsh` files are supported (experimental) -| xref:languages/javascript.adoc[JavaScript] | JavaScript `.js` files are supported (experimental) |======================= More information about each language is located in the language specific sections. Mind that the compatibility of each DSL with Camel will depend on the runtime you'll use to run the Integration. diff --git a/docs/modules/ROOT/pages/troubleshooting/debugging.adoc b/docs/modules/ROOT/pages/troubleshooting/debugging.adoc index 24ffdd1833..b7901bf53f 100644 --- a/docs/modules/ROOT/pages/troubleshooting/debugging.adoc +++ b/docs/modules/ROOT/pages/troubleshooting/debugging.adoc @@ -42,7 +42,7 @@ As you can see in the logs, the CLI has configured the integration in debug mode The JVM is suspended and waits for a debugger to attach by default: this behavior can be turned off using the `--suspend=false` option. -Last thing to do is, to start a remote debugger on `localhost:5005` with the **integration file (if using Java, Groovy or Kotlin), the Apache Camel project, or the Camel K Runtime project**, opened on your IDE. +Last thing to do is, to start a remote debugger on `localhost:5005` with the **integration file, the Apache Camel project, or the Camel K Runtime project**, opened on your IDE. The following picture shows the configuration of a remote debugger in IntelliJ IDEA: diff --git a/e2e/native/files/Kotlin.kts b/e2e/common/languages/files/PolyglotJava.java similarity index 73% rename from e2e/native/files/Kotlin.kts rename to e2e/common/languages/files/PolyglotJava.java index 1af1c544f7..60bd194509 100644 --- a/e2e/native/files/Kotlin.kts +++ b/e2e/common/languages/files/PolyglotJava.java @@ -15,7 +15,14 @@ * limitations under the License. */ -from("timer:tick") - .setHeader("m").constant("string!") - .setBody().simple("Magic\${header.m}") - .log("Kotlin \${body}"); +import org.apache.camel.builder.RouteBuilder; + +public class PolyglotJava extends RouteBuilder { + @Override + public void configure() throws Exception { + from("timer:tick") + .setHeader("m").constant("java") + .setBody().simple("Magicpolyglot-${header.m}") + .log("${body}"); + } +} diff --git a/e2e/common/languages/files/js-polyglot.js b/e2e/common/languages/files/js-polyglot.js deleted file mode 100644 index 3d0ec5601b..0000000000 --- a/e2e/common/languages/files/js-polyglot.js +++ /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. - -from('timer:js?period=1000') - .routeId('js') - .setHeader("m").constant("polyglot-js") - .setBody() - .simple('Magic${header.m}') - .to('log:info') diff --git a/e2e/common/languages/files/js.js b/e2e/common/languages/files/js.js deleted file mode 100644 index f71b868f6a..0000000000 --- a/e2e/common/languages/files/js.js +++ /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. - -from('timer:js?period=1000') - .routeId('js') - .setHeader("m").constant("string!") - .setBody() - .simple('Magic${header.m}') - .to('log:info') diff --git a/e2e/common/languages/files/kotlin.kts b/e2e/common/languages/files/kotlin.kts deleted file mode 100644 index 7962d363a0..0000000000 --- a/e2e/common/languages/files/kotlin.kts +++ /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. - */ - -from("timer:kotlin?period=1000") - .routeId("kotlin") - .setHeader("m").constant("string!") - .setBody() - .simple("Magic\${header.m}") - .to("log:info") diff --git a/e2e/common/languages/js_test.go b/e2e/common/languages/js_test.go deleted file mode 100644 index 2813e0d8f0..0000000000 --- a/e2e/common/languages/js_test.go +++ /dev/null @@ -1,47 +0,0 @@ -//go:build integration -// +build integration - -// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration" - -/* -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 common - -import ( - "context" - "testing" - - . "github.com/onsi/gomega" - - corev1 "k8s.io/api/core/v1" - - . "github.com/apache/camel-k/v2/e2e/support" - v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" -) - -func TestRunSimpleJavaScriptExamples(t *testing.T) { - t.Parallel() - WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - t.Run("run js", func(t *testing.T) { - g.Expect(KamelRun(t, ctx, ns, "files/js.js").Execute()).To(Succeed()) - g.Eventually(IntegrationPodPhase(t, ctx, ns, "js"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) - g.Eventually(IntegrationConditionStatus(t, ctx, ns, "js", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) - g.Eventually(IntegrationLogs(t, ctx, ns, "js"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) - }) - }) -} diff --git a/e2e/common/languages/kotlin_test.go b/e2e/common/languages/kotlin_test.go deleted file mode 100644 index c5c6f01afc..0000000000 --- a/e2e/common/languages/kotlin_test.go +++ /dev/null @@ -1,47 +0,0 @@ -//go:build integration -// +build integration - -// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration" - -/* -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 common - -import ( - "context" - "testing" - - . "github.com/onsi/gomega" - - corev1 "k8s.io/api/core/v1" - - . "github.com/apache/camel-k/v2/e2e/support" - v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" -) - -func TestRunSimpleKotlinExamples(t *testing.T) { - t.Parallel() - WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - t.Run("run kotlin", func(t *testing.T) { - g.Expect(KamelRun(t, ctx, ns, "files/kotlin.kts").Execute()).To(Succeed()) - g.Eventually(IntegrationPodPhase(t, ctx, ns, "kotlin"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) - g.Eventually(IntegrationConditionStatus(t, ctx, ns, "kotlin", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) - g.Eventually(IntegrationLogs(t, ctx, ns, "kotlin"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) - }) - }) -} diff --git a/e2e/common/languages/polyglot_test.go b/e2e/common/languages/polyglot_test.go index b01dc40170..9d7119c2ed 100644 --- a/e2e/common/languages/polyglot_test.go +++ b/e2e/common/languages/polyglot_test.go @@ -38,11 +38,11 @@ func TestRunPolyglotExamples(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { t.Run("run polyglot", func(t *testing.T) { - g.Expect(KamelRun(t, ctx, ns, "--name", "polyglot", "files/js-polyglot.js", "files/yaml-polyglot.yaml").Execute()).To(Succeed()) + g.Expect(KamelRun(t, ctx, ns, "--name", "polyglot", "files/PolyglotJava.java", "files/yaml-polyglot.yaml").Execute()).To(Succeed()) g.Eventually(IntegrationPodPhase(t, ctx, ns, "polyglot"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) g.Eventually(IntegrationConditionStatus(t, ctx, ns, "polyglot", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) + g.Eventually(IntegrationLogs(t, ctx, ns, "polyglot"), TestTimeoutShort).Should(ContainSubstring("Magicpolyglot-java")) g.Eventually(IntegrationLogs(t, ctx, ns, "polyglot"), TestTimeoutShort).Should(ContainSubstring("Magicpolyglot-yaml")) - g.Eventually(IntegrationLogs(t, ctx, ns, "polyglot"), TestTimeoutShort).Should(ContainSubstring("Magicpolyglot-js")) }) }) } diff --git a/e2e/native/files/JavaScript.js b/e2e/native/files/JavaScript.js deleted file mode 100644 index 4130ddb5c3..0000000000 --- a/e2e/native/files/JavaScript.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('timer:tick') - .setHeader('m').constant('string!') - .setBody().simple('Magic${header.m}') - .log('JavaScript ${body}') diff --git a/e2e/native/native_test.go b/e2e/native/native_test.go index 29d93579f7..a13fdfd8f4 100644 --- a/e2e/native/native_test.go +++ b/e2e/native/native_test.go @@ -35,13 +35,6 @@ import ( func TestNativeIntegrations(t *testing.T) { WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - t.Run("unsupported integration source language", func(t *testing.T) { - name := RandomizedSuffixName("unsupported-js") - g.Expect(KamelRun(t, ctx, ns, "files/JavaScript.js", "--name", name, "-t", "quarkus.build-mode=native", "-t", "builder.tasks-limit-memory=quarkus-native:6.5Gi").Execute()).To(Succeed()) - - g.Eventually(IntegrationPhase(t, ctx, ns, name)).Should(Equal(v1.IntegrationPhaseError)) - }) - t.Run("xml native support", func(t *testing.T) { name := RandomizedSuffixName("xml-native") g.Expect(KamelRun(t, ctx, ns, "files/Xml.xml", "--name", name, "-t", "quarkus.build-mode=native", "-t", "builder.tasks-limit-memory=quarkus-native:6.5Gi").Execute()).To(Succeed()) diff --git a/e2e/native/native_with_sources_test.go b/e2e/native/native_with_sources_test.go index 6d3a950bcc..e2fb9f3dd2 100644 --- a/e2e/native/native_with_sources_test.go +++ b/e2e/native/native_with_sources_test.go @@ -92,17 +92,5 @@ func TestNativeHighMemoryIntegrations(t *testing.T) { g.Eventually(IntegrationLogs(t, ctx, ns, name), TestTimeoutShort).Should(ContainSubstring("Groovy Magicstring!")) }) - t.Run("kotlin native support", func(t *testing.T) { - name := RandomizedSuffixName("kotlin-native") - g.Expect(KamelRun(t, ctx, ns, "files/Kotlin.kts", "--name", name, "-t", "quarkus.build-mode=native", "-t", "builder.tasks-limit-memory=quarkus-native:9.5Gi").Execute()).To(Succeed()) - - g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutVeryLong).Should(Equal(corev1.PodRunning)) - g.Eventually(IntegrationPod(t, ctx, ns, name), TestTimeoutShort). - Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*"))) - g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutShort). - Should(Equal(corev1.ConditionTrue)) - - g.Eventually(IntegrationLogs(t, ctx, ns, name), TestTimeoutShort).Should(ContainSubstring("Kotlin Magicstring!")) - }) }) }