Skip to content

Commit

Permalink
Upgrade to Quarkus 2.0.0.Alpha1
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Apr 27, 2021
1 parent 901af25 commit 6930b1e
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
quarkus-version: 2.0.0.Alpha1 # replace ${quarkus.version}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public RuntimeValue<CamelContext> 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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <T> Class<T> resolveClass(String name, Class<T> type) {
return CastUtils.cast(loadClass(name, applicationContextClassLoader));
}

@Override
public Class<?> resolveClass(String name, ClassLoader loader) {
return loadClass(name, loader);
}

@Override
public <T> Class<T> resolveClass(String name, Class<T> 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 <T> Class<T> resolveMandatoryClass(String name, Class<T> type) throws ClassNotFoundException {
Class<T> 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 <T> Class<T> resolveMandatoryClass(String name, Class<T> type, ClassLoader loader) throws ClassNotFoundException {
Class<T> 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<URL> loadResourcesAsURL(String uri) {
return loadAllResourcesAsURL(uri);
}

@Override
public Enumeration<URL> loadAllResourcesAsURL(String uri) {
return ObjectHelper.loadResourcesAsURL(uri);
}

protected Class<?> loadClass(String name, ClassLoader loader) {
return ObjectHelper.loadClass(name, loader);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ protected CamelContext createCamelContext() {
throw new IllegalStateException("Should not be invoked");
}

Collection<MainListener> getMainListeners() {
public Collection<MainListener> getMainListeners() {
return Collections.unmodifiableCollection(listeners);
}

MainConfigurationProperties getMainConfigurationProperties() {
public MainConfigurationProperties getMainConfigurationProperties() {
return mainConfigurationProperties;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,5 +58,10 @@ public String getValue(String propertyName) {
public String getName() {
return MinioConfig.class.getName();
}

@Override
public Set<String> getPropertyNames() {
return values.keySet();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public KafkaConsumer<String, String> createKafkaConsumer(Vertx vertx) {
config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());

KafkaConsumer<String, String> consumer = KafkaConsumer.create(vertx, config);
return consumer.subscribe(TOPIC_OUTBOUND);
consumer.subscribe(TOPIC_OUTBOUND);
return consumer;
}

@Produces
Expand Down
8 changes: 5 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,22 @@
<json-smart.version>2.4.2</json-smart.version>
<kafka.version>2.5.0</kafka.version>
<kudu.version>${kudu-version}</kudu.version><!-- keep in sync with Camel -->
<kotlin.version>1.4.31</kotlin.version><!-- keep in sync with Quarkus -->
<kotlin.version>1.4.32</kotlin.version><!-- keep in sync with Quarkus -->
<netty3.version>${netty3-version}</netty3.version><!-- Spark -->
<mvel2.version>${mvel-version}</mvel2.version><!-- keep in sync with Camel and Optaplanner -->
<nimbus-jose-jwt.version>4.41.1</nimbus-jose-jwt.version><!-- Mess in hdfs transitive deps -->
<okhttp.version>${squareup-okhttp-version}</okhttp.version><!-- keep in sync with okio -->
<okio.version>${squareup-okio-version}</okio.version><!-- keep in sync with okhttp -->
<opencensus.version>0.28.0</opencensus.version><!-- mess in google-pubsub deps -->
<optaplanner.version>8.2.0.Final</optaplanner.version>
<perfmark.version>0.23.0</perfmark.version><!-- mess in google-pubsub deps -->
<protobuf.version>${protobuf-version}</protobuf.version>
<quarkiverse.freemarker.version>0.2.2</quarkiverse.freemarker.version>
<quarkiverse-minio.version>0.2.2</quarkiverse-minio.version>
<quarkus.version>1.13.2.Final</quarkus.version>
<quarkus.version>2.0.0.Alpha1</quarkus.version>
<quarkus-google-cloud.version>0.5.0</quarkus-google-cloud.version>
<quarkus-hazelcast-client.version>1.1.1</quarkus-hazelcast-client.version>
<quarkus-qpid-jms.version>0.24.0</quarkus-qpid-jms.version>
<protobuf.version>${protobuf-version}</protobuf.version>
<retrofit.version>2.5.0</retrofit.version>
<scala-2.11.version>2.11.12</scala-2.11.version><!-- Spark -->
<smallrye.reactive.messaging.camel.version>2.9.0</smallrye.reactive.messaging.camel.version> <!-- keep in sync with Quarkus SmallRye Reactive Messaging -->
Expand Down
10 changes: 10 additions & 0 deletions poms/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5753,6 +5753,16 @@
<artifactId>debezium-embedded</artifactId>
<version>${debezium.version}</version>
</dependency>
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-api</artifactId>
<version>${opencensus.version}</version>
</dependency>
<dependency>
<groupId>io.perfmark</groupId>
<artifactId>perfmark-api</artifactId>
<version>${perfmark.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.freemarker</groupId>
<artifactId>quarkus-freemarker</artifactId>
Expand Down

0 comments on commit 6930b1e

Please sign in to comment.