You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/10/05 15:27:14 UTC

[camel-quarkus] branch master updated (152559e -> 092d855)

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

lburgazzoli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git.


    from 152559e  remove redunand dependency on camel-quarkus-core from integration tests #9
     new baedf0c  chore: use RecorderContext to load classes when possible to delegate class loading to quarkus engine
     new d8c8cd1  chore: adapt to lastet cmale snapshot
     new 6568dbc  chore: re-enable caffeine as a workaround is in place in camel
     new 747b1dc  chore: replace MainSupport with BaseMainSupport in CamelMain
     new 092d855  chore: simplify bean registration and document contraints

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../quarkus/core/deployment/BuildProcessor.java    | 22 ++++++++--------
 .../core/deployment/CamelBeanBuildItem.java        |  5 ++--
 .../quarkus/core/deployment/CamelSupport.java      |  9 +++----
 .../core/deployment/SubstrateProcessor.java        | 10 --------
 .../org/apache/camel/quarkus/core/CamelMain.java   | 30 +++++++++++++++++-----
 .../quarkus/core/CamelMainEventDispatcher.java     | 15 ++++++-----
 .../camel/quarkus/core/CamelMainRecorder.java      |  9 +++----
 .../core/runtime/support/SupportListener.java      | 10 ++++----
 8 files changed, 56 insertions(+), 54 deletions(-)


[camel-quarkus] 05/05: chore: simplify bean registration and document contraints

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 092d855d942dcf99ab8edf224cc14181da23b84b
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Sat Oct 5 15:32:35 2019 +0200

    chore: simplify bean registration and document contraints
---
 .../camel/quarkus/core/deployment/BuildProcessor.java   | 17 ++++++-----------
 .../quarkus/core/deployment/CamelBeanBuildItem.java     |  5 ++---
 .../camel/quarkus/core/deployment/CamelSupport.java     |  9 +++------
 3 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
index afda882..1f268a6 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
@@ -17,7 +17,6 @@
 package org.apache.camel.quarkus.core.deployment;
 
 import java.util.List;
-import java.util.Objects;
 
 import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
 import io.quarkus.arc.deployment.BeanContainerBuildItem;
