This is an automated email from the ASF dual-hosted git repository. zbendhiba pushed a commit to branch camel-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/camel-main by this push: new 8568f99 fix atlasmap integration tests error 8568f99 is described below commit 8568f990c51deb5cea6a065b609de10d207909de Author: Zineb Bendhiba <bendhiba.zi...@gmail.com> AuthorDate: Mon May 3 17:49:52 2021 +0200 fix atlasmap integration tests error --- .../atlasmap/deployment/AtlasmapProcessor.java | 21 ----- extensions/atlasmap/runtime/pom.xml | 6 ++ .../component/atlasmap/AtlasmapRecorder.java | 90 ---------------------- .../component/atlasmap/graalvm/Substitutions.java | 21 +++++ 4 files changed, 27 insertions(+), 111 deletions(-) diff --git a/extensions/atlasmap/deployment/src/main/java/org/apache/camel/quarkus/component/atlasmap/deployment/AtlasmapProcessor.java b/extensions/atlasmap/deployment/src/main/java/org/apache/camel/quarkus/component/atlasmap/deployment/AtlasmapProcessor.java index 0e35d58..713a714 100644 --- a/extensions/atlasmap/deployment/src/main/java/org/apache/camel/quarkus/component/atlasmap/deployment/AtlasmapProcessor.java +++ b/extensions/atlasmap/deployment/src/main/java/org/apache/camel/quarkus/component/atlasmap/deployment/AtlasmapProcessor.java @@ -180,20 +180,11 @@ import io.atlasmap.xml.v2.XmlNamespace; import io.atlasmap.xml.v2.XmlNamespaces; 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.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; -import io.quarkus.deployment.recording.RecorderContext; import io.quarkus.deployment.util.ServiceUtil; -import io.quarkus.runtime.RuntimeValue; -import org.apache.camel.component.atlasmap.AtlasMapComponent; -import org.apache.camel.quarkus.component.atlasmap.AtlasmapRecorder; -import org.apache.camel.quarkus.core.deployment.spi.CamelBeanBuildItem; -import org.apache.camel.quarkus.core.deployment.spi.CamelContextBuildItem; -import org.apache.camel.quarkus.core.deployment.spi.CompiledCSimpleExpressionBuildItem; class AtlasmapProcessor { @@ -390,16 +381,4 @@ class AtlasmapProcessor { } }); } - - @Record(ExecutionTime.STATIC_INIT) - @BuildStep - CamelBeanBuildItem configureComponent( - RecorderContext recorderContext, - AtlasmapRecorder recorder, - CamelContextBuildItem camelContext, - List<CompiledCSimpleExpressionBuildItem> compiledCSimpleExpressions) { - - final RuntimeValue<?> atlasmapComponent = recorder.createAtlasmapComponent(); - return new CamelBeanBuildItem("atlasmap", AtlasMapComponent.class.getName(), atlasmapComponent); - } } diff --git a/extensions/atlasmap/runtime/pom.xml b/extensions/atlasmap/runtime/pom.xml index 2c0fea5..2d80f1a 100644 --- a/extensions/atlasmap/runtime/pom.xml +++ b/extensions/atlasmap/runtime/pom.xml @@ -60,8 +60,14 @@ <groupId>io.quarkus</groupId> <artifactId>quarkus-jackson</artifactId> </dependency> + <dependency> + <groupId>org.graalvm.nativeimage</groupId> + <artifactId>svm</artifactId> + <scope>provided</scope> + </dependency> </dependencies> + <build> <plugins> <plugin> diff --git a/extensions/atlasmap/runtime/src/main/java/org/apache/camel/quarkus/component/atlasmap/AtlasmapRecorder.java b/extensions/atlasmap/runtime/src/main/java/org/apache/camel/quarkus/component/atlasmap/AtlasmapRecorder.java deleted file mode 100644 index 146484c..0000000 --- a/extensions/atlasmap/runtime/src/main/java/org/apache/camel/quarkus/component/atlasmap/AtlasmapRecorder.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.apache.camel.quarkus.component.atlasmap; - -import java.net.URL; -import java.util.Collections; -import java.util.Enumeration; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -import io.atlasmap.core.DefaultAtlasContextFactory; -import io.quarkus.runtime.RuntimeValue; -import io.quarkus.runtime.annotations.Recorder; -import org.apache.camel.component.atlasmap.AtlasMapComponent; -import org.jboss.logging.Logger; - -@Recorder -public class AtlasmapRecorder { - - public RuntimeValue<AtlasMapComponent> createAtlasmapComponent() { - /* - * TODO simplify once https://github.com/atlasmap/atlasmap/issues/2704 is solved - * Currently there is no way to directly create a DefaultAtlasContextFactory with a custom compound class loader - */ - final DefaultAtlasContextFactory cf = DefaultAtlasContextFactory.getInstance(); - cf.destroy(); - final CamelQuarkusCompoundClassLoader compoundClassLoader = new CamelQuarkusCompoundClassLoader(); - final ClassLoader tccl = Thread.currentThread().getContextClassLoader(); - compoundClassLoader.addAlternativeLoader(tccl); - cf.init(compoundClassLoader); - - final AtlasMapComponent component = new AtlasMapComponent(); - component.setAtlasContextFactory(cf); - return new RuntimeValue<AtlasMapComponent>(component); - } - - /** - * TODO: remove once https://github.com/atlasmap/atlasmap/pull/2703 is fixed in an AtlasMap version we use - */ - static class CamelQuarkusCompoundClassLoader extends io.atlasmap.core.CompoundClassLoader { - private static final Logger LOG = Logger.getLogger(CamelQuarkusCompoundClassLoader.class); - - private Set<ClassLoader> delegates = new LinkedHashSet<>(); - - @Override - public Class<?> loadClass(String name) throws ClassNotFoundException { - for (ClassLoader cl : delegates) { - try { - return cl.loadClass(name); - } catch (Throwable t) { - LOG.debugf(t, "Class '%s' was not found with ClassLoader '%s'", name, cl); - } - } - throw new ClassNotFoundException(name); - } - - @Override - public URL getResource(String name) { - for (ClassLoader cl : delegates) { - URL url = cl.getResource(name); - if (url != null) { - return url; - } - LOG.debugf("Resource '%s' was not found with ClassLoader '%s'", name, cl); - } - return null; - } - - @Override - public Enumeration<URL> getResources(String name) { - List<URL> answer = new LinkedList<>(); - for (ClassLoader cl : delegates) { - try { - Enumeration<URL> urls = cl.getResources(name); - while (urls != null && urls.hasMoreElements()) { - answer.add(urls.nextElement()); - } - } catch (Exception e) { - LOG.debugf(e, "I/O error while looking for a resource '%s' with ClassLoader '%s'", name, cl); - } - } - return Collections.enumeration(answer); - } - - @Override - public synchronized void addAlternativeLoader(ClassLoader cl) { - delegates.add(cl); - } - } -} diff --git a/extensions/atlasmap/runtime/src/main/java/org/apache/camel/quarkus/component/atlasmap/graalvm/Substitutions.java b/extensions/atlasmap/runtime/src/main/java/org/apache/camel/quarkus/component/atlasmap/graalvm/Substitutions.java new file mode 100644 index 0000000..53779cf --- /dev/null +++ b/extensions/atlasmap/runtime/src/main/java/org/apache/camel/quarkus/component/atlasmap/graalvm/Substitutions.java @@ -0,0 +1,21 @@ +package org.apache.camel.quarkus.component.atlasmap.graalvm; + +import java.util.Set; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +public class Substitutions { +} + +@TargetClass(className = "io.atlasmap.core.DefaultAtlasCompoundClassLoader") +final class DefaultAtlasCompoundClassLoader_Substitute { + @Alias + private Set<ClassLoader> delegates; + + @Substitute + public synchronized void addAlternativeLoader(ClassLoader cl) { + delegates.add(Thread.currentThread().getContextClassLoader()); + } +}