@@ -0,0 +1,2523 @@
+package io.quarkus.jdbc.postgresql.runtime.graal;%0A%0Aimport java.lang.reflect.Method;%0Aimport java.util.concurrent.atomic.AtomicBoolean;%0A%0Aimport javax.xml.transform.dom.DOMResult;%0A%0Aimport org.graalvm.nativeimage.hosted.Feature;%0Aimport org.graalvm.nativeimage.hosted.RuntimeReflection;%0Aimport org.postgresql.core.BaseConnection;%0A%0Aimport com.oracle.svm.core.annotate.AutomaticFeature;%0A%0A@AutomaticFeature%0Apublic final class SQLXLMFeature implements Feature %7B%0A%0A    private final AtomicBoolean triggered = new AtomicBoolean(false);%0A%0A    /**%0A     * To set this, add %60-J-Dio.quarkus.jdbc.postgresql.graalvm.diagnostics=true%60 to the native-image parameters%0A     */%0A    private static final boolean log = Boolean.getBoolean(%22io.quarkus.jdbc.postgresql.graalvm.diagnostics%22);%0A%0A    @Override%0A    public void beforeAnalysis(BeforeAnalysisAccess access) %7B%0A        Class%3C?%3E pgSQLXMLClass = access.findClassByName(%22io.quarkus.jdbc.postgresql.runtime.graal.PgSQLXML%22);%0A        try %7B%0A            //Only if this method is ever invoked, then it's possible that field %7B@link PgSQLXML#domResult %7D%0A            //is ever non-null, and only in that case the XML parsing facilities pulled in by the driver%0A            //end up being necessary.%0A            final Method triggerMethod = pgSQLXMLClass.getMethod(%22setResult%22, Class.class);%0A            access.registerReachabilityHandler(this::identifiedXMLProcessingInDriver, triggerMethod);%0A        %7D catch (Exception e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%0A    private void identifiedXMLProcessingInDriver(DuringAnalysisAccess duringAnalysisAccess) %7B%0A        final boolean needsEnablingYet = triggered.compareAndSet(false, true);%0A        if (needsEnablingYet) %7B%0A            if (log) %7B%0A                System.out.println(%0A                        %22Quarkus's automatic feature for GraalVM native images: enabling support for XML processing in the PosgreSQL JDBC driver%22);%0A            %7D%0A            enableDomXMLProcessingInDriver(duringAnalysisAccess);%0A        %7D%0A    %7D%0A%0A    private void enableDomXMLProcessingInDriver(DuringAnalysisAccess duringAnalysisAccess) %7B%0A        final Class%3C?%3E classByName = duringAnalysisAccess.findClassByName(%22io.quarkus.jdbc.postgresql.runtime.graal.DomHelper%22);%0A        try %7B%0A            final Method method = classByName.getMethod(%22reallyProcessDomResult%22, DOMResult.class, BaseConnection.class);%0A            RuntimeReflection.register(method);%0A        %7D catch (NoSuchMethodException e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%0A%7D%0A

Introduce an AutomaticFeature for jdbc-postgresql enabling XML processing capabilities only when required