This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
The following commit(s) were added to refs/heads/main by this push:
new 12d462c Move dsl-jsh to core project - Removed the jsh module from
camel-k-runtime
12d462c is described below
commit 12d462cb46c4aa3ae641499576fab24ca231a521
Author: Andrea Cosentino <[email protected]>
AuthorDate: Thu Mar 10 11:50:55 2022 +0100
Move dsl-jsh to core project - Removed the jsh module from camel-k-runtime
---
camel-k-loader-jsh/deployment/pom.xml | 59 ---------
.../quarkus/deployment/JshSourceLoaderFeature.java | 29 -----
.../deployment/JshSourceLoaderProcessor.java | 20 ---
camel-k-loader-jsh/impl/pom.xml | 134 --------------------
.../services/org/apache/camel/routes-loader/jsh | 2 -
.../java/org/apache/camel/k/loader/jsh/Jsh.java | 136 ---------------------
.../apache/camel/k/loader/jsh/JshClassLoader.java | 53 --------
.../camel/k/loader/jsh/JshLoaderDelegate.java | 80 ------------
.../camel/k/loader/jsh/JshRoutesBuilderLoader.java | 112 -----------------
.../camel/k/loader/jsh/JshSourceLoaderTest.groovy | 44 -------
.../camel/k/loader/jsh/support/TestRuntime.groovy | 67 ----------
.../impl/src/test/resources/jsh/routes.jsh | 20 ---
.../impl/src/test/resources/log4j2-test.xml | 36 ------
camel-k-loader-jsh/pom.xml | 37 ------
camel-k-loader-jsh/runtime/pom.xml | 86 -------------
.../jsh/quarkus/JshSourceLoaderRecorder.java | 23 ----
itests/camel-k-itests-loader-jsh/pom.xml | 21 +---
pom.xml | 16 ---
.../camel/k/tooling/maven/GenerateCatalogMojo.java | 9 --
support/camel-k-runtime-bom/pom.xml | 11 --
20 files changed, 3 insertions(+), 992 deletions(-)
diff --git a/camel-k-loader-jsh/deployment/pom.xml
b/camel-k-loader-jsh/deployment/pom.xml
deleted file mode 100644
index 6a2de5c..0000000
--- a/camel-k-loader-jsh/deployment/pom.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?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-loader-jsh-parent</artifactId>
- <version>1.13.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>camel-k-loader-jsh-deployment</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-loader-jsh</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-core-deployment</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <annotationProcessorPaths>
- <path>
- <groupId>io.quarkus</groupId>
-
<artifactId>quarkus-extension-processor</artifactId>
- <version>${quarkus-version}</version>
- </path>
- </annotationProcessorPaths>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git
a/camel-k-loader-jsh/deployment/src/main/java/org/apache/camel/k/loader/jsh/quarkus/deployment/JshSourceLoaderFeature.java
b/camel-k-loader-jsh/deployment/src/main/java/org/apache/camel/k/loader/jsh/quarkus/deployment/JshSourceLoaderFeature.java
deleted file mode 100644
index 12925ce..0000000
---
a/camel-k-loader-jsh/deployment/src/main/java/org/apache/camel/k/loader/jsh/quarkus/deployment/JshSourceLoaderFeature.java
+++ /dev/null
@@ -1,29 +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.k.loader.jsh.quarkus.deployment;
-
-import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.builditem.FeatureBuildItem;
-
-public class JshSourceLoaderFeature {
- private static final String FEATURE = "camel-k-loader-jsh";
-
- @BuildStep
- FeatureBuildItem feature() {
- return new FeatureBuildItem(FEATURE);
- }
-}
diff --git
a/camel-k-loader-jsh/deployment/src/main/java/org/apache/camel/k/loader/jsh/quarkus/deployment/JshSourceLoaderProcessor.java
b/camel-k-loader-jsh/deployment/src/main/java/org/apache/camel/k/loader/jsh/quarkus/deployment/JshSourceLoaderProcessor.java
deleted file mode 100644
index 62cecca..0000000
---
a/camel-k-loader-jsh/deployment/src/main/java/org/apache/camel/k/loader/jsh/quarkus/deployment/JshSourceLoaderProcessor.java
+++ /dev/null
@@ -1,20 +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.k.loader.jsh.quarkus.deployment;
-
-public class JshSourceLoaderProcessor {
-}
diff --git a/camel-k-loader-jsh/impl/pom.xml b/camel-k-loader-jsh/impl/pom.xml
deleted file mode 100644
index 3336eac..0000000
--- a/camel-k-loader-jsh/impl/pom.xml
+++ /dev/null
@@ -1,134 +0,0 @@
-<?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-loader-jsh-parent</artifactId>
- <version>1.13.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>camel-k-loader-jsh-impl</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-core-support</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core-engine</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-apt</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-annotations</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <!-- ****************************** -->
- <!-- -->
- <!-- TESTS -->
- <!-- -->
- <!-- ****************************** -->
-
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-test</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-main</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-bean</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-timer</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-seda</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-log</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-rest</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-direct</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.gmavenplus</groupId>
- <artifactId>gmavenplus-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>addSources</goal>
- <goal>addTestSources</goal>
- <goal>compile</goal>
- <goal>compileTests</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <invokeDynamic>true</invokeDynamic>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.jboss.jandex</groupId>
- <artifactId>jandex-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>make-index</id>
- <goals>
- <goal>jandex</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git
a/camel-k-loader-jsh/impl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/jsh
b/camel-k-loader-jsh/impl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/jsh
deleted file mode 100644
index 6ef86e7..0000000
---
a/camel-k-loader-jsh/impl/src/generated/resources/META-INF/services/org/apache/camel/routes-loader/jsh
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated by camel build tools - do NOT edit this file!
-class=org.apache.camel.k.loader.jsh.JshRoutesBuilderLoader
diff --git
a/camel-k-loader-jsh/impl/src/main/java/org/apache/camel/k/loader/jsh/Jsh.java
b/camel-k-loader-jsh/impl/src/main/java/org/apache/camel/k/loader/jsh/Jsh.java
deleted file mode 100644
index 6662eee..0000000
---
a/camel-k-loader-jsh/impl/src/main/java/org/apache/camel/k/loader/jsh/Jsh.java
+++ /dev/null
@@ -1,136 +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.k.loader.jsh;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.script.ScriptException;
-
-import jdk.jshell.JShell;
-import jdk.jshell.Snippet;
-import jdk.jshell.SnippetEvent;
-import jdk.jshell.SourceCodeAnalysis;
-import jdk.jshell.spi.ExecutionControl;
-import jdk.jshell.spi.ExecutionControlProvider;
-import jdk.jshell.spi.ExecutionEnv;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class Jsh {
- private static final Logger LOGGER = LoggerFactory.getLogger(Jsh.class);
- private static final ThreadLocal<Map<String, Object>> BINDINGS =
ThreadLocal.withInitial(ConcurrentHashMap::new);
-
- private Jsh() {
- // no-op
- }
-
- public static List<String> compile(JShell jshell, String script) throws
ScriptException {
- List<String> snippets = new ArrayList<>();
-
- while (!script.isEmpty()) {
- SourceCodeAnalysis.CompletionInfo ci =
jshell.sourceCodeAnalysis().analyzeCompletion(script);
- if (!ci.completeness().isComplete()) {
- throw new ScriptException("Incomplete script:\n" + script);
- }
-
- snippets.add(ci.source());
-
- script = ci.remaining();
- }
-
- return snippets;
- }
-
- public static void setBinding(JShell jshell, String name, Object value)
throws ScriptException {
- ObjectHelper.notNull(jshell, "jshell");
- ObjectHelper.notNull(name, "name");
- ObjectHelper.notNull(value, "value");
-
- setBinding(jshell, name, value, value.getClass());
- }
-
- public static <T> void setBinding(JShell jshell, String name, T value,
Class<? extends T> type) throws ScriptException {
- ObjectHelper.notNull(jshell, "jshell");
- ObjectHelper.notNull(name, "name");
- ObjectHelper.notNull(value, "value");
- ObjectHelper.notNull(type, "type");
-
- setBinding(name, value);
-
- // As JShell leverages LocalExecutionControl as execution engine and
thus JShell
- // runs in the current process it is possible to access to local
classes, we use
- // such capability to inject bindings as variables.
- String snippet = String.format(
- "var %s = %s.getBinding(\"%s\", %s.class);",
- name,
- Jsh.class.getName(),
- name,
- type.getName());
-
- eval(jshell, snippet);
- }
-
- public static Object getBinding(String name) {
- return BINDINGS.get().get(name);
- }
-
- public static <T> T getBinding(String name, Class<T> type) {
- Object answer = BINDINGS.get().get(name);
- return answer != null ? type.cast(answer) : null;
- }
-
- public static void setBinding(String name, Object value) {
- BINDINGS.get().put(name, value);
- }
-
- public static void clearBindings() {
- BINDINGS.get().clear();
- }
-
- public static void eval(JShell jshell, String snippet) throws
ScriptException {
- LOGGER.debug("Evaluating {}", snippet);
-
- List<SnippetEvent> events = jshell.eval(snippet);
-
- for (SnippetEvent event : events) {
- if (event.exception() != null) {
- throw new ScriptException(event.exception());
- }
- if (event.status() != Snippet.Status.VALID) {
- throw new ScriptException("Error evaluating snippet:\n" +
event.snippet().source());
- }
- }
- }
-
- public static ExecutionControlProvider wrapExecutionControl(String name,
ExecutionControl delegate) {
- return new ExecutionControlProvider() {
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public ExecutionControl generate(ExecutionEnv env, Map<String,
String> parameters) throws Throwable {
- return delegate;
- }
- };
- }
-}
diff --git
a/camel-k-loader-jsh/impl/src/main/java/org/apache/camel/k/loader/jsh/JshClassLoader.java
b/camel-k-loader-jsh/impl/src/main/java/org/apache/camel/k/loader/jsh/JshClassLoader.java
deleted file mode 100644
index ade085b..0000000
---
a/camel-k-loader-jsh/impl/src/main/java/org/apache/camel/k/loader/jsh/JshClassLoader.java
+++ /dev/null
@@ -1,53 +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.k.loader.jsh;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import jdk.jshell.spi.ExecutionControl;
-
-/**
- * An implementation of a {@link ClassLoader} that allow hold class bytecode.
- */
-final class JshClassLoader extends ClassLoader {
- private final Map<String, ExecutionControl.ClassBytecodes> types;
-
- JshClassLoader(ClassLoader parent) {
- super(parent);
-
- this.types = new HashMap<>();
- }
-
- void addClassBytecodes(ExecutionControl.ClassBytecodes classBytecodes) {
- types.put(toResourceString(classBytecodes.name()), classBytecodes);
- }
-
- @Override
- protected Class<?> findClass(String name) throws ClassNotFoundException {
- final String key = toResourceString(name);
- final ExecutionControl.ClassBytecodes cb = types.get(key);
-
- return cb == null
- ? super.findClass(name)
- : super.defineClass(name, cb.bytecodes(), 0,
cb.bytecodes().length);
- }
-
- private static String toResourceString(String name) {
- return name.replace('.', '/') + ".class";
- }
-}
diff --git
a/camel-k-loader-jsh/impl/src/main/java/org/apache/camel/k/loader/jsh/JshLoaderDelegate.java
b/camel-k-loader-jsh/impl/src/main/java/org/apache/camel/k/loader/jsh/JshLoaderDelegate.java
deleted file mode 100644
index cd59cd0..0000000
---
a/camel-k-loader-jsh/impl/src/main/java/org/apache/camel/k/loader/jsh/JshLoaderDelegate.java
+++ /dev/null
@@ -1,80 +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.k.loader.jsh;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import jdk.jshell.execution.LoaderDelegate;
-import jdk.jshell.spi.ExecutionControl;
-
-/**
- * A simple implementation of {@link LoaderDelegate} tailored for camel-k use
case.
- */
-final class JshLoaderDelegate implements LoaderDelegate {
- private final JshClassLoader loader;
- private final Map<String, Class<?>> types;
-
- public JshLoaderDelegate(JshClassLoader loader) {
- this.loader = loader;
- this.types = new HashMap<>();
- }
-
- @SuppressWarnings("PMD.PreserveStackTrace")
- @Override
- public void load(ExecutionControl.ClassBytecodes[] cbs)
- throws ExecutionControl.ClassInstallException,
ExecutionControl.EngineTerminationException {
-
- boolean[] loaded = new boolean[cbs.length];
- try {
- for (ExecutionControl.ClassBytecodes cb : cbs) {
- loader.addClassBytecodes(cb);
- }
- for (int i = 0; i < cbs.length; ++i) {
- Class<?> type = loader.loadClass(cbs[i].name());
- type.getDeclaredMethods();
-
- types.put(cbs[i].name(), type);
-
- loaded[i] = true;
- }
- } catch (Throwable ex) {
- throw new ExecutionControl.ClassInstallException("load: " +
ex.getMessage(), loaded);
- }
- }
-
- @Override
- public void classesRedefined(ExecutionControl.ClassBytecodes[] cbcs) {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- @Override
- public void addToClasspath(String cp)
- throws ExecutionControl.EngineTerminationException,
ExecutionControl.InternalException {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- @Override
- public Class<?> findClass(String name) throws ClassNotFoundException {
- Class<?> type = types.get(name);
- if (type != null) {
- return type;
- }
-
- throw new ClassNotFoundException(name + " not found");
- }
-}
diff --git
a/camel-k-loader-jsh/impl/src/main/java/org/apache/camel/k/loader/jsh/JshRoutesBuilderLoader.java
b/camel-k-loader-jsh/impl/src/main/java/org/apache/camel/k/loader/jsh/JshRoutesBuilderLoader.java
deleted file mode 100644
index 803d122..0000000
---
a/camel-k-loader-jsh/impl/src/main/java/org/apache/camel/k/loader/jsh/JshRoutesBuilderLoader.java
+++ /dev/null
@@ -1,112 +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.k.loader.jsh;
-
-import java.io.Reader;
-
-import javax.script.ScriptException;
-
-import jdk.jshell.JShell;
-import jdk.jshell.execution.DirectExecutionControl;
-import jdk.jshell.execution.LoaderDelegate;
-import jdk.jshell.spi.ExecutionControl;
-import jdk.jshell.spi.ExecutionControlProvider;
-import org.apache.camel.CamelContext;
-import org.apache.camel.Experimental;
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.api.management.ManagedAttribute;
-import org.apache.camel.api.management.ManagedResource;
-import org.apache.camel.builder.endpoint.EndpointRouteBuilder;
-import org.apache.camel.spi.Registry;
-import org.apache.camel.spi.Resource;
-import org.apache.camel.spi.RoutesBuilderLoader;
-import org.apache.camel.spi.annotations.RoutesLoader;
-import org.apache.camel.support.RoutesBuilderLoaderSupport;
-import org.apache.camel.util.IOHelper;
-
-/**
- * A {@link RoutesBuilderLoader} implementation based on {@link JShell}.
- */
-@ManagedResource(description = "Managed JShell RoutesBuilderLoader")
-@Experimental
-@RoutesLoader("jsh")
-public class JshRoutesBuilderLoader extends RoutesBuilderLoaderSupport {
- public static final String EXTENSION = "jsh";
-
- @ManagedAttribute(description = "Supported file extension")
- @Override
- public String getSupportedExtension() {
- return EXTENSION;
- }
-
- @Override
- public RoutesBuilder loadRoutesBuilder(Resource resource) throws Exception
{
- return EndpointRouteBuilder.loadEndpointRoutesBuilder(resource,
JshRoutesBuilderLoader::eval);
- }
-
- private static void eval(Reader reader, EndpointRouteBuilder builder)
throws Exception {
- final ClassLoader tccl =
Thread.currentThread().getContextClassLoader();
- final String content = IOHelper.toString(reader);
-
- //
- // By default the jdk.jshell.execution.DefaultLoaderDelegate uses a
- // custom URL class-loader and does not provide any option to set the
- // parent which causes the ThreadLocal hack used to inject bindings
- // to fail as there are two copies fo the Jsh class (one from the
- // Quarkus class loader and one for the custom one).
- //
- final JshClassLoader jshcl = new JshClassLoader(tccl);
- final LoaderDelegate delegate = new JshLoaderDelegate(jshcl);
- final ExecutionControl control = new DirectExecutionControl(delegate);
- final ExecutionControlProvider provider =
Jsh.wrapExecutionControl("jsh-direct", control);
-
- Thread.currentThread().setContextClassLoader(jshcl);
-
- //
- // Leverage DirectExecutionControl as execution engine to make JShell
running
- // in the current process and give a chance to bind variables to the
script
- // using ThreadLocal hack.
- //
- try (JShell jshell = JShell.builder().executionEngine(provider,
null).build()) {
- //
- // since we can't set a base class for the snippet as we do for
other
- // languages (groovy, kotlin) we need to introduce a top level
variable
- // that users need to use to access the RouteBuilder, like:
- //
- // builder.from("timer:tick")
- // .to("log:info")
- //
- // context and thus registry can easily be retrieved from the
registered
- // variable `builder` but for a better UX, add them as top level
vars.
- //
- Jsh.setBinding(jshell, "builder", builder,
EndpointRouteBuilder.class);
- Jsh.setBinding(jshell, "context", builder.getContext(),
CamelContext.class);
- Jsh.setBinding(jshell, "registry",
builder.getContext().getRegistry(), Registry.class);
-
- for (String snippet : Jsh.compile(jshell, content)) {
- Jsh.eval(jshell, snippet);
- }
- } catch (ScriptException e) {
- throw new RuntimeException(e);
- } finally {
- // remove contextual bindings once the snippet has been evaluated
- Jsh.clearBindings();
- // restore original TCCL
- Thread.currentThread().setContextClassLoader(tccl);
- }
- }
-}
diff --git
a/camel-k-loader-jsh/impl/src/test/groovy/org/apache/camel/k/loader/jsh/JshSourceLoaderTest.groovy
b/camel-k-loader-jsh/impl/src/test/groovy/org/apache/camel/k/loader/jsh/JshSourceLoaderTest.groovy
deleted file mode 100644
index da36ec6..0000000
---
a/camel-k-loader-jsh/impl/src/test/groovy/org/apache/camel/k/loader/jsh/JshSourceLoaderTest.groovy
+++ /dev/null
@@ -1,44 +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.k.loader.jsh
-
-import org.apache.camel.k.loader.jsh.support.TestRuntime
-import org.apache.camel.model.ProcessDefinition
-import org.apache.camel.model.ToDefinition
-import spock.lang.AutoCleanup
-import spock.lang.Specification
-
-class JshSourceLoaderTest extends Specification {
- @AutoCleanup
- def runtime = new TestRuntime()
-
- def "load"(location) {
- expect:
- runtime.loadRoutes(location)
-
- with(runtime.context.routeDefinitions) {
- it[0].input.endpointUri ==~ /timer:.*tick/
- it[0].outputs[0] instanceof ProcessDefinition
- it[0].outputs[1] instanceof ToDefinition
- }
- where:
- location << [
- "classpath:jsh/routes.jsh"
- ]
-
- }
-}
diff --git
a/camel-k-loader-jsh/impl/src/test/groovy/org/apache/camel/k/loader/jsh/support/TestRuntime.groovy
b/camel-k-loader-jsh/impl/src/test/groovy/org/apache/camel/k/loader/jsh/support/TestRuntime.groovy
deleted file mode 100644
index fe26848..0000000
---
a/camel-k-loader-jsh/impl/src/test/groovy/org/apache/camel/k/loader/jsh/support/TestRuntime.groovy
+++ /dev/null
@@ -1,67 +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.k.loader.jsh.support
-
-import org.apache.camel.CamelContext
-import org.apache.camel.RoutesBuilder
-import org.apache.camel.impl.DefaultCamelContext
-import org.apache.camel.k.CompositeClassloader
-import org.apache.camel.k.Runtime
-import org.apache.camel.k.support.SourcesSupport
-import org.apache.camel.model.ModelCamelContext
-
-class TestRuntime implements Runtime, AutoCloseable {
- final ModelCamelContext context
- final List<RoutesBuilder> builders
- final List<Object> configurations
-
- TestRuntime() {
- this.context = new DefaultCamelContext()
- this.context.setApplicationContextClassLoader(new
CompositeClassloader())
- this.builders = []
- this.configurations = []
- }
-
- @Override
- CamelContext getCamelContext() {
- return this.context
- }
-
- @Override
- void addRoutes(RoutesBuilder builder) {
- this.builders << builder
- this.context.addRoutes(builder)
- }
-
- void loadRoutes(String... routes) {
- SourcesSupport.loadSources(this, routes)
- }
-
- void start() {
- context.start()
- }
-
- @Override
- void stop() {
- context.stop()
- }
-
- @Override
- void close() {
- stop()
- }
-}
diff --git a/camel-k-loader-jsh/impl/src/test/resources/jsh/routes.jsh
b/camel-k-loader-jsh/impl/src/test/resources/jsh/routes.jsh
deleted file mode 100644
index 99bfe4f..0000000
--- a/camel-k-loader-jsh/impl/src/test/resources/jsh/routes.jsh
+++ /dev/null
@@ -1,20 +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.
- */
-
-builder.from("timer:tick")
- .process(e -> {})
- .to("log:info");
\ No newline at end of file
diff --git a/camel-k-loader-jsh/impl/src/test/resources/log4j2-test.xml
b/camel-k-loader-jsh/impl/src/test/resources/log4j2-test.xml
deleted file mode 100644
index f2a5fb2..0000000
--- a/camel-k-loader-jsh/impl/src/test/resources/log4j2-test.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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.
-
--->
-<Configuration status="INFO">
- <Appenders>
- <Console name="STDOUT" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS}|%-5level|%t|%c{1} -
%msg%n"/>
- </Console>
- <Null name="NONE"/>
- </Appenders>
-
- <Loggers>
- <Logger name="org.apache.camel.k.loader.jsh.Jsh" level="DEBUG"/>
- <Root level="INFO">
- <!--<AppenderRef ref="STDOUT"/>-->
- <AppenderRef ref="NONE"/>
- </Root>
- </Loggers>
-
-</Configuration>
\ No newline at end of file
diff --git a/camel-k-loader-jsh/pom.xml b/camel-k-loader-jsh/pom.xml
deleted file mode 100644
index 477c181..0000000
--- a/camel-k-loader-jsh/pom.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?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-runtime-project</artifactId>
- <version>1.13.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
-
- <artifactId>camel-k-loader-jsh-parent</artifactId>
-
- <modules>
- <module>impl</module>
- <module>runtime</module>
- <module>deployment</module>
- </modules>
-
-</project>
diff --git a/camel-k-loader-jsh/runtime/pom.xml
b/camel-k-loader-jsh/runtime/pom.xml
deleted file mode 100644
index b34b168..0000000
--- a/camel-k-loader-jsh/runtime/pom.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-<?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-loader-jsh-parent</artifactId>
- <version>1.13.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>camel-k-loader-jsh</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-loader-jsh-impl</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-bootstrap-maven-plugin</artifactId>
- <version>${quarkus-version}</version>
- <executions>
- <execution>
- <goals>
- <goal>extension-descriptor</goal>
- </goals>
- <configuration>
-
<deployment>${project.groupId}:${project.artifactId}-deployment:${project.version}</deployment>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <annotationProcessorPaths>
- <path>
- <groupId>io.quarkus</groupId>
-
<artifactId>quarkus-extension-processor</artifactId>
- <version>${quarkus-version}</version>
- </path>
- </annotationProcessorPaths>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.jboss.jandex</groupId>
- <artifactId>jandex-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>make-index</id>
- <goals>
- <goal>jandex</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git
a/camel-k-loader-jsh/runtime/src/main/java/org/apache/camel/k/loader/jsh/quarkus/JshSourceLoaderRecorder.java
b/camel-k-loader-jsh/runtime/src/main/java/org/apache/camel/k/loader/jsh/quarkus/JshSourceLoaderRecorder.java
deleted file mode 100644
index 561a885..0000000
---
a/camel-k-loader-jsh/runtime/src/main/java/org/apache/camel/k/loader/jsh/quarkus/JshSourceLoaderRecorder.java
+++ /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.
- */
-package org.apache.camel.k.loader.jsh.quarkus;
-
-import io.quarkus.runtime.annotations.Recorder;
-
-@Recorder
-public class JshSourceLoaderRecorder {
-}
diff --git a/itests/camel-k-itests-loader-jsh/pom.xml
b/itests/camel-k-itests-loader-jsh/pom.xml
index 34d8ffd..2cc6a0b 100644
--- a/itests/camel-k-itests-loader-jsh/pom.xml
+++ b/itests/camel-k-itests-loader-jsh/pom.xml
@@ -30,11 +30,11 @@
<dependencies>
<dependency>
<groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-loader-jsh</artifactId>
+ <artifactId>camel-k-itests-loader-inspector</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-itests-loader-inspector</artifactId>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jsh-dsl</artifactId>
</dependency>
<!-- camel quarkus -->
@@ -67,21 +67,6 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
-
- <!-- The following dependencies guarantee that this module is built
after them. -->
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-loader-jsh-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
</dependencies>
</project>
diff --git a/pom.xml b/pom.xml
index 8b25975..6b4fca4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -365,7 +365,6 @@
<module>components</module>
<module>camel-k-core</module>
- <module>camel-k-loader-jsh</module>
<module>camel-k-cron</module>
<module>camel-k-cloudevents</module>
@@ -631,21 +630,6 @@
<!-- loaders -->
<dependency>
<groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-loader-jsh</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-loader-jsh-deployment</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-loader-jsh-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-loader-yaml</artifactId>
<version>${project.version}</version>
</dependency>
diff --git
a/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
b/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
index 9d2717c..6cf4816 100644
---
a/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
+++
b/support/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
@@ -407,15 +407,6 @@ public class GenerateCatalogMojo extends AbstractMojo {
.build()
);
}
- if (dslsExclusionList != null && !dslsExclusionList.contains("jsh")) {
- specBuilder.putLoader(
- "jsh",
- CamelLoader.fromArtifact("org.apache.camel.k",
"camel-k-loader-jsh")
- .addLanguages("jsh")
- .putMetadata("native", "false")
- .build()
- );
- }
}
private void processComponents(org.apache.camel.catalog.CamelCatalog
catalog, Map<String, CamelArtifact> artifacts) {
diff --git a/support/camel-k-runtime-bom/pom.xml
b/support/camel-k-runtime-bom/pom.xml
index 8158edb..4a5d1c0 100644
--- a/support/camel-k-runtime-bom/pom.xml
+++ b/support/camel-k-runtime-bom/pom.xml
@@ -181,17 +181,6 @@
<artifactId>camel-k-master</artifactId>
<version>${project.version}</version>
</dependency>
-
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-loader-jsh-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-loader-jsh</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-kamelet-reify</artifactId>