This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch quarkus-master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit a3d0fbdc26aa47741f3c3e94455248f42d0f69e3 Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Fri Feb 7 10:49:27 2020 +0100 Fix MongoDbProcessor according to the latest changes in the mongodb extension --- .../mongodb/deployment/MongoDbProcessor.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/extensions/mongodb/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/deployment/MongoDbProcessor.java b/extensions/mongodb/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/deployment/MongoDbProcessor.java index f14c0c9..00abff7 100644 --- a/extensions/mongodb/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/deployment/MongoDbProcessor.java +++ b/extensions/mongodb/deployment/src/main/java/org/apache/camel/quarkus/component/mongodb/deployment/MongoDbProcessor.java @@ -16,12 +16,15 @@ */ package org.apache.camel.quarkus.component.mongodb.deployment; -import com.mongodb.MongoClient; +import java.util.List; + +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 io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.mongodb.deployment.MongoClientBuildItem; +import io.quarkus.mongodb.runtime.MongoClientRecorder; import org.apache.camel.quarkus.component.mongodb.CamelMongoClientRecorder; import org.apache.camel.quarkus.core.deployment.CamelRuntimeBeanBuildItem; @@ -36,10 +39,21 @@ class MongoDbProcessor { @BuildStep @Record(ExecutionTime.RUNTIME_INIT) - CamelRuntimeBeanBuildItem registerCamelMongoClientProducer(MongoClientBuildItem mongoClientBuildItem, + void registerCamelMongoClientProducer( + List<MongoClientBuildItem> mongoClients, + BuildProducer<CamelRuntimeBeanBuildItem> runtimeBeans, CamelMongoClientRecorder recorder) { - return new CamelRuntimeBeanBuildItem("camelMongoClient", MongoClient.class.getName(), - recorder.createCamelMongoClient(mongoClientBuildItem.getClient())); + for (MongoClientBuildItem mongoClient : mongoClients) { + // If there is a default mongo client instance, then bind it to the camel registry + // with the default mongo client name used by the camel-mongodb component + if (MongoClientRecorder.DEFAULT_MONGOCLIENT_NAME.equals(mongoClient.getName())) { + runtimeBeans.produce( + new CamelRuntimeBeanBuildItem( + "camelMongoClient", + "com.mongodb.MongoClient", + recorder.createCamelMongoClient(mongoClients.get(0).getClient()))); + } + } } }