From d326851e1a0114a88e9fbba42067d70c32f2fdc4 Mon Sep 17 00:00:00 2001 From: Peter Palaga Date: Wed, 21 Apr 2021 15:59:48 +0200 Subject: [PATCH] Upgrade to Quarkus 2.0.0.Alpha1 --- docs/antora.yml | 2 +- .../quarkus/core/CamelContextRecorder.java | 2 + .../core/CamelQuarkusClassResolver.java | 99 +++++++++++++++++++ .../camel/quarkus/core/FastCamelContext.java | 5 +- .../apache/camel/quarkus/main/CamelMain.java | 4 +- .../minio/it/MinioClientProducer.java | 2 +- .../minio/it/MinioConfigProvider.java | 6 ++ .../vertx/kafka/it/VertxKafkaProducers.java | 3 +- pom.xml | 8 +- poms/bom/pom.xml | 10 ++ 10 files changed, 131 insertions(+), 10 deletions(-) create mode 100644 extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelQuarkusClassResolver.java diff --git a/docs/antora.yml b/docs/antora.yml index 80e9fcf13b24..88632698461d 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -24,4 +24,4 @@ asciidoc: attributes: cq-camel-components: 3.10.x@components # replace ${camel.docs.components.xref} min-maven-version: 3.6.2 # replace ${min-maven-version} - quarkus-version: 1.13.2.Final # replace ${quarkus.version} \ No newline at end of file + quarkus-version: 2.0.0.Alpha1 # replace ${quarkus.version} \ No newline at end of file diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelContextRecorder.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelContextRecorder.java index c73e8f784c25..f8cb34c69ee6 100644 --- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelContextRecorder.java +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelContextRecorder.java @@ -56,6 +56,8 @@ public RuntimeValue createContext( context.setLoadTypeConverters(false); context.setModelJAXBContextFactory(contextFactory.getValue()); context.adapt(ExtendedCamelContext.class).setStartupStepRecorder(startupStepRecorder.getValue()); + final ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + context.setApplicationContextClassLoader(tccl); context.build(); context.addLifecycleStrategy(new CamelLifecycleEventBridge()); context.getManagementStrategy().addEventNotifier(new CamelManagementEventBridge()); diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelQuarkusClassResolver.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelQuarkusClassResolver.java new file mode 100644 index 000000000000..361763c3a395 --- /dev/null +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelQuarkusClassResolver.java @@ -0,0 +1,99 @@ +package org.apache.camel.quarkus.core; + +import java.io.InputStream; +import java.net.URL; +import java.util.Enumeration; + +import org.apache.camel.spi.ClassResolver; +import org.apache.camel.util.CastUtils; +import org.apache.camel.util.ObjectHelper; + +public class CamelQuarkusClassResolver implements ClassResolver { + + private final ClassLoader applicationContextClassLoader; + + public CamelQuarkusClassResolver(ClassLoader applicationContextClassLoader) { + this.applicationContextClassLoader = applicationContextClassLoader; + } + + @Override + public Class resolveClass(String name) { + return loadClass(name, applicationContextClassLoader); + } + + @Override + public Class resolveClass(String name, Class type) { + return CastUtils.cast(loadClass(name, applicationContextClassLoader)); + } + + @Override + public Class resolveClass(String name, ClassLoader loader) { + return loadClass(name, loader); + } + + @Override + public Class resolveClass(String name, Class type, ClassLoader loader) { + return CastUtils.cast(loadClass(name, loader)); + } + + @Override + public Class resolveMandatoryClass(String name) throws ClassNotFoundException { + Class answer = resolveClass(name); + if (answer == null) { + throw new ClassNotFoundException(name); + } + return answer; + } + + @Override + public Class resolveMandatoryClass(String name, Class type) throws ClassNotFoundException { + Class answer = resolveClass(name, type); + if (answer == null) { + throw new ClassNotFoundException(name); + } + return answer; + } + + @Override + public Class resolveMandatoryClass(String name, ClassLoader loader) throws ClassNotFoundException { + Class answer = resolveClass(name, loader); + if (answer == null) { + throw new ClassNotFoundException(name); + } + return answer; + } + + @Override + public Class resolveMandatoryClass(String name, Class type, ClassLoader loader) throws ClassNotFoundException { + Class answer = resolveClass(name, type, loader); + if (answer == null) { + throw new ClassNotFoundException(name); + } + return answer; + } + + @Override + public InputStream loadResourceAsStream(String uri) { + return ObjectHelper.loadResourceAsStream(uri, applicationContextClassLoader); + } + + @Override + public URL loadResourceAsURL(String uri) { + return ObjectHelper.loadResourceAsURL(uri, applicationContextClassLoader); + } + + @Override + public Enumeration loadResourcesAsURL(String uri) { + return loadAllResourcesAsURL(uri); + } + + @Override + public Enumeration loadAllResourcesAsURL(String uri) { + return ObjectHelper.loadResourcesAsURL(uri); + } + + protected Class loadClass(String name, ClassLoader loader) { + return ObjectHelper.loadClass(name, loader); + } + +} diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastCamelContext.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastCamelContext.java index 992028d69f88..a7ba15d4ed20 100644 --- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastCamelContext.java +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastCamelContext.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Properties; import java.util.function.Function; @@ -46,7 +47,6 @@ import org.apache.camel.impl.engine.DefaultBeanIntrospection; import org.apache.camel.impl.engine.DefaultCamelBeanPostProcessor; import org.apache.camel.impl.engine.DefaultCamelContextNameStrategy; -import org.apache.camel.impl.engine.DefaultClassResolver; import org.apache.camel.impl.engine.DefaultComponentNameResolver; import org.apache.camel.impl.engine.DefaultComponentResolver; import org.apache.camel.impl.engine.DefaultConfigurerResolver; @@ -298,7 +298,8 @@ protected FactoryFinderResolver createFactoryFinderResolver() { @Override protected ClassResolver createClassResolver() { - return new DefaultClassResolver(this); + return new CamelQuarkusClassResolver(Objects.requireNonNull(getApplicationContextClassLoader(), + "applicationContextClassLoader must be set before calling createClassResolver()")); } @Override diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMain.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMain.java index 6078f35915b6..579e668d132a 100644 --- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMain.java +++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMain.java @@ -121,11 +121,11 @@ protected CamelContext createCamelContext() { throw new IllegalStateException("Should not be invoked"); } - Collection getMainListeners() { + public Collection getMainListeners() { return Collections.unmodifiableCollection(listeners); } - MainConfigurationProperties getMainConfigurationProperties() { + public MainConfigurationProperties getMainConfigurationProperties() { return mainConfigurationProperties; } diff --git a/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioClientProducer.java b/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioClientProducer.java index d3ea59d06fd3..74fe08f80047 100644 --- a/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioClientProducer.java +++ b/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioClientProducer.java @@ -17,8 +17,8 @@ package org.apache.camel.quarkus.component.minio.it; import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Produces; import javax.inject.Named; -import javax.ws.rs.Produces; import io.minio.MinioClient; diff --git a/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioConfigProvider.java b/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioConfigProvider.java index 809a7d4e1928..496cc29d5f79 100644 --- a/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioConfigProvider.java +++ b/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioConfigProvider.java @@ -19,6 +19,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Set; import org.eclipse.microprofile.config.spi.ConfigSource; import org.eclipse.microprofile.config.spi.ConfigSourceProvider; @@ -57,5 +58,10 @@ public String getValue(String propertyName) { public String getName() { return MinioConfig.class.getName(); } + + @Override + public Set getPropertyNames() { + return values.keySet(); + } } } diff --git a/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaProducers.java b/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaProducers.java index 4ad0be0f1126..6674b858fbb3 100644 --- a/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaProducers.java +++ b/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaProducers.java @@ -52,7 +52,8 @@ public KafkaConsumer createKafkaConsumer(Vertx vertx) { config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); KafkaConsumer consumer = KafkaConsumer.create(vertx, config); - return consumer.subscribe(TOPIC_OUTBOUND); + consumer.subscribe(TOPIC_OUTBOUND); + return consumer; } @Produces diff --git a/pom.xml b/pom.xml index a0482f34ba6b..d6719180ab2d 100644 --- a/pom.xml +++ b/pom.xml @@ -95,20 +95,22 @@ 2.4.2 2.5.0 ${kudu-version} - 1.4.31 + 1.4.32 ${netty3-version} ${mvel-version} 4.41.1 ${squareup-okhttp-version} ${squareup-okio-version} + 0.28.0 8.2.0.Final + 0.23.0 + ${protobuf-version} 0.2.2 0.2.2 - 1.13.2.Final + 2.0.0.Alpha1 0.5.0 1.1.1 0.24.0 - ${protobuf-version} 2.5.0 1.5.3 2.11.12 diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 0c3e64142656..f7caa72912c9 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -5773,6 +5773,16 @@ debezium-embedded ${debezium.version} + + io.opencensus + opencensus-api + ${opencensus.version} + + + io.perfmark + perfmark-api + ${perfmark.version} + io.quarkiverse.freemarker quarkus-freemarker