nicolaferraro closed pull request #3: swith to full in-memory java compiler and 
some minro cleanup
URL: https://github.com/apache/camel-k/pull/3
 
 
   

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/jvm/pom.xml b/runtime/jvm/pom.xml
index f4860c6..da1aade 100644
--- a/runtime/jvm/pom.xml
+++ b/runtime/jvm/pom.xml
@@ -27,15 +27,19 @@
             <version>${log4j2.version}</version>
         </dependency>
         <dependency>
-            <groupId>net.openhft</groupId>
-            <artifactId>compiler</artifactId>
-            <version>${openhft-compiler.version}</version>
+            <groupId>org.jooq</groupId>
+            <artifactId>joor-java-8</artifactId>
+            <version>${joor.version}</version>
         </dependency>
-
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
-            <version>2.6</version>
+            <version>${commons-io.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.8</version>
         </dependency>
 
         <dependency>
@@ -44,7 +48,6 @@
             <version>${junit.version}</version>
             <scope>test</scope>
         </dependency>
-
         <dependency>
             <groupId>org.assertj</groupId>
             <artifactId>assertj-core</artifactId>
diff --git a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RouteLoaders.java 
b/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RouteLoaders.java
index 0eb12fa..c5b5b99 100644
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RouteLoaders.java
+++ b/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RouteLoaders.java
@@ -27,12 +27,13 @@
 import javax.script.ScriptEngineManager;
 import javax.script.SimpleBindings;
 
-import net.openhft.compiler.CompilerUtils;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.model.RouteDefinition;
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.joor.Reflect;
 
 public enum RouteLoaders implements RoutesLoader {
     JavaClass {
@@ -64,19 +65,11 @@ public boolean test(String resource) {
         @Override
         public RouteBuilder load(String resource) throws Exception {
             try (InputStream is = is(resource)) {
-                String name = resource.substring(0, resource.length() - 
".java".length()).split(":", -1)[1];
-                if (name.startsWith("/")) {
-                    name = name.substring(1);
-                }
-
-                String content = IOUtils.toString(is);
-
-                Class<?> type = 
CompilerUtils.CACHED_COMPILER.loadFromJava(name.replace("/", "."), content);
-                if (!RouteBuilder.class.isAssignableFrom(type)) {
-                    throw new IllegalStateException("The class provided (" + 
resource + ") is not a org.apache.camel.builder.RouteBuilder");
-                }
+                String name = StringUtils.substringAfter(resource, ":");
+                name = StringUtils.removeEnd(name, ".java");
+                name = StringUtils.removeStart(name, "/");
 
-                return (RouteBuilder) type.newInstance();
+                return Reflect.compile(name.replace("/", "."), 
IOUtils.toString(is)).create().get();
             }
         }
     },
diff --git a/runtime/pom.xml b/runtime/pom.xml
index ee1f82d..825ec83 100644
--- a/runtime/pom.xml
+++ b/runtime/pom.xml
@@ -17,7 +17,8 @@
 
         <camel.version>2.22.0</camel.version>
         <junit.version>4.12</junit.version>
-        <openhft-compiler.version>2.3.1</openhft-compiler.version>
+        <joor.version>0.9.9</joor.version>
+        <commons-io.version>2.6</commons-io.version>
         <assertj.version>3.11.1</assertj.version>
         <log4j2.version>2.11.0</log4j2.version>
         <slf4j.version>1.7.25</slf4j.version>


 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to