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/28 11:06:49 UTC

[camel-quarkus] 02/02: main: wrap MainListener with a RuntimeValue

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 14b90854efdcf8a8574cb2350f67dd2fe999d9c8
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Sun Oct 27 21:35:46 2019 +0100

    main: wrap MainListener with a RuntimeValue
---
 .../deployment/CamelMainListenerBuildItem.java     |  7 ++++---
 .../camel/quarkus/core/CamelMainRecorder.java      |  4 ++--
 .../support/deployment/SupportBuildStep.java       | 10 ++++++----
 .../core/runtime/support/SupportRecorder.java      | 22 +++++++---------------
 4 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelMainListenerBuildItem.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelMainListenerBuildItem.java
index 188177e..0a09ccb 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelMainListenerBuildItem.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelMainListenerBuildItem.java
@@ -17,6 +17,7 @@
 package org.apache.camel.quarkus.core.deployment;
 
 import io.quarkus.builder.item.MultiBuildItem;
+import io.quarkus.runtime.RuntimeValue;
 import org.apache.camel.main.MainListener;
 import org.apache.camel.quarkus.core.CamelMain;
 
@@ -24,13 +25,13 @@ import org.apache.camel.quarkus.core.CamelMain;
  * A {@link MultiBuildItem} holding {@link MainListener}s to add to {@link CamelMain}.
  */
 public final class CamelMainListenerBuildItem extends MultiBuildItem {
-    private final MainListener listener;
+    private final RuntimeValue<MainListener> listener;
 
-    public CamelMainListenerBuildItem(MainListener listener) {
+    public CamelMainListenerBuildItem(RuntimeValue<MainListener> listener) {
         this.listener = listener;
     }
 
-    public MainListener getListener() {
+    public RuntimeValue<MainListener> getListener() {
         return listener;
     }
 }
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 001a0c7..d851671 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
@@ -78,8 +78,8 @@ public class CamelMainRecorder {
         }
     }
 
-    public void addListener(RuntimeValue<CamelMain> main, MainListener listener) {
-        main.getValue().addMainListener(listener);
+    public void addListener(RuntimeValue<CamelMain> main, RuntimeValue<MainListener> listener) {
+        main.getValue().addMainListener(listener.getValue());
     }
 
     public void setReactiveExecutor(RuntimeValue<CamelMain> main, RuntimeValue<ReactiveExecutor> executor) {
diff --git a/integration-tests/core-main/deployment/src/main/java/org/apache/camel/quarkus/core/runtime/support/deployment/SupportBuildStep.java b/integration-tests/core-main/deployment/src/main/java/org/apache/camel/quarkus/core/runtime/support/deployment/SupportBuildStep.java
index 3cc84f8..395a634 100644
--- a/integration-tests/core-main/deployment/src/main/java/org/apache/camel/quarkus/core/runtime/support/deployment/SupportBuildStep.java
+++ b/integration-tests/core-main/deployment/src/main/java/org/apache/camel/quarkus/core/runtime/support/deployment/SupportBuildStep.java
@@ -16,14 +16,16 @@
  */
 package org.apache.camel.quarkus.core.runtime.support.deployment;
 
-import io.quarkus.deployment.annotations.BuildProducer;
 import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
 import org.apache.camel.quarkus.core.deployment.CamelMainListenerBuildItem;
-import org.apache.camel.quarkus.core.runtime.support.SupportListener;
+import org.apache.camel.quarkus.core.runtime.support.SupportRecorder;
 
 public class SupportBuildStep {
+    @Record(ExecutionTime.STATIC_INIT)
     @BuildStep
-    void listener(BuildProducer<CamelMainListenerBuildItem> listener) {
-        listener.produce(new CamelMainListenerBuildItem(new SupportListener()));
+    CamelMainListenerBuildItem listener(SupportRecorder recorder) {
+        return new CamelMainListenerBuildItem(recorder.createSupportListener());
     }
 }
diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelMainListenerBuildItem.java b/integration-tests/core-main/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/support/SupportRecorder.java
similarity index 62%
copy from extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelMainListenerBuildItem.java
copy to integration-tests/core-main/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/support/SupportRecorder.java
index 188177e..f9eaf3e 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelMainListenerBuildItem.java
+++ b/integration-tests/core-main/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/support/SupportRecorder.java
@@ -14,23 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.quarkus.core.deployment;
+package org.apache.camel.quarkus.core.runtime.support;
 
-import io.quarkus.builder.item.MultiBuildItem;
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
 import org.apache.camel.main.MainListener;
-import org.apache.camel.quarkus.core.CamelMain;
 
-/**
- * A {@link MultiBuildItem} holding {@link MainListener}s to add to {@link CamelMain}.
- */
-public final class CamelMainListenerBuildItem extends MultiBuildItem {
-    private final MainListener listener;
-
-    public CamelMainListenerBuildItem(MainListener listener) {
-        this.listener = listener;
-    }
-
-    public MainListener getListener() {
-        return listener;
+@Recorder
+public class SupportRecorder {
+    public RuntimeValue<MainListener> createSupportListener() {
+        return new RuntimeValue<>(new SupportListener());
     }
 }