@@ -61,29 +60,25 @@ class BuildProcessor {
         @BuildStep
         CamelRegistryBuildItem registry(
             CamelRecorder recorder,
+            RecorderContext recorderContext,
             ApplicationArchivesBuildItem applicationArchives,
             List<CamelBeanBuildItem> registryItems) {
 
             RuntimeValue<Registry> registry = recorder.createRegistry();
 
-            CamelSupport.services(applicationArchives).filter(
-                si -> registryItems.stream().noneMatch(
-                    c -> Objects.equals(si.name, c.getName()) && c.getType().isAssignableFrom(si.type)
-                )
-            ).forEach(
-                si -> {
-                    LOGGER.debug("Binding camel service {} with type {}", si.name, si.type);
+            CamelSupport.services(applicationArchives).forEach(si -> {
+                    LOGGER.debug("Binding bean with name: {}, type {}", si.name, si.type);
 
                     recorder.bind(
                         registry,
                         si.name,
-                        si.type
+                        recorderContext.classProxy(si.type)
                     );
                 }
             );
 
             for (CamelBeanBuildItem item : registryItems) {
-                LOGGER.debug("Binding item with name: {}, type {}", item.getName(), item.getType());
+                LOGGER.debug("Binding bean with name: {}, type {}", item.getName(), item.getType());
 
                 recorder.bind(
                     registry,
@@ -126,11 +121,11 @@ class BuildProcessor {
         CamelMainBuildItem main(
             CombinedIndexBuildItem combinedIndex,
             CamelMainRecorder recorder,
+            RecorderContext recorderContext,
             CamelContextBuildItem context,
             List<CamelMainListenerBuildItem> listeners,
             List<CamelRoutesBuilderBuildItem> routesBuilders,
             BeanContainerBuildItem beanContainer,
-            RecorderContext recorderContext,
             CamelConfig.BuildTime buildTimeConfig) {
 
             RuntimeValue<CamelMain> main = recorder.createCamelMain(context.getCamelContext(), beanContainer.getValue());
diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelBeanBuildItem.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelBeanBuildItem.java
index 9e38756..84a578a 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelBeanBuildItem.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelBeanBuildItem.java
@@ -22,9 +22,8 @@ import io.quarkus.builder.item.MultiBuildItem;
 
 /**
  * A {@link MultiBuildItem} holding beans to add to {@link org.apache.camel.spi.Registry} during
- * static initialization phase.
- * Can be produced only by methods that do not depend on {@link org.apache.camel.quarkus.core.runtime.CamelRuntime}
- * because otherwise there is a circular dependency.
+ * static initialization phase. Note that the field type should refer to the most specialized
+ * class to avoid the issue described in https://issues.apache.org/jira/browse/CAMEL-13948.
  */
 public final class CamelBeanBuildItem extends MultiBuildItem {
     private final String name;
diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelSupport.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelSupport.java
index e2f6807..418c442 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelSupport.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelSupport.java
@@ -102,10 +102,7 @@ public final class CamelSupport {
             for (Map.Entry<Object, Object> entry : props.entrySet()) {
                 String k = entry.getKey().toString();
                 if (k.equals("class")) {
-                    String clazz = entry.getValue().toString();
-                    Class<?> cl = Class.forName(clazz);
-
-                    answer.add(new ServiceInfo(name, cl));
+                    answer.add(new ServiceInfo(name, entry.getValue().toString()));
                 }
             }
         } catch (Exception e) {
@@ -121,9 +118,9 @@ public final class CamelSupport {
      */
     public static class ServiceInfo {
         public final String name;
-        public final Class<?> type;
+        public final String type;
 
-        public ServiceInfo(String name, Class<?> type) {
+        public ServiceInfo(String name, String type) {
             this.name = name;
             this.type = type;
         }


[camel-quarkus] 02/05: chore: adapt to lastet cmale snapshot

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d8c8cd1bca4f31c8f842b1dfa011e65c5fae1632
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Sat Oct 5 14:03:45 2019 +0200

    chore: adapt to lastet cmale snapshot
---
 .../camel/quarkus/core/CamelMainEventDispatcher.java      | 15 ++++++++-------
 .../quarkus/core/runtime/support/SupportListener.java     | 10 +++++-----
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainEventDispatcher.java b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainEventDispatcher.java
index f6504c5..1df54ab 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainEventDispatcher.java
+++ b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainEventDispatcher.java
@@ -18,6 +18,7 @@ package org.apache.camel.quarkus.core;
 
 import io.quarkus.arc.Arc;
 import org.apache.camel.CamelContext;
+import org.apache.camel.main.BaseMainSupport;
 import org.apache.camel.main.MainSupport;
 
 /**
@@ -25,27 +26,27 @@ import org.apache.camel.main.MainSupport;
  */
 public class CamelMainEventDispatcher implements org.apache.camel.main.MainListener {
     @Override
-    public void beforeStart(MainSupport main) {
-        fireEvent(CamelMainEvents.BeforeStart.class, new CamelMainEvents.BeforeStart());
+    public void configure(CamelContext context) {
+        fireEvent(CamelMainEvents.Configure.class, new CamelMainEvents.Configure());
     }
 
     @Override
-    public void configure(CamelContext context) {
-        fireEvent(CamelMainEvents.Configure.class, new CamelMainEvents.Configure());
+    public void beforeStart(BaseMainSupport main) {
+        fireEvent(CamelMainEvents.BeforeStart.class, new CamelMainEvents.BeforeStart());
     }
 
     @Override
-    public void afterStart(MainSupport main) {
+    public void afterStart(BaseMainSupport main) {
         fireEvent(CamelMainEvents.AfterStart.class, new CamelMainEvents.AfterStart());
     }
 
     @Override
-    public void beforeStop(MainSupport main) {
+    public void beforeStop(BaseMainSupport main) {
         fireEvent(CamelMainEvents.BeforeStop.class, new CamelMainEvents.BeforeStop());
     }
 
     @Override
-    public void afterStop(MainSupport main) {
+    public void afterStop(BaseMainSupport main) {
         fireEvent(CamelMainEvents.AfterStop.class, new CamelMainEvents.AfterStop());
     }
 
diff --git a/integration-tests/core-main/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/support/SupportListener.java b/integration-tests/core-main/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/support/SupportListener.java
index 2206d7a..81f3c41 100644
--- a/integration-tests/core-main/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/support/SupportListener.java
+++ b/integration-tests/core-main/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/support/SupportListener.java
@@ -18,8 +18,8 @@ package org.apache.camel.quarkus.core.runtime.support;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.main.BaseMainSupport;
 import org.apache.camel.main.MainListener;
-import org.apache.camel.main.MainSupport;
 
 public class SupportListener implements MainListener {
     @Override
@@ -39,18 +39,18 @@ public class SupportListener implements MainListener {
     }
 
     @Override
-    public void beforeStart(MainSupport main) {
+    public void beforeStart(BaseMainSupport main) {
     }
 
     @Override
-    public void afterStart(MainSupport main) {
+    public void afterStart(BaseMainSupport main) {
     }
 
     @Override
-    public void beforeStop(MainSupport main) {
+    public void beforeStop(BaseMainSupport main) {
     }
 
     @Override
-    public void afterStop(MainSupport main) {
+    public void afterStop(BaseMainSupport main) {
     }
 }


[camel-quarkus] 03/05: chore: re-enable caffeine as a workaround is in place in camel

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6568dbc674d11db3c34c69fc7d45fd0a879f9ee2
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Sat Oct 5 14:04:22 2019 +0200

    chore: re-enable caffeine as a workaround is in place in camel
---
 .../camel/quarkus/core/deployment/SubstrateProcessor.java      | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/SubstrateProcessor.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/SubstrateProcessor.java
index 6b0c0f6..3b20b6b 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/SubstrateProcessor.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/SubstrateProcessor.java
@@ -33,7 +33,6 @@ import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem;
 import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
 import io.quarkus.deployment.builditem.substrate.ReflectiveClassBuildItem;
 import io.quarkus.deployment.builditem.substrate.ReflectiveMethodBuildItem;
-import io.quarkus.deployment.builditem.substrate.SubstrateConfigBuildItem;
 import io.quarkus.deployment.builditem.substrate.SubstrateResourceBuildItem;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
@@ -84,15 +83,6 @@ class SubstrateProcessor {
         ApplicationArchivesBuildItem applicationArchivesBuildItem;
 
         @BuildStep
-        SubstrateConfigBuildItem cache() {
-            return SubstrateConfigBuildItem.builder()
-                // TODO: switch back to caffeine once https://github.com/apache/camel-quarkus/issues/80 gets fixed
-                .addNativeImageSystemProperty("CamelWarmUpLRUCacheFactory", "true")
-                .addNativeImageSystemProperty("CamelSimpleLRUCacheFactory", "true")
-                .build();
-        }
-
-        @BuildStep
         void process(CombinedIndexBuildItem combinedIndex) {
             IndexView view = combinedIndex.getIndex();
 


[camel-quarkus] 01/05: chore: use RecorderContext to load classes when possible to delegate class loading to quarkus engine

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit baedf0cb53f6fb09058e0e9c6b76e58dda0999ec
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Sat Oct 5 13:29:35 2019 +0200

    chore: use RecorderContext to load classes when possible to delegate class loading to quarkus engine
---
 .../org/apache/camel/quarkus/core/deployment/BuildProcessor.java   | 7 ++++++-
 .../main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java | 6 +++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
index 1145f63..afda882 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
@@ -29,8 +29,10 @@ import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem;
 import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
 import io.quarkus.deployment.builditem.ServiceStartBuildItem;
 import io.quarkus.deployment.builditem.ShutdownContextBuildItem;
+import io.quarkus.deployment.recording.RecorderContext;
 import io.quarkus.runtime.RuntimeValue;
 import org.apache.camel.CamelContext;
+import org.apache.camel.RoutesBuilder;
 import org.apache.camel.quarkus.core.CamelConfig;
 import org.apache.camel.quarkus.core.CamelMain;
 import org.apache.camel.quarkus.core.CamelMainProducers;
@@ -49,6 +51,7 @@ class BuildProcessor {
      * Build steps related to camel core.
      */
     public static class Core {
+
         @BuildStep
         void beans(BuildProducer<AdditionalBeanBuildItem> beanProducer) {
             beanProducer.produce(AdditionalBeanBuildItem.unremovableOf(CamelProducers.class));
@@ -117,6 +120,7 @@ class BuildProcessor {
             beanProducer.produce(AdditionalBeanBuildItem.unremovableOf(CamelMainProducers.class));
         }
 
+        @SuppressWarnings("unchecked")
         @Record(ExecutionTime.STATIC_INIT)
         @BuildStep(onlyIfNot = Flags.MainDisabled.class)
         CamelMainBuildItem main(
@@ -126,6 +130,7 @@ class BuildProcessor {
             List<CamelMainListenerBuildItem> listeners,
             List<CamelRoutesBuilderBuildItem> routesBuilders,
             BeanContainerBuildItem beanContainer,
+            RecorderContext recorderContext,
             CamelConfig.BuildTime buildTimeConfig) {
 
             RuntimeValue<CamelMain> main = recorder.createCamelMain(context.getCamelContext(), beanContainer.getValue());
@@ -134,7 +139,7 @@ class BuildProcessor {
             }
 
             CamelSupport.getRouteBuilderClasses(combinedIndex.getIndex()).forEach(name -> {
-                recorder.addRouteBuilder(main, name);
+                recorder.addRouteBuilder(main, (Class<RoutesBuilder>)recorderContext.classProxy(name));
             });
             routesBuilders.forEach(routesBuilder -> {
                 recorder.addRouteBuilder(main, routesBuilder.getInstance());
diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java
index f9d7236..0c861a7 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java
+++ b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java
@@ -49,12 +49,12 @@ public class CamelMainRecorder {
 
     public void addRouteBuilder(
             RuntimeValue<CamelMain> main,
-            String className) {
+            Class<? extends RoutesBuilder> routeBuilderClass) {
 
         try {
-            main.getValue().addRouteBuilder(Class.forName(className));
+            main.getValue().addRouteBuilder(routeBuilderClass);
         } catch (Exception e) {
-            throw new RuntimeException("Could not add route builder '" + className + "'", e);
+            throw new RuntimeException("Could not add route builder '" + routeBuilderClass.getName() + "'", e);
         }
     }
 


[camel-quarkus] 04/05: chore: replace MainSupport with BaseMainSupport in CamelMain

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 747b1dc27259a4ac4b4bef3c36572b91dcb4b01a
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Sat Oct 5 14:39:04 2019 +0200

    chore: replace MainSupport with BaseMainSupport in CamelMain
---
 .../org/apache/camel/quarkus/core/CamelMain.java   | 30 +++++++++++++++++-----
 .../camel/quarkus/core/CamelMainRecorder.java      |  3 +--
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMain.java b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMain.java
index 2c71954..7e5c7f9 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMain.java
+++ b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMain.java
@@ -22,12 +22,16 @@ import java.util.Collections;
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.ProducerTemplate;
+import org.apache.camel.main.BaseMainSupport;
 import org.apache.camel.main.MainConfigurationProperties;
 import org.apache.camel.main.MainListener;
-import org.apache.camel.main.MainSupport;
 import org.apache.camel.support.service.ServiceHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CamelMain extends BaseMainSupport implements CamelContextAware {
+    private static final Logger LOGGER = LoggerFactory.getLogger(CamelMain.class);
 
-public class CamelMain extends MainSupport implements CamelContextAware {
     @Override
     public void setCamelContext(CamelContext camelContext) {
         this.camelContext = camelContext;
@@ -40,9 +44,15 @@ public class CamelMain extends MainSupport implements CamelContextAware {
 
     @Override
     protected void doStart() throws Exception {
-        beforeStart();
+        for (MainListener listener : listeners) {
+            listener.beforeStart(this);
+        }
+
         getCamelContext().start();
-        afterStart();
+
+        for (MainListener listener : listeners) {
+            listener.afterStart(this);
+        }
     }
 
     @Override
@@ -53,12 +63,18 @@ public class CamelMain extends MainSupport implements CamelContextAware {
                 camelTemplate = null;
             }
         } catch (Exception e) {
-            MainSupport.LOG.debug("Error stopping camelTemplate due " + e.getMessage() + ". This exception is ignored.", e);
+            LOGGER.debug("Error stopping camelTemplate due " + e.getMessage() + ". This exception is ignored.", e);
+        }
+
+        for (MainListener listener : listeners) {
+            listener.beforeStop(this);
         }
 
-        beforeStop();
         getCamelContext().stop();
-        afterStop();
+
+        for (MainListener listener : listeners) {
+            listener.afterStop(this);
+        }
     }
 
     @Override
diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java
index 0c861a7..139ca38 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java
+++ b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMainRecorder.java
@@ -38,7 +38,6 @@ public class CamelMainRecorder {
 
         CamelMain main = new CamelMain();
         main.setCamelContext(runtime.getValue());
-        main.disableHangupSupport();
         main.addMainListener(new CamelMainEventDispatcher());
 
         // register to the container
@@ -83,7 +82,7 @@ public class CamelMainRecorder {
 
         if (ObjectHelper.isNotEmpty(location)) {
             // TODO: if pointing to a directory, we should load all xmls in it
-            //   (maybe with glob support in it to be complete)
+            //       (maybe with glob support in it to be complete)
             try (InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(main.getValue().getCamelContext(), location)) {
                 main.getValue().getCamelContext().getExtension(Model.class).addRouteDefinitions(is);
             } catch (Exception e) {