[camel-k-runtime] branch master updated: Remove support for java class loader #195

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel-k-runtime] branch master updated: Remove support for java class loader #195

davsclaus-2
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git


The following commit(s) were added to refs/heads/master by this push:
     new 808b0ea  Remove support for java class loader #195
     new 23d7599  Merge pull request #194 from lburgazzoli/java-class
808b0ea is described below

commit 808b0ea00d594c0ff6605c5c987f3f50cd8c7146
Author: lburgazzoli <[hidden email]>
AuthorDate: Mon Nov 11 20:46:32 2019 +0100

    Remove support for java class loader #195
---
 .../camel/k/loader/java/JavaClassRoutesLoader.java | 47 ----------------------
 .../services/org/apache/camel/k/loader/class       | 18 ---------
 .../org/apache/camel/k/loader/java/MyRoutes.java   | 27 -------------
 .../camel/k/loader/java/RoutesLoaderTest.java      | 14 -------
 .../org/apache/camel/k/main/MyRoutesWithBeans.java | 34 ----------------
 .../java/org/apache/camel/k/main/RuntimeTest.java  | 13 ------
 6 files changed, 153 deletions(-)

diff --git a/camel-k-loader-java/src/main/java/org/apache/camel/k/loader/java/JavaClassRoutesLoader.java b/camel-k-loader-java/src/main/java/org/apache/camel/k/loader/java/JavaClassRoutesLoader.java
deleted file mode 100644
index f0b9753..0000000
--- a/camel-k-loader-java/src/main/java/org/apache/camel/k/loader/java/JavaClassRoutesLoader.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.k.loader.java;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.k.RoutesLoader;
-import org.apache.camel.k.Source;
-import org.apache.commons.lang3.StringUtils;
-
-public class JavaClassRoutesLoader implements RoutesLoader {
-    @Override
-    public List<String> getSupportedLanguages() {
-        return Collections.singletonList("class");
-    }
-
-    @Override
-    public RouteBuilder load(CamelContext camelContext, Source source) throws Exception {
-        String name = source.getName();
-        name = StringUtils.removeEnd(name, ".class");
-
-        Class<?> type = Class.forName(name);
-
-        if (!RouteBuilder.class.isAssignableFrom(type)) {
-            throw new IllegalStateException("The class provided is not a org.apache.camel.builder.RouteBuilder");
-        }
-
-        return (RouteBuilder)type.newInstance();
-    }
-}
diff --git a/camel-k-loader-java/src/main/resources/META-INF/services/org/apache/camel/k/loader/class b/camel-k-loader-java/src/main/resources/META-INF/services/org/apache/camel/k/loader/class
deleted file mode 100644
index ca7a231..0000000
--- a/camel-k-loader-java/src/main/resources/META-INF/services/org/apache/camel/k/loader/class
+++ /dev/null
@@ -1,18 +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.
-#
-
-class=org.apache.camel.k.loader.java.JavaClassRoutesLoader
\ No newline at end of file
diff --git a/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/MyRoutes.java b/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/MyRoutes.java
deleted file mode 100644
index 8b2f4e9..0000000
--- a/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/MyRoutes.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.k.loader.java;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyRoutes extends RouteBuilder {
-    @Override
-    public void configure() throws Exception {
-        from("timer:tick")
-            .to("log:info");
-    }
-}
diff --git a/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/RoutesLoaderTest.java b/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/RoutesLoaderTest.java
index 1fdf8d6..d9cc59c 100644
--- a/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/RoutesLoaderTest.java
+++ b/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/RoutesLoaderTest.java
@@ -39,19 +39,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 public class RoutesLoaderTest {
     @Test
-    public void testLoaderFromRegistry() throws Exception {
-        RoutesLoader myLoader = new JavaClassRoutesLoader();
-        CamelContext camelContext = new DefaultCamelContext();
-        camelContext.getRegistry().bind("my-loader", myLoader);
-
-        Source source = Sources.fromURI("classpath:" + MyRoutes.class.getName() + ".class");
-        RoutesLoader loader = RuntimeSupport.loaderFor(camelContext, source);
-
-        assertThat(loader).isInstanceOf(JavaClassRoutesLoader.class);
-        assertThat(loader).isSameAs(myLoader);
-    }
-
-    @Test
     public void testLoadJavaWithNestedClass() throws Exception {
         CamelContext context = new DefaultCamelContext();
 
@@ -111,7 +98,6 @@ public class RoutesLoaderTest {
 
     static Stream<Arguments> parameters() {
         return Stream.of(
-            Arguments.arguments("classpath:" + MyRoutes.class.getName() + ".class", JavaClassRoutesLoader.class),
             Arguments.arguments("classpath:MyRoutes.java", JavaSourceRoutesLoader.class),
             Arguments.arguments("classpath:MyRoutesWithNameOverride.java?name=MyRoutes.java", JavaSourceRoutesLoader.class),
             Arguments.arguments("classpath:MyRoutesWithPackage.java", JavaSourceRoutesLoader.class),
diff --git a/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/MyRoutesWithBeans.java b/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/MyRoutesWithBeans.java
deleted file mode 100644
index a42b9f1..0000000
--- a/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/MyRoutesWithBeans.java
+++ /dev/null
@@ -1,34 +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.main;
-
-import org.apache.camel.BindToRegistry;
-import org.apache.camel.builder.RouteBuilder;
-
-public class MyRoutesWithBeans extends RouteBuilder {
-    @Override
-    public void configure() throws Exception {
-        from("direct:start")
-            .bean("my-bean", "getName")
-            .to("log:info");
-    }
-
-    @BindToRegistry("my-bean")
-    public org.apache.camel.k.main.MyBean createMyBean() {
-        return new org.apache.camel.k.main.MyBean("my-bean-name");
-    }
-}
\ No newline at end of file
diff --git a/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java b/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java
index d85ef53..ffa89e2 100644
--- a/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java
+++ b/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java
@@ -92,19 +92,6 @@ public class RuntimeTest {
         runtime.run();
     }
 
-
-    @Test
-    public void testLoadJavaClassWithBeans() throws Exception {
-        ApplicationRuntime runtime = new ApplicationRuntime();
-        runtime.addListener(RoutesConfigurer.forRoutes("classpath:" + MyRoutesWithBeans.class.getName() + ".class"));
-        runtime.addListener(Runtime.Phase.Started, r ->  runtime.stop());
-        runtime.run();
-
-        assertThat(runtime.getRegistry().lookupByName("my-bean")).isInstanceOfSatisfying(MyBean.class, b -> {
-            assertThat(b).hasFieldOrPropertyWithValue("name", "my-bean-name");
-        });
-    }
-
     @Test
     public void testLoadJavaSourceWithBeans() throws Exception {
         ApplicationRuntime runtime = new ApplicationRuntime();