You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by GitBox <gi...@apache.org> on 2018/12/14 07:58:22 UTC

[GitHub] nicolaferraro closed pull request #290: Runtime enhacements

nicolaferraro closed pull request #290: Runtime enhacements
URL: https://github.com/apache/camel-k/pull/290
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/runtime/camel-k-runtime-core/pom.xml b/runtime/camel-k-runtime-core/pom.xml
new file mode 100644
index 00000000..35774928
--- /dev/null
+++ b/runtime/camel-k-runtime-core/pom.xml
@@ -0,0 +1,82 @@
+<?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-parent</artifactId>
+        <version>0.1.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>camel-k-runtime-core</artifactId>
+
+    <dependencies>
+
+        <!-- ****************************** -->
+        <!--                                -->
+        <!-- RUNTIME                        -->
+        <!--                                -->
+        <!-- ****************************** -->
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>${slf4j.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>${commons-lang.version}</version>
+        </dependency>
+
+        <!-- ****************************** -->
+        <!--                                -->
+        <!-- TESTS                          -->
+        <!--                                -->
+        <!-- ****************************** -->
+
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <version>${junit-jupiter.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <version>${junit-jupiter.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <version>${assertj.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/Constants.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Constants.java
similarity index 80%
rename from runtime/jvm/src/main/java/org/apache/camel/k/jvm/Constants.java
rename to runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Constants.java
index d3cb4b7b..e00fed49 100644
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/Constants.java
+++ b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Constants.java
@@ -14,16 +14,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.k.jvm;
+package org.apache.camel.k;
 
 public final class Constants {
     public static final String ENV_CAMEL_K_ROUTES = "CAMEL_K_ROUTES";
     public static final String ENV_CAMEL_K_CONF = "CAMEL_K_CONF";
     public static final String ENV_CAMEL_K_CONF_D = "CAMEL_K_CONF_D";
+    public static final String ENV_CAMEL_K_TRAITS = "CAMEL_K_TRAITS";
     public static final String SCHEME_CLASSPATH = "classpath:";
     public static final String SCHEME_FILE = "file:";
     public static final String SCHEME_ENV = "env:";
     public static final String LOGGING_LEVEL_PREFIX = "logging.level.";
+    public static final String ROUTES_LOADER_RESOURCE_PATH = "META-INF/services/org/apache/camel/k/loader/";
+    public static final String RUNTIME_TRAIT_RESOURCE_PATH = "META-INF/services/org/apache/camel/k/trait/";
 
     private Constants() {
     }
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/Language.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Language.java
similarity index 86%
rename from runtime/jvm/src/main/java/org/apache/camel/k/jvm/Language.java
rename to runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Language.java
index d041faa0..c338bd60 100644
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/Language.java
+++ b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Language.java
@@ -14,45 +14,59 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.k.jvm;
+package org.apache.camel.k;
 
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.lang3.StringUtils;
 
 public enum Language {
     Unknown(
+        "unknown",
         Collections.emptyList(),
         Collections.emptyList()),
     JavaClass(
+        "java-class",
         Collections.singletonList("class"),
         Collections.singletonList("class")),
     JavaSource(
+        "java-source",
         Collections.singletonList("java"),
         Collections.singletonList("java")),
     JavaScript(
+        "js",
         Arrays.asList("js", "javascript"),
         Collections.singletonList("js")),
     Groovy(
+        "groovy",
         Collections.singletonList("groovy"),
         Collections.singletonList("groovy")),
     Xml(
+        "xml",
         Collections.singletonList("xml"),
         Collections.singletonList("xml")),
     Kotlin(
+        "kotlin",
         Arrays.asList("kotlin", "kts"),
         Collections.singletonList("kts"));
 
+    private final String id;
     private final List<String> names;
     private final List<String> extensions;
 
-    Language(List<String> names, List<String> extensions) {
+    Language(String id, List<String> names, List<String> extensions) {
+        this.id = ObjectHelper.notNull(id, "id");
         this.names = names;
         this.extensions = extensions;
     }
 
+    public String getId() {
+        return id;
+    }
+
     public List<String> getNames() {
         return names;
     }
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RoutesLoader.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RoutesLoader.java
similarity index 97%
rename from runtime/jvm/src/main/java/org/apache/camel/k/jvm/RoutesLoader.java
rename to runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RoutesLoader.java
index faac8edb..3026b926 100644
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RoutesLoader.java
+++ b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RoutesLoader.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.k.jvm;
+package org.apache.camel.k;
 
 import java.util.List;
 
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RuntimeRegistry.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RuntimeRegistry.java
similarity index 96%
rename from runtime/jvm/src/main/java/org/apache/camel/k/jvm/RuntimeRegistry.java
rename to runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RuntimeRegistry.java
index 7e13a283..895fe339 100644
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RuntimeRegistry.java
+++ b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RuntimeRegistry.java
@@ -14,17 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.k.jvm;
+package org.apache.camel.k;
 
 import java.util.Map;
 
 import org.apache.camel.spi.Registry;
 
 public interface RuntimeRegistry extends Registry {
-
-    /**
-     *
-     */
     void bind(String name, Object bean);
 
     @SuppressWarnings("deprecation")
diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RuntimeTrait.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RuntimeTrait.java
new file mode 100644
index 00000000..275f53a3
--- /dev/null
+++ b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RuntimeTrait.java
@@ -0,0 +1,28 @@
+package org.apache.camel.k;
+
+import org.apache.camel.CamelContext;
+
+/**
+ * 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.
+ */
+
+@FunctionalInterface
+public interface RuntimeTrait {
+    /**
+     * Perform CamelContext customization.
+     */
+    void apply(CamelContext camelContext);
+}
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/Source.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Source.java
similarity index 98%
rename from runtime/jvm/src/main/java/org/apache/camel/k/jvm/Source.java
rename to runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Source.java
index 8b00a4b9..0726b072 100644
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/Source.java
+++ b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Source.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.k.jvm;
+package org.apache.camel.k;
 
 import java.util.Map;
 
diff --git a/runtime/groovy/pom.xml b/runtime/camel-k-runtime-groovy/pom.xml
similarity index 100%
rename from runtime/groovy/pom.xml
rename to runtime/camel-k-runtime-groovy/pom.xml
diff --git a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy
similarity index 93%
rename from runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy
rename to runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy
index 932f5265..bb081d44 100644
--- a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy
+++ b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy
@@ -18,6 +18,10 @@ package org.apache.camel.k.groovy
 
 
 import org.apache.camel.builder.RouteBuilder
+import org.apache.camel.k.Language
+import org.apache.camel.k.RoutesLoader
+import org.apache.camel.k.RuntimeRegistry
+import org.apache.camel.k.Source
 import org.apache.camel.k.groovy.dsl.IntegrationConfiguration
 import org.apache.camel.k.jvm.*
 import org.codehaus.groovy.control.CompilerConfiguration
diff --git a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentConfiguration.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentConfiguration.groovy
similarity index 100%
rename from runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentConfiguration.groovy
rename to runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentConfiguration.groovy
diff --git a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentsConfiguration.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentsConfiguration.groovy
similarity index 100%
rename from runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentsConfiguration.groovy
rename to runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentsConfiguration.groovy
diff --git a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy
similarity index 97%
rename from runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy
rename to runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy
index 405fe8c1..d70dd04d 100644
--- a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy
+++ b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy
@@ -17,7 +17,7 @@
 package org.apache.camel.k.groovy.dsl
 
 import org.apache.camel.CamelContext
-import org.apache.camel.k.jvm.RuntimeRegistry
+import org.apache.camel.k.RuntimeRegistry
 
 class ContextConfiguration {
     private final CamelContext context
diff --git a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy
similarity index 98%
rename from runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy
rename to runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy
index 5b07bd53..fdc860aa 100644
--- a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy
+++ b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy
@@ -21,7 +21,7 @@ import org.apache.camel.Exchange
 import org.apache.camel.Predicate
 import org.apache.camel.Processor
 import org.apache.camel.builder.RouteBuilder
-import org.apache.camel.k.jvm.RuntimeRegistry
+import org.apache.camel.k.RuntimeRegistry
 import org.apache.camel.k.jvm.dsl.Components
 import org.apache.camel.model.RouteDefinition
 
diff --git a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy
similarity index 96%
rename from runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy
rename to runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy
index 0b7b23d8..f695ec19 100644
--- a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy
+++ b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.k.groovy.dsl
 
-import org.apache.camel.k.jvm.RuntimeRegistry
+import org.apache.camel.k.RuntimeRegistry
 
 class RegistryConfiguration {
     private final RuntimeRegistry registry
diff --git a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RestConfiguration.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RestConfiguration.groovy
similarity index 100%
rename from runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RestConfiguration.groovy
rename to runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RestConfiguration.groovy
diff --git a/runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/extension/LogComponentExtension.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/extension/LogComponentExtension.groovy
similarity index 100%
rename from runtime/groovy/src/main/groovy/org/apache/camel/k/groovy/extension/LogComponentExtension.groovy
rename to runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/extension/LogComponentExtension.groovy
diff --git a/runtime/groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
similarity index 100%
rename from runtime/groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
rename to runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
diff --git a/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org/apache/camel/k/loader/groovy b/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org/apache/camel/k/loader/groovy
new file mode 100644
index 00000000..ba7720a4
--- /dev/null
+++ b/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org/apache/camel/k/loader/groovy
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.k.groovy.GroovyRoutesLoader
\ No newline at end of file
diff --git a/runtime/groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy b/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy
similarity index 88%
rename from runtime/groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy
rename to runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy
index ab3779c3..0bc194ff 100644
--- a/runtime/groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy
+++ b/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy
@@ -16,9 +16,10 @@
  */
 package org.apache.camel.k.groovy
 
-import org.apache.camel.k.jvm.RoutesLoaders
+import org.apache.camel.impl.DefaultCamelContext
+import org.apache.camel.k.jvm.RuntimeSupport
 import org.apache.camel.k.jvm.SimpleRuntimeRegistry
-import org.apache.camel.k.jvm.Source
+import org.apache.camel.k.Source
 import org.apache.camel.model.ToDefinition
 import spock.lang.Specification
 
@@ -29,7 +30,7 @@ class LoaderTest extends Specification {
             def source = Source.create("classpath:routes.groovy")
 
         when:
-            def loader = RoutesLoaders.loaderFor(source)
+            def loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source)
             def builder = loader.load(new SimpleRuntimeRegistry(), source)
 
         then:
diff --git a/runtime/groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy b/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy
similarity index 100%
rename from runtime/groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy
rename to runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy
diff --git a/runtime/groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy b/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy
similarity index 100%
rename from runtime/groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy
rename to runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy
diff --git a/runtime/groovy/src/test/resources/log4j2-test.xml b/runtime/camel-k-runtime-groovy/src/test/resources/log4j2-test.xml
similarity index 100%
rename from runtime/groovy/src/test/resources/log4j2-test.xml
rename to runtime/camel-k-runtime-groovy/src/test/resources/log4j2-test.xml
diff --git a/runtime/groovy/src/test/resources/routes-with-bindings.groovy b/runtime/camel-k-runtime-groovy/src/test/resources/routes-with-bindings.groovy
similarity index 100%
rename from runtime/groovy/src/test/resources/routes-with-bindings.groovy
rename to runtime/camel-k-runtime-groovy/src/test/resources/routes-with-bindings.groovy
diff --git a/runtime/groovy/src/test/resources/routes-with-component-configuration.groovy b/runtime/camel-k-runtime-groovy/src/test/resources/routes-with-component-configuration.groovy
similarity index 100%
rename from runtime/groovy/src/test/resources/routes-with-component-configuration.groovy
rename to runtime/camel-k-runtime-groovy/src/test/resources/routes-with-component-configuration.groovy
diff --git a/runtime/groovy/src/test/resources/routes-with-rest.groovy b/runtime/camel-k-runtime-groovy/src/test/resources/routes-with-rest.groovy
similarity index 100%
rename from runtime/groovy/src/test/resources/routes-with-rest.groovy
rename to runtime/camel-k-runtime-groovy/src/test/resources/routes-with-rest.groovy
diff --git a/runtime/groovy/src/test/resources/routes.groovy b/runtime/camel-k-runtime-groovy/src/test/resources/routes.groovy
similarity index 100%
rename from runtime/groovy/src/test/resources/routes.groovy
rename to runtime/camel-k-runtime-groovy/src/test/resources/routes.groovy
diff --git a/runtime/jvm/pom.xml b/runtime/camel-k-runtime-jvm/pom.xml
similarity index 90%
rename from runtime/jvm/pom.xml
rename to runtime/camel-k-runtime-jvm/pom.xml
index b02dc3cd..aa486034 100644
--- a/runtime/jvm/pom.xml
+++ b/runtime/camel-k-runtime-jvm/pom.xml
@@ -29,10 +29,6 @@
 
     <artifactId>camel-k-runtime-jvm</artifactId>
 
-    <properties>
-        <kotlin.version>1.2.71</kotlin.version>
-    </properties>
-
     <dependencies>
 
         <!-- ****************************** -->
@@ -42,13 +38,9 @@
         <!-- ****************************** -->
 
         <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>${slf4j.version}</version>
+            <groupId>org.apache.camel.k</groupId>
+            <artifactId>camel-k-runtime-core</artifactId>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.logging.log4j</groupId>
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/Application.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/Application.java
similarity index 83%
rename from runtime/jvm/src/main/java/org/apache/camel/k/jvm/Application.java
rename to runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/Application.java
index 917b5660..682609cd 100644
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/Application.java
+++ b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/Application.java
@@ -16,11 +16,9 @@
  */
 package org.apache.camel.k.jvm;
 
-import java.util.Properties;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
-import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.k.Constants;
 import org.apache.camel.main.MainListenerSupport;
 import org.apache.camel.support.LifecycleStrategySupport;
 import org.apache.camel.util.ObjectHelper;
@@ -65,20 +63,21 @@ public static void main(String[] args) throws Exception {
     // *******************************
 
     static class ComponentPropertiesBinder extends MainListenerSupport {
+
         @Override
         public void configure(CamelContext context) {
-            final PropertiesComponent component = context.getComponent("properties", PropertiesComponent.class);
-            final Properties properties = component.getInitialProperties();
-
-            if (properties == null) {
-                throw new IllegalStateException("PropertiesComponent has no properties");
-            }
-
             // Configure the camel context using properties in the form:
             //
             //     camel.context.${name} = ${value}
             //
-            RuntimeSupport.bindProperties(properties, context, "camel.context.");
+            RuntimeSupport.bindProperties(context, context, "camel.context.");
+
+            // Programmatically apply the camel context.
+            //
+            // This is useful to configure services such as the ClusterService,
+            // RouteController, etc
+            //
+            RuntimeSupport.configureContext(context);
 
             context.addLifecycleStrategy(new LifecycleStrategySupport() {
                 @SuppressWarnings("unchecked")
@@ -90,7 +89,7 @@ public void onComponentAdd(String name, Component component) {
                     //
                     //     camel.component.${scheme}.${name} = ${value}
                     //
-                    RuntimeSupport.bindProperties(properties, component, "camel.component." + name + ".");
+                    RuntimeSupport.bindProperties(context, component, "camel.component." + name + ".");
                 }
             });
         }
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/Runtime.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/Runtime.java
similarity index 94%
rename from runtime/jvm/src/main/java/org/apache/camel/k/jvm/Runtime.java
rename to runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/Runtime.java
index 1e05e70b..3923e85a 100644
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/Runtime.java
+++ b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/Runtime.java
@@ -27,6 +27,9 @@
 import org.apache.camel.component.properties.PropertiesComponent;
 import org.apache.camel.impl.CompositeRegistry;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.k.RoutesLoader;
+import org.apache.camel.k.RuntimeRegistry;
+import org.apache.camel.k.Source;
 import org.apache.camel.main.MainSupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -44,7 +47,7 @@ public Runtime() {
     public void load(String[] routes) throws Exception {
         for (String route: routes) {
             final Source source = Source.create(route);
-            final RoutesLoader loader = RoutesLoaders.loaderFor(source);
+            final RoutesLoader loader = RuntimeSupport.loaderFor(getCamelContext(), source);
             final RouteBuilder builder = loader.load(registry, source);
 
             if (builder == null) {
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RuntimeSupport.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/RuntimeSupport.java
similarity index 72%
rename from runtime/jvm/src/main/java/org/apache/camel/k/jvm/RuntimeSupport.java
rename to runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/RuntimeSupport.java
index 936e4d15..b3192b66 100644
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RuntimeSupport.java
+++ b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/RuntimeSupport.java
@@ -28,6 +28,14 @@
 import java.util.Objects;
 import java.util.Properties;
 
+import org.apache.camel.CamelContext;
+import org.apache.camel.NoFactoryAvailableException;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.k.Constants;
+import org.apache.camel.k.RoutesLoader;
+import org.apache.camel.k.RuntimeTrait;
+import org.apache.camel.k.Source;
+import org.apache.camel.spi.FactoryFinder;
 import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.io.FilenameUtils;
@@ -102,6 +110,29 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
         return properties;
     }
 
+    public static void configureContext(CamelContext context) {
+        try {
+            FactoryFinder finder = context.getFactoryFinder(Constants.RUNTIME_TRAIT_RESOURCE_PATH);
+            String traitIDs = System.getenv().getOrDefault(Constants.ENV_CAMEL_K_TRAITS, "");
+
+            for (String traitId: traitIDs.split(",", -1)) {
+                RuntimeTrait trait = (RuntimeTrait)finder.newInstance(traitId);
+
+                bindProperties(context, trait, "trait." + traitId);
+
+                trait.apply(context);
+            }
+        } catch (NoFactoryAvailableException e) {
+            // ignored
+        }
+
+        context.getRegistry().findByType(RuntimeTrait.class).forEach(
+            customizer -> {
+                customizer.apply(context);
+            }
+        );
+    }
+
     public static void configureLogging() {
         final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
         final Properties properties = loadProperties();
@@ -123,6 +154,17 @@ public static void configureLogging() {
         );
     }
 
+    public static void bindProperties(CamelContext context, Object target, String prefix) {
+        final PropertiesComponent component = context.getComponent("properties", PropertiesComponent.class);
+        final Properties properties = component.getInitialProperties();
+
+        if (properties == null) {
+            throw new IllegalStateException("PropertiesComponent has no properties");
+        }
+
+        bindProperties(properties, target, prefix);
+    }
+
     public static void bindProperties(Properties properties, Object target, String prefix) {
         properties.entrySet().stream()
             .filter(entry -> entry.getKey() instanceof String)
@@ -140,4 +182,18 @@ public static void bindProperties(Properties properties, Object target, String p
                 }
             );
     }
+
+    public static RoutesLoader loaderFor(CamelContext context, Source source) {
+        final FactoryFinder finder;
+        final RoutesLoader loader;
+
+        try {
+            finder = context.getFactoryFinder(Constants.ROUTES_LOADER_RESOURCE_PATH);
+            loader = (RoutesLoader)finder.newInstance(source.getLanguage().getId());
+        } catch (NoFactoryAvailableException e) {
+            throw new IllegalArgumentException("Unable to find loader for: " + source, e);
+        }
+
+        return loader;
+    }
 }
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/SimpleRuntimeRegistry.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/SimpleRuntimeRegistry.java
similarity index 98%
rename from runtime/jvm/src/main/java/org/apache/camel/k/jvm/SimpleRuntimeRegistry.java
rename to runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/SimpleRuntimeRegistry.java
index 1035b9c4..c62175fe 100644
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/SimpleRuntimeRegistry.java
+++ b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/SimpleRuntimeRegistry.java
@@ -24,6 +24,7 @@
 import java.util.stream.Collectors;
 
 import org.apache.camel.NoSuchBeanException;
+import org.apache.camel.k.RuntimeRegistry;
 
 public class SimpleRuntimeRegistry implements RuntimeRegistry {
     private final ConcurrentMap<String, Object> registry;
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/URIResolver.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/URIResolver.java
similarity index 97%
rename from runtime/jvm/src/main/java/org/apache/camel/k/jvm/URIResolver.java
rename to runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/URIResolver.java
index c7ec4fea..30bee2ea 100644
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/URIResolver.java
+++ b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/URIResolver.java
@@ -24,6 +24,8 @@
 import java.util.zip.GZIPInputStream;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.k.Constants;
+import org.apache.camel.k.Source;
 import org.apache.camel.util.ResourceHelper;
 import org.apache.camel.util.StringHelper;
 
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/dsl/Components.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/dsl/Components.java
similarity index 100%
rename from runtime/jvm/src/main/java/org/apache/camel/k/jvm/dsl/Components.java
rename to runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/dsl/Components.java
diff --git a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaClassLoader.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaClassLoader.java
new file mode 100644
index 00000000..bf73a827
--- /dev/null
+++ b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaClassLoader.java
@@ -0,0 +1,34 @@
+package org.apache.camel.k.jvm.loader;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.k.Constants;
+import org.apache.camel.k.Language;
+import org.apache.camel.k.RoutesLoader;
+import org.apache.camel.k.RuntimeRegistry;
+import org.apache.camel.k.Source;
+import org.apache.commons.lang3.StringUtils;
+
+public class JavaClassLoader implements RoutesLoader {
+    @Override
+    public List<Language> getSupportedLanguages() {
+        return Collections.singletonList(Language.JavaClass);
+    }
+
+    @Override
+    public RouteBuilder load(RuntimeRegistry registry, Source source) throws Exception {
+        String path = source.getLocation();
+        path = StringUtils.removeStart(path, Constants.SCHEME_CLASSPATH);
+        path = StringUtils.removeEnd(path, ".class");
+
+        Class<?> type = Class.forName(path);
+
+        if (!RouteBuilder.class.isAssignableFrom(type)) {
+            throw new IllegalStateException("The class provided (" + path + ") is not a org.apache.camel.builder.RouteBuilder");
+        }
+
+        return (RouteBuilder)type.newInstance();
+    }
+}
diff --git a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaScriptLoader.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaScriptLoader.java
new file mode 100644
index 00000000..650a4d1f
--- /dev/null
+++ b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaScriptLoader.java
@@ -0,0 +1,58 @@
+package org.apache.camel.k.jvm.loader;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import javax.script.Bindings;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.SimpleBindings;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.k.Language;
+import org.apache.camel.k.RoutesLoader;
+import org.apache.camel.k.RuntimeRegistry;
+import org.apache.camel.k.Source;
+import org.apache.camel.k.jvm.URIResolver;
+import org.apache.camel.k.jvm.dsl.Components;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.model.rest.RestConfigurationDefinition;
+import org.apache.camel.model.rest.RestDefinition;
+
+public class JavaScriptLoader implements RoutesLoader {
+    @Override
+    public List<Language> getSupportedLanguages() {
+        return Collections.singletonList(Language.JavaScript);
+    }
+
+    @Override
+    public RouteBuilder load(RuntimeRegistry registry, Source source) throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                final CamelContext context = getContext();
+                final ScriptEngineManager manager = new ScriptEngineManager();
+                final ScriptEngine engine = manager.getEngineByName("nashorn");
+                final Bindings bindings = new SimpleBindings();
+
+                // Exposed to the underlying script, but maybe better to have
+                // a nice dsl
+                bindings.put("builder", this);
+                bindings.put("context", context);
+                bindings.put("components", new Components(context));
+                bindings.put("registry", registry);
+                bindings.put("from", (Function<String, RouteDefinition>) uri -> from(uri));
+                bindings.put("rest", (Supplier<RestDefinition>) () -> rest());
+                bindings.put("restConfiguration", (Supplier<RestConfigurationDefinition>) () -> restConfiguration());
+
+                try (InputStream is = URIResolver.resolve(context, source)) {
+                    engine.eval(new InputStreamReader(is), bindings);
+                }
+            }
+        };
+    }
+}
diff --git a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaSourceLoader.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaSourceLoader.java
new file mode 100644
index 00000000..767a6d4a
--- /dev/null
+++ b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaSourceLoader.java
@@ -0,0 +1,45 @@
+package org.apache.camel.k.jvm.loader;
+
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.k.Language;
+import org.apache.camel.k.RoutesLoader;
+import org.apache.camel.k.RuntimeRegistry;
+import org.apache.camel.k.Source;
+import org.apache.camel.k.jvm.URIResolver;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.joor.Reflect;
+
+public class JavaSourceLoader implements RoutesLoader {
+    @Override
+    public List<Language> getSupportedLanguages() {
+        return Collections.singletonList(Language.JavaSource);
+    }
+
+    @Override
+    public RouteBuilder load(RuntimeRegistry registry, Source source) throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                try (InputStream is = URIResolver.resolve(getContext(), source)) {
+                    String name = StringUtils.substringAfter(source.getLocation(), ":");
+                    name = StringUtils.removeEnd(name, ".java");
+
+                    if (name.contains("/")) {
+                        name = StringUtils.substringAfterLast(name, "/");
+                    }
+
+                    // Wrap routes builder
+                    includeRoutes(
+                        Reflect.compile(name, IOUtils.toString(is, StandardCharsets.UTF_8)).create().get()
+                    );
+                }
+            }
+        };
+    }
+}
diff --git a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/XmlLoader.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/XmlLoader.java
new file mode 100644
index 00000000..7532f141
--- /dev/null
+++ b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/XmlLoader.java
@@ -0,0 +1,50 @@
+package org.apache.camel.k.jvm.loader;
+
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.List;
+import javax.xml.bind.UnmarshalException;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.k.Language;
+import org.apache.camel.k.RoutesLoader;
+import org.apache.camel.k.RuntimeRegistry;
+import org.apache.camel.k.Source;
+import org.apache.camel.k.jvm.URIResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class XmlLoader implements RoutesLoader {
+    private static final Logger LOGGER = LoggerFactory.getLogger(XmlLoader.class);
+
+    @Override
+    public List<Language> getSupportedLanguages() {
+        return Collections.singletonList(Language.Xml);
+    }
+
+    @Override
+    public RouteBuilder load(RuntimeRegistry registry, Source source) throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                try (InputStream is = URIResolver.resolve(getContext(), source)) {
+                    try {
+                        setRouteCollection(
+                            getContext().loadRoutesDefinition(is)
+                        );
+                    } catch (UnmarshalException e) {
+                        LOGGER.debug("Unable to load RoutesDefinition: {}", e.getMessage());
+                    }
+
+                    try {
+                        setRestCollection(
+                            getContext().loadRestsDefinition(is)
+                        );
+                    } catch (UnmarshalException e) {
+                        LOGGER.debug("Unable to load RestsDefinition: {}", e.getMessage());
+                    }
+                }
+            }
+        };
+    }
+}
diff --git a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/java-class b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/java-class
new file mode 100644
index 00000000..2d85f95e
--- /dev/null
+++ b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/java-class
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.k.jvm.loader.JavaClassLoader
\ No newline at end of file
diff --git a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/java-source b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/java-source
new file mode 100644
index 00000000..3bf82972
--- /dev/null
+++ b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/java-source
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.k.jvm.loader.JavaSourceLoader
\ No newline at end of file
diff --git a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/js b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/js
new file mode 100644
index 00000000..45227e82
--- /dev/null
+++ b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/js
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.k.jvm.loader.JavaScriptLoader
\ No newline at end of file
diff --git a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/xml b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/xml
new file mode 100644
index 00000000..e30ce1eb
--- /dev/null
+++ b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/xml
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.k.jvm.loader.XmlLoader
\ No newline at end of file
diff --git a/runtime/jvm/src/main/resources/log4j2.properties b/runtime/camel-k-runtime-jvm/src/main/resources/log4j2.properties
similarity index 100%
rename from runtime/jvm/src/main/resources/log4j2.properties
rename to runtime/camel-k-runtime-jvm/src/main/resources/log4j2.properties
diff --git a/runtime/jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java
similarity index 55%
rename from runtime/jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java
rename to runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java
index 6ae83242..43e0d9c2 100644
--- a/runtime/jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java
+++ b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java
@@ -19,12 +19,11 @@
 import java.util.Properties;
 import java.util.concurrent.ThreadLocalRandom;
 
-import org.apache.camel.CamelContext;
 import org.apache.camel.component.seda.SedaComponent;
-import org.apache.camel.main.MainListenerSupport;
-import org.apache.camel.main.MainSupport;
+import org.apache.camel.k.RuntimeTrait;
 import org.junit.jupiter.api.Test;
 
+import static org.apache.camel.k.jvm.RuntimeTestSupport.afterStart;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class PropertiesTest {
@@ -37,23 +36,13 @@ public void testLoadProperties() throws Exception {
         runtime.setProperties(properties);
         runtime.setDuration(5);
         runtime.addMainListener(new Application.ComponentPropertiesBinder());
-        runtime.addMainListener(new MainListenerSupport() {
-            @Override
-            public void afterStart(MainSupport main) {
-                try {
-                    CamelContext context = main.getCamelContexts().get(0);
-
-                    assertThat(context.resolvePropertyPlaceholders("{{root.key}}")).isEqualTo("root.value");
-                    assertThat(context.resolvePropertyPlaceholders("{{001.key}}")).isEqualTo("001.value");
-                    assertThat(context.resolvePropertyPlaceholders("{{002.key}}")).isEqualTo("002.value");
-                    assertThat(context.resolvePropertyPlaceholders("{{a.key}}")).isEqualTo("a.002");
-
-                    main.stop();
-                } catch (Exception e) {
-                    throw new RuntimeException(e);
-                }
-            }
-        });
+        runtime.addMainListener(afterStart((main, context) -> {
+            assertThat(context.resolvePropertyPlaceholders("{{root.key}}")).isEqualTo("root.value");
+            assertThat(context.resolvePropertyPlaceholders("{{001.key}}")).isEqualTo("001.value");
+            assertThat(context.resolvePropertyPlaceholders("{{002.key}}")).isEqualTo("002.value");
+            assertThat(context.resolvePropertyPlaceholders("{{a.key}}")).isEqualTo("a.002");
+            main.stop();
+        }));
 
         runtime.run();
     }
@@ -67,21 +56,12 @@ public void testSystemProperties() throws Exception {
             runtime.setProperties(System.getProperties());
             runtime.setDuration(5);
             runtime.addMainListener(new Application.ComponentPropertiesBinder());
-            runtime.addMainListener(new MainListenerSupport() {
-                @Override
-                public void afterStart(MainSupport main) {
-                    try {
-                        CamelContext context = main.getCamelContexts().get(0);
-                        String value = context.resolvePropertyPlaceholders("{{my.property}}");
-
-                        assertThat(value).isEqualTo("my.value");
-
-                        main.stop();
-                    } catch (Exception e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-            });
+            runtime.addMainListener(afterStart((main, context) -> {
+                String value = context.resolvePropertyPlaceholders("{{my.property}}");
+
+                assertThat(value).isEqualTo("my.value");
+                main.stop();
+            }));
 
             runtime.run();
         } finally {
@@ -103,21 +83,11 @@ public void testComponentConfiguration() throws Exception {
             runtime.setDuration(5);
             runtime.getRegistry().bind("my-seda", new SedaComponent());
             runtime.addMainListener(new Application.ComponentPropertiesBinder());
-            runtime.addMainListener(new MainListenerSupport() {
-                @Override
-                public void afterStart(MainSupport main) {
-                    try {
-                        CamelContext context = main.getCamelContexts().get(0);
-
-                        assertThat(context.getComponent("seda", true)).hasFieldOrPropertyWithValue("queueSize", queueSize1);
-                        assertThat(context.getComponent("my-seda", true)).hasFieldOrPropertyWithValue("queueSize", queueSize2);
-
-                        main.stop();
-                    } catch (Exception e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-            });
+            runtime.addMainListener(afterStart((main, context) -> {
+                assertThat(context.getComponent("seda", true)).hasFieldOrPropertyWithValue("queueSize", queueSize1);
+                assertThat(context.getComponent("my-seda", true)).hasFieldOrPropertyWithValue("queueSize", queueSize2);
+                main.stop();
+            }));
 
             runtime.run();
         } finally {
@@ -135,23 +105,12 @@ public void testContextConfiguration() throws Exception {
             Runtime runtime = new Runtime();
             runtime.setProperties(System.getProperties());
             runtime.setDuration(5);
-            runtime.getRegistry().bind("my-seda", new SedaComponent());
             runtime.addMainListener(new Application.ComponentPropertiesBinder());
-            runtime.addMainListener(new MainListenerSupport() {
-                @Override
-                public void afterStart(MainSupport main) {
-                    try {
-                        CamelContext context = main.getCamelContexts().get(0);
-
-                        assertThat(context.isMessageHistory()).isFalse();
-                        assertThat(context.isLoadTypeConverters()).isFalse();
-
-                        main.stop();
-                    } catch (Exception e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-            });
+            runtime.addMainListener(afterStart((main, context) -> {
+                assertThat(context.isMessageHistory()).isFalse();
+                assertThat(context.isLoadTypeConverters()).isFalse();
+                main.stop();
+            }));
 
             runtime.run();
         } finally {
@@ -159,4 +118,23 @@ public void afterStart(MainSupport main) {
             System.getProperties().remove("camel.context.loadTypeConverters");
         }
     }
+
+    @Test
+    public void testContextTrait() throws Exception {
+        Runtime runtime = new Runtime();
+        runtime.setProperties(System.getProperties());
+        runtime.setDuration(5);
+        runtime.getRegistry().bind("c1", (RuntimeTrait) context -> {
+            context.setMessageHistory(false);
+            context.setLoadTypeConverters(false);
+        });
+        runtime.addMainListener(new Application.ComponentPropertiesBinder());
+        runtime.addMainListener(afterStart((main, context) -> {
+            assertThat(context.isMessageHistory()).isFalse();
+            assertThat(context.isLoadTypeConverters()).isFalse();
+            main.stop();
+        }));
+
+        runtime.run();
+    }
 }
diff --git a/runtime/jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java
similarity index 82%
rename from runtime/jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java
rename to runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java
index d12539ca..cc3b7c3b 100644
--- a/runtime/jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java
+++ b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java
@@ -19,6 +19,13 @@
 import java.util.List;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.k.RoutesLoader;
+import org.apache.camel.k.Source;
+import org.apache.camel.k.jvm.loader.JavaClassLoader;
+import org.apache.camel.k.jvm.loader.JavaScriptLoader;
+import org.apache.camel.k.jvm.loader.JavaSourceLoader;
+import org.apache.camel.k.jvm.loader.XmlLoader;
 import org.apache.camel.model.ProcessDefinition;
 import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.model.SetBodyDefinition;
@@ -33,10 +40,10 @@
     @Test
     public void testLoadClass() throws Exception {
         Source source = Source.create("classpath:" + MyRoutes.class.getName() + ".class");
-        RoutesLoader loader = RoutesLoaders.loaderFor(source);
+        RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source);
         RouteBuilder builder = loader.load(new SimpleRuntimeRegistry(), source);
 
-        assertThat(loader).isInstanceOf(RoutesLoaders.JavaClass.class);
+        assertThat(loader).isInstanceOf(JavaClassLoader.class);
         assertThat(builder).isNotNull();
 
         builder.configure();
@@ -50,10 +57,10 @@ public void testLoadClass() throws Exception {
     @Test
     public void testLoadJava() throws Exception {
         Source source = Source.create("classpath:MyRoutes.java");
-        RoutesLoader loader = RoutesLoaders.loaderFor(source);
+        RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source);
         RouteBuilder builder = loader.load(new SimpleRuntimeRegistry(), source);
 
-        assertThat(loader).isInstanceOf(RoutesLoaders.JavaSource.class);
+        assertThat(loader).isInstanceOf(JavaSourceLoader.class);
         assertThat(builder).isNotNull();
 
         builder.configure();
@@ -67,10 +74,10 @@ public void testLoadJava() throws Exception {
     @Test
     public void testLoadJavaWithNestedClass() throws Exception {
         Source source = Source.create("classpath:MyRoutesWithNestedClass.java");
-        RoutesLoader loader = RoutesLoaders.loaderFor(source);
+        RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source);
         RouteBuilder builder = loader.load(new SimpleRuntimeRegistry(), source);
 
-        assertThat(loader).isInstanceOf(RoutesLoaders.JavaSource.class);
+        assertThat(loader).isInstanceOf(JavaSourceLoader.class);
         assertThat(builder).isNotNull();
 
         builder.configure();
@@ -86,10 +93,10 @@ public void testLoadJavaWithNestedClass() throws Exception {
     @Test
     public void testLoadJavaScript() throws Exception {
         Source source = Source.create("classpath:routes.js");
-        RoutesLoader loader = RoutesLoaders.loaderFor(source);
+        RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source);
         RouteBuilder builder = loader.load(new SimpleRuntimeRegistry(), source);
 
-        assertThat(loader).isInstanceOf(RoutesLoaders.JavaScript.class);
+        assertThat(loader).isInstanceOf(JavaScriptLoader.class);
         assertThat(builder).isNotNull();
 
         builder.configure();
@@ -103,10 +110,10 @@ public void testLoadJavaScript() throws Exception {
     @Test
     public void testLoadCompressedRoute() throws Exception {
         Source source = Source.create("classpath:routes-compressed.js.gz.b64?language=js&compression=true");
-        RoutesLoader loader = RoutesLoaders.loaderFor(source);
+        RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source);
         RouteBuilder builder = loader.load(new SimpleRuntimeRegistry(), source);
 
-        assertThat(loader).isInstanceOf(RoutesLoaders.JavaScript.class);
+        assertThat(loader).isInstanceOf(JavaScriptLoader.class);
         assertThat(builder).isNotNull();
 
         builder.configure();
@@ -120,10 +127,10 @@ public void testLoadCompressedRoute() throws Exception {
     @Test
     public void testLoadJavaScriptWithCustomExtension() throws Exception {
         Source source = Source.create("classpath:routes.mytype?language=js");
-        RoutesLoader loader = RoutesLoaders.loaderFor(source);
+        RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source);
         RouteBuilder builder = loader.load(new SimpleRuntimeRegistry(), source);
 
-        assertThat(loader).isInstanceOf(RoutesLoaders.JavaScript.class);
+        assertThat(loader).isInstanceOf(JavaScriptLoader.class);
         assertThat(builder).isNotNull();
 
         builder.configure();
@@ -137,10 +144,10 @@ public void testLoadJavaScriptWithCustomExtension() throws Exception {
     @Test
     public void testLoadXml() throws Exception {
         Source source = Source.create("classpath:routes.xml");
-        RoutesLoader loader = RoutesLoaders.loaderFor(source);
+        RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source);
         RouteBuilder builder = loader.load(new SimpleRuntimeRegistry(), source);
 
-        assertThat(loader).isInstanceOf(RoutesLoaders.Xml.class);
+        assertThat(loader).isInstanceOf(XmlLoader.class);
         assertThat(builder).isNotNull();
 
         builder.configure();
diff --git a/runtime/jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTest.java b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTest.java
similarity index 100%
rename from runtime/jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTest.java
rename to runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTest.java
diff --git a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTestSupport.java b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTestSupport.java
new file mode 100644
index 00000000..d72ddddd
--- /dev/null
+++ b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTestSupport.java
@@ -0,0 +1,41 @@
+/**
+ * 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.jvm;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.main.MainListener;
+import org.apache.camel.main.MainListenerSupport;
+import org.apache.camel.main.MainSupport;
+import org.apache.camel.util.function.ThrowingBiConsumer;
+
+public final class RuntimeTestSupport {
+    private RuntimeTestSupport() {
+    }
+
+    public static MainListener afterStart(ThrowingBiConsumer<MainSupport, CamelContext, Exception> consumer) {
+        return new MainListenerSupport() {
+            @Override
+            public void afterStart(MainSupport main) {
+                try {
+                    consumer.accept(main, main.getCamelContexts().get(0));
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        };
+    }
+}
diff --git a/runtime/jvm/src/test/resources/MyRoutes.java b/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutes.java
similarity index 100%
rename from runtime/jvm/src/test/resources/MyRoutes.java
rename to runtime/camel-k-runtime-jvm/src/test/resources/MyRoutes.java
diff --git a/runtime/jvm/src/test/resources/MyRoutesWithNestedClass.java b/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithNestedClass.java
similarity index 100%
rename from runtime/jvm/src/test/resources/MyRoutesWithNestedClass.java
rename to runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithNestedClass.java
diff --git a/runtime/jvm/src/test/resources/conf.d/001/conf.properties b/runtime/camel-k-runtime-jvm/src/test/resources/conf.d/001/conf.properties
similarity index 100%
rename from runtime/jvm/src/test/resources/conf.d/001/conf.properties
rename to runtime/camel-k-runtime-jvm/src/test/resources/conf.d/001/conf.properties
diff --git a/runtime/jvm/src/test/resources/conf.d/002/conf.properties b/runtime/camel-k-runtime-jvm/src/test/resources/conf.d/002/conf.properties
similarity index 100%
rename from runtime/jvm/src/test/resources/conf.d/002/conf.properties
rename to runtime/camel-k-runtime-jvm/src/test/resources/conf.d/002/conf.properties
diff --git a/runtime/jvm/src/test/resources/conf.properties b/runtime/camel-k-runtime-jvm/src/test/resources/conf.properties
similarity index 100%
rename from runtime/jvm/src/test/resources/conf.properties
rename to runtime/camel-k-runtime-jvm/src/test/resources/conf.properties
diff --git a/runtime/jvm/src/test/resources/log4j2-test.xml b/runtime/camel-k-runtime-jvm/src/test/resources/log4j2-test.xml
similarity index 100%
rename from runtime/jvm/src/test/resources/log4j2-test.xml
rename to runtime/camel-k-runtime-jvm/src/test/resources/log4j2-test.xml
diff --git a/runtime/jvm/src/test/resources/r1.js b/runtime/camel-k-runtime-jvm/src/test/resources/r1.js
similarity index 100%
rename from runtime/jvm/src/test/resources/r1.js
rename to runtime/camel-k-runtime-jvm/src/test/resources/r1.js
diff --git a/runtime/jvm/src/test/resources/r2.mytype b/runtime/camel-k-runtime-jvm/src/test/resources/r2.mytype
similarity index 100%
rename from runtime/jvm/src/test/resources/r2.mytype
rename to runtime/camel-k-runtime-jvm/src/test/resources/r2.mytype
diff --git a/runtime/jvm/src/test/resources/routes-compressed.js.gz.b64 b/runtime/camel-k-runtime-jvm/src/test/resources/routes-compressed.js.gz.b64
similarity index 100%
rename from runtime/jvm/src/test/resources/routes-compressed.js.gz.b64
rename to runtime/camel-k-runtime-jvm/src/test/resources/routes-compressed.js.gz.b64
diff --git a/runtime/jvm/src/test/resources/routes.js b/runtime/camel-k-runtime-jvm/src/test/resources/routes.js
similarity index 100%
rename from runtime/jvm/src/test/resources/routes.js
rename to runtime/camel-k-runtime-jvm/src/test/resources/routes.js
diff --git a/runtime/jvm/src/test/resources/routes.mytype b/runtime/camel-k-runtime-jvm/src/test/resources/routes.mytype
similarity index 100%
rename from runtime/jvm/src/test/resources/routes.mytype
rename to runtime/camel-k-runtime-jvm/src/test/resources/routes.mytype
diff --git a/runtime/jvm/src/test/resources/routes.xml b/runtime/camel-k-runtime-jvm/src/test/resources/routes.xml
similarity index 100%
rename from runtime/jvm/src/test/resources/routes.xml
rename to runtime/camel-k-runtime-jvm/src/test/resources/routes.xml
diff --git a/runtime/kotlin/pom.xml b/runtime/camel-k-runtime-kotlin/pom.xml
similarity index 100%
rename from runtime/kotlin/pom.xml
rename to runtime/camel-k-runtime-kotlin/pom.xml
diff --git a/runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt
similarity index 96%
rename from runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt
rename to runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt
index fba85d60..79025393 100644
--- a/runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt
+++ b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt
@@ -17,6 +17,10 @@
 package org.apache.camel.k.kotlin
 
 import org.apache.camel.builder.RouteBuilder
+import org.apache.camel.k.Language
+import org.apache.camel.k.RoutesLoader
+import org.apache.camel.k.RuntimeRegistry
+import org.apache.camel.k.Source
 import org.apache.camel.k.jvm.*
 import org.apache.camel.k.kotlin.dsl.IntegrationConfiguration
 import org.slf4j.Logger
diff --git a/runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ComponentsConfiguration.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ComponentsConfiguration.kt
similarity index 100%
rename from runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ComponentsConfiguration.kt
rename to runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ComponentsConfiguration.kt
diff --git a/runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt
similarity index 96%
rename from runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt
rename to runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt
index 618d1c79..9dbf77f2 100644
--- a/runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt
+++ b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt
@@ -17,7 +17,7 @@
 package org.apache.camel.k.kotlin.dsl
 
 import org.apache.camel.CamelContext
-import org.apache.camel.k.jvm.RuntimeRegistry
+import org.apache.camel.k.RuntimeRegistry
 
 class ContextConfiguration (val registry: RuntimeRegistry, val context: CamelContext) {
 
diff --git a/runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt
similarity index 97%
rename from runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt
rename to runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt
index 52d20f4b..926ad3ac 100644
--- a/runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt
+++ b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt
@@ -20,7 +20,7 @@ import org.apache.camel.Exchange
 import org.apache.camel.Predicate
 import org.apache.camel.Processor
 import org.apache.camel.builder.RouteBuilder
-import org.apache.camel.k.jvm.RuntimeRegistry
+import org.apache.camel.k.RuntimeRegistry
 import org.apache.camel.model.RouteDefinition
 
 abstract class IntegrationConfiguration(
diff --git a/runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt
similarity index 95%
rename from runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt
rename to runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt
index f15f71ab..b3abc957 100644
--- a/runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt
+++ b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.k.kotlin.dsl
 
-import org.apache.camel.k.jvm.RuntimeRegistry
+import org.apache.camel.k.RuntimeRegistry
 
 class RegistryConfiguration(val registry: RuntimeRegistry) {
     fun bind(name: String, value: Any) {
diff --git a/runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RestConfiguration.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RestConfiguration.kt
similarity index 100%
rename from runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RestConfiguration.kt
rename to runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RestConfiguration.kt
diff --git a/runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/extension/LogComponentExtensions.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/extension/LogComponentExtensions.kt
similarity index 100%
rename from runtime/kotlin/src/main/kotlin/org/apache/camel/k/kotlin/extension/LogComponentExtensions.kt
rename to runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/extension/LogComponentExtensions.kt
diff --git a/runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/services/org/apache/camel/k/loader/kotlin b/runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/services/org/apache/camel/k/loader/kotlin
new file mode 100644
index 00000000..d4bcde13
--- /dev/null
+++ b/runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/services/org/apache/camel/k/loader/kotlin
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.k.kotlin.KotlinRoutesLoader
\ No newline at end of file
diff --git a/runtime/kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt b/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt
similarity index 89%
rename from runtime/kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt
rename to runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt
index 0783b275..c0f86c6c 100644
--- a/runtime/kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt
+++ b/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt
@@ -16,9 +16,10 @@
  */
 package org.apache.camel.k.kotlin
 
-import org.apache.camel.k.jvm.RoutesLoaders
+import org.apache.camel.impl.DefaultCamelContext
+import org.apache.camel.k.Source
+import org.apache.camel.k.jvm.RuntimeSupport
 import org.apache.camel.k.jvm.SimpleRuntimeRegistry
-import org.apache.camel.k.jvm.Source
 import org.apache.camel.model.ProcessDefinition
 import org.apache.camel.model.ToDefinition
 import org.assertj.core.api.Assertions.assertThat
@@ -29,7 +30,7 @@ class LoaderTest {
     @Test
     fun `load route from classpath`() {
         var source = Source.create("classpath:routes.kts")
-        val loader = RoutesLoaders.loaderFor(source)
+        val loader = RuntimeSupport.loaderFor(DefaultCamelContext(), source)
         val builder = loader.load(SimpleRuntimeRegistry(), source)
 
         assertThat(loader).isInstanceOf(KotlinRoutesLoader::class.java)
diff --git a/runtime/kotlin/src/test/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationTest.kt b/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationTest.kt
similarity index 100%
rename from runtime/kotlin/src/test/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationTest.kt
rename to runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationTest.kt
diff --git a/runtime/kotlin/src/test/kotlin/org/apache/camel/k/kotlin/extension/LogExtensionTest.kt b/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/extension/LogExtensionTest.kt
similarity index 100%
rename from runtime/kotlin/src/test/kotlin/org/apache/camel/k/kotlin/extension/LogExtensionTest.kt
rename to runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/extension/LogExtensionTest.kt
diff --git a/runtime/kotlin/src/test/resources/log4j2-test.xml b/runtime/camel-k-runtime-kotlin/src/test/resources/log4j2-test.xml
similarity index 100%
rename from runtime/kotlin/src/test/resources/log4j2-test.xml
rename to runtime/camel-k-runtime-kotlin/src/test/resources/log4j2-test.xml
diff --git a/runtime/kotlin/src/test/resources/routes-new.kts b/runtime/camel-k-runtime-kotlin/src/test/resources/routes-new.kts
similarity index 100%
rename from runtime/kotlin/src/test/resources/routes-new.kts
rename to runtime/camel-k-runtime-kotlin/src/test/resources/routes-new.kts
diff --git a/runtime/kotlin/src/test/resources/routes-with-bindings.kts b/runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-bindings.kts
similarity index 100%
rename from runtime/kotlin/src/test/resources/routes-with-bindings.kts
rename to runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-bindings.kts
diff --git a/runtime/kotlin/src/test/resources/routes-with-component-configuration.kts b/runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-component-configuration.kts
similarity index 100%
rename from runtime/kotlin/src/test/resources/routes-with-component-configuration.kts
rename to runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-component-configuration.kts
diff --git a/runtime/kotlin/src/test/resources/routes-with-rest.kts b/runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-rest.kts
similarity index 100%
rename from runtime/kotlin/src/test/resources/routes-with-rest.kts
rename to runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-rest.kts
diff --git a/runtime/kotlin/src/test/resources/routes.kts b/runtime/camel-k-runtime-kotlin/src/test/resources/routes.kts
similarity index 100%
rename from runtime/kotlin/src/test/resources/routes.kts
rename to runtime/camel-k-runtime-kotlin/src/test/resources/routes.kts
diff --git a/runtime/spring-boot/pom.xml b/runtime/camel-k-runtime-spring-boot/pom.xml
similarity index 100%
rename from runtime/spring-boot/pom.xml
rename to runtime/camel-k-runtime-spring-boot/pom.xml
diff --git a/runtime/spring-boot/src/main/java/org/apache/camel/k/spring/boot/Application.java b/runtime/camel-k-runtime-spring-boot/src/main/java/org/apache/camel/k/spring/boot/Application.java
similarity index 91%
rename from runtime/spring-boot/src/main/java/org/apache/camel/k/spring/boot/Application.java
rename to runtime/camel-k-runtime-spring-boot/src/main/java/org/apache/camel/k/spring/boot/Application.java
index 0fe24ff6..427dd9ed 100644
--- a/runtime/spring-boot/src/main/java/org/apache/camel/k/spring/boot/Application.java
+++ b/runtime/camel-k-runtime-spring-boot/src/main/java/org/apache/camel/k/spring/boot/Application.java
@@ -22,12 +22,11 @@
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.k.jvm.Constants;
-import org.apache.camel.k.jvm.RoutesLoader;
-import org.apache.camel.k.jvm.RoutesLoaders;
-import org.apache.camel.k.jvm.RuntimeRegistry;
+import org.apache.camel.k.RuntimeRegistry;
+import org.apache.camel.k.Constants;
+import org.apache.camel.k.RoutesLoader;
 import org.apache.camel.k.jvm.RuntimeSupport;
-import org.apache.camel.k.jvm.Source;
+import org.apache.camel.k.Source;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.spring.boot.CamelContextConfiguration;
 import org.apache.camel.util.ObjectHelper;
@@ -85,10 +84,17 @@ public void beforeApplicationStart(CamelContext context) {
                     throw new IllegalStateException("No valid routes found in " + Constants.ENV_CAMEL_K_ROUTES + " environment variable");
                 }
 
+                // Programmatically apply the camel context.
+                //
+                // This is useful to configure services such as the ClusterService,
+                // RouteController, etc
+                //
+                RuntimeSupport.configureContext( context);
+
                 try {
                     for (String route : routes.split(",")) {
                         final Source source = Source.create(route);
-                        final RoutesLoader loader = RoutesLoaders.loaderFor(source);
+                        final RoutesLoader loader = RuntimeSupport.loaderFor(context, source);
                         final RouteBuilder builder = loader.load(registry, source);
 
                         if (builder == null) {
diff --git a/runtime/groovy/src/main/resources/META-INF/services/org.apache.camel.k.jvm.RoutesLoader b/runtime/groovy/src/main/resources/META-INF/services/org.apache.camel.k.jvm.RoutesLoader
deleted file mode 100644
index db214e0e..00000000
--- a/runtime/groovy/src/main/resources/META-INF/services/org.apache.camel.k.jvm.RoutesLoader
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.camel.k.groovy.GroovyRoutesLoader
\ No newline at end of file
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RoutesLoaders.java b/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RoutesLoaders.java
deleted file mode 100644
index 5f670780..00000000
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RoutesLoaders.java
+++ /dev/null
@@ -1,179 +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.jvm;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.util.Collections;
-import java.util.List;
-import java.util.ServiceLoader;
-import java.util.function.Function;
-import java.util.function.Supplier;
-import javax.script.Bindings;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.SimpleBindings;
-import javax.xml.bind.UnmarshalException;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.k.jvm.dsl.Components;
-import org.apache.camel.model.RouteDefinition;
-import org.apache.camel.model.rest.RestConfigurationDefinition;
-import org.apache.camel.model.rest.RestDefinition;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.joor.Reflect;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class RoutesLoaders {
-    private static final Logger LOGGER = LoggerFactory.getLogger(RoutesLoaders.class);
-
-    private RoutesLoaders() {
-    }
-
-    public static class JavaClass implements RoutesLoader {
-        @Override
-        public List<Language> getSupportedLanguages() {
-            return Collections.singletonList(Language.JavaClass);
-        }
-
-        @Override
-        public RouteBuilder load(RuntimeRegistry registry, Source source) throws Exception {
-            String path = source.getLocation();
-            path = StringUtils.removeStart(path, Constants.SCHEME_CLASSPATH);
-            path = StringUtils.removeEnd(path, ".class");
-
-            Class<?> type = Class.forName(path);
-
-            if (!RouteBuilder.class.isAssignableFrom(type)) {
-                throw new IllegalStateException("The class provided (" + path + ") is not a org.apache.camel.builder.RouteBuilder");
-            }
-
-            return (RouteBuilder)type.newInstance();
-        }
-    }
-
-    public static class JavaSource implements RoutesLoader {
-        @Override
-        public List<Language> getSupportedLanguages() {
-            return Collections.singletonList(Language.JavaSource);
-        }
-
-        @Override
-        public RouteBuilder load(RuntimeRegistry registry, Source source) throws Exception {
-            return new RouteBuilder() {
-                @Override
-                public void configure() throws Exception {
-                    try (InputStream is = URIResolver.resolve(getContext(), source)) {
-                        String name = StringUtils.substringAfter(source.getLocation(), ":");
-                        name = StringUtils.removeEnd(name, ".java");
-
-                        if (name.contains("/")) {
-                            name = StringUtils.substringAfterLast(name, "/");
-                        }
-
-                        // Wrap routes builder
-                        includeRoutes(
-                            Reflect.compile(name, IOUtils.toString(is, StandardCharsets.UTF_8)).create().get()
-                        );
-                    }
-                }
-            };
-        }
-    }
-
-    public static class JavaScript implements RoutesLoader {
-        @Override
-        public List<Language> getSupportedLanguages() {
-            return Collections.singletonList(Language.JavaScript);
-        }
-
-        @Override
-        public RouteBuilder load(RuntimeRegistry registry, Source source) throws Exception {
-            return new RouteBuilder() {
-                @Override
-                public void configure() throws Exception {
-                    final CamelContext context = getContext();
-                    final ScriptEngineManager manager = new ScriptEngineManager();
-                    final ScriptEngine engine = manager.getEngineByName("nashorn");
-                    final Bindings bindings = new SimpleBindings();
-
-                    // Exposed to the underlying script, but maybe better to have
-                    // a nice dsl
-                    bindings.put("builder", this);
-                    bindings.put("context", context);
-                    bindings.put("components", new Components(context));
-                    bindings.put("registry", registry);
-                    bindings.put("from", (Function<String, RouteDefinition>) uri -> from(uri));
-                    bindings.put("rest", (Supplier<RestDefinition>) () -> rest());
-                    bindings.put("restConfiguration", (Supplier<RestConfigurationDefinition>) () -> restConfiguration());
-
-                    try (InputStream is = URIResolver.resolve(context, source)) {
-                        engine.eval(new InputStreamReader(is), bindings);
-                    }
-                }
-            };
-        }
-    }
-
-    public static class Xml implements RoutesLoader {
-        @Override
-        public List<Language> getSupportedLanguages() {
-            return Collections.singletonList(Language.Xml);
-        }
-
-        @Override
-        public RouteBuilder load(RuntimeRegistry registry, Source source) throws Exception {
-            return new RouteBuilder() {
-                @Override
-                public void configure() throws Exception {
-                    try (InputStream is = URIResolver.resolve(getContext(), source)) {
-                        try {
-                            setRouteCollection(
-                                getContext().loadRoutesDefinition(is)
-                            );
-                        } catch (UnmarshalException e) {
-                            LOGGER.debug("Unable to load RoutesDefinition: {}", e.getMessage());
-                        }
-
-                        try {
-                            setRestCollection(
-                                getContext().loadRestsDefinition(is)
-                            );
-                        } catch (UnmarshalException e) {
-                            LOGGER.debug("Unable to load RestsDefinition: {}", e.getMessage());
-                        }
-                    }
-                }
-            };
-        }
-    }
-
-
-    public static RoutesLoader loaderFor(Source source) {
-        for (RoutesLoader loader: ServiceLoader.load(RoutesLoader.class)) {
-            if (loader.getSupportedLanguages().contains(source.getLanguage())) {
-                return loader;
-            }
-        }
-
-        throw new IllegalArgumentException("Unable to find loader for: " + source);
-    }
-}
diff --git a/runtime/jvm/src/main/resources/META-INF/services/org.apache.camel.k.jvm.RoutesLoader b/runtime/jvm/src/main/resources/META-INF/services/org.apache.camel.k.jvm.RoutesLoader
deleted file mode 100644
index 5a579270..00000000
--- a/runtime/jvm/src/main/resources/META-INF/services/org.apache.camel.k.jvm.RoutesLoader
+++ /dev/null
@@ -1,4 +0,0 @@
-org.apache.camel.k.jvm.RoutesLoaders$JavaClass
-org.apache.camel.k.jvm.RoutesLoaders$JavaSource
-org.apache.camel.k.jvm.RoutesLoaders$JavaScript
-org.apache.camel.k.jvm.RoutesLoaders$Xml
diff --git a/runtime/kotlin/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory b/runtime/kotlin/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory
deleted file mode 100644
index f8f59003..00000000
--- a/runtime/kotlin/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory
+++ /dev/null
@@ -1 +0,0 @@
-org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory
\ No newline at end of file
diff --git a/runtime/kotlin/src/main/resources/META-INF/services/org.apache.camel.k.jvm.RoutesLoader b/runtime/kotlin/src/main/resources/META-INF/services/org.apache.camel.k.jvm.RoutesLoader
deleted file mode 100644
index 83c3f090..00000000
--- a/runtime/kotlin/src/main/resources/META-INF/services/org.apache.camel.k.jvm.RoutesLoader
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.camel.k.kotlin.KotlinRoutesLoader
\ No newline at end of file
diff --git a/runtime/pom.xml b/runtime/pom.xml
index 7e421b9c..014e40bb 100644
--- a/runtime/pom.xml
+++ b/runtime/pom.xml
@@ -23,7 +23,7 @@
     <artifactId>camel-k-runtime-parent</artifactId>
     <version>0.1.1-SNAPSHOT</version>
     <packaging>pom</packaging>
-    
+
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <maven.compiler.source>1.8</maven.compiler.source>
@@ -92,12 +92,13 @@
             </plugins>
         </pluginManagement>
     </build>
-    
+
     <modules>
-        <module>jvm</module>
-        <module>groovy</module>
-        <module>kotlin</module>
-        <module>spring-boot</module>
+        <module>camel-k-runtime-core</module>
+        <module>camel-k-runtime-jvm</module>
+        <module>camel-k-runtime-groovy</module>
+        <module>camel-k-runtime-kotlin</module>
+        <module>camel-k-runtime-spring-boot</module>
         <module>catalog-builder</module>
         <module>dependency-lister</module>
         <module>camel-knative-http</module>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services