diff --git a/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java b/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java index 51cce765f1fa9..c661f5ea866b6 100644 --- a/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java +++ b/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java @@ -1,7 +1,6 @@ package io.quarkus.narayana.jta.deployment; import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT; -import static io.quarkus.deployment.annotations.ExecutionTime.STATIC_INIT; import java.util.List; import java.util.Map; @@ -101,8 +100,11 @@ public void build(NarayanaJtaRecorder recorder, BuildProducer reflectiveClass, BuildProducer runtimeInit, BuildProducer feature, + BuildProducer logCleanupFilters, + BuildProducer nativeImageFeatures, TransactionManagerConfiguration transactions, TransactionManagerBuildTimeConfig transactionManagerBuildTimeConfig, - ShutdownContextBuildItem shutdownContextBuildItem) { + ShutdownContextBuildItem shutdownContextBuildItem, + Capabilities capabilities) { recorder.handleShutdown(shutdownContextBuildItem, transactions); feature.produce(new FeatureBuildItem(Feature.NARAYANA_JTA)); additionalBeans.produce(new AdditionalBeanBuildItem(NarayanaJtaProducers.class)); @@ -163,44 +165,13 @@ public void build(NarayanaJtaRecorder recorder, recorder.setDefaultProperties(defaultProperties); // This must be done before setNodeName as the code in setNodeName will create a TSM based on the value of this property recorder.disableTransactionStatusManager(); + allowUnsafeMultipleLastResources(recorder, transactionManagerBuildTimeConfig, capabilities, logCleanupFilters, + nativeImageFeatures); recorder.setNodeName(transactions); recorder.setDefaultTimeout(transactions); recorder.setConfig(transactions); } - @BuildStep - @Record(STATIC_INIT) - public void allowUnsafeMultipleLastResources(NarayanaJtaRecorder recorder, - TransactionManagerBuildTimeConfig transactionManagerBuildTimeConfig, - Capabilities capabilities, BuildProducer logCleanupFilters, - BuildProducer nativeImageFeatures) { - switch (transactionManagerBuildTimeConfig.unsafeMultipleLastResources - .orElse(UnsafeMultipleLastResourcesMode.DEFAULT)) { - case ALLOW -> { - recorder.allowUnsafeMultipleLastResources(capabilities.isPresent(Capability.AGROAL), true); - // we will handle the warnings ourselves at runtime init when the option is set explicitly - logCleanupFilters.produce( - new LogCleanupFilterBuildItem("com.arjuna.ats.arjuna", "ARJUNA012139", "ARJUNA012141", "ARJUNA012142")); - } - case WARN_FIRST -> { - recorder.allowUnsafeMultipleLastResources(capabilities.isPresent(Capability.AGROAL), true); - // we will handle the warnings ourselves at runtime init when the option is set explicitly - // but we still want Narayana to produce a warning on the first offending transaction - logCleanupFilters.produce( - new LogCleanupFilterBuildItem("com.arjuna.ats.arjuna", "ARJUNA012139", "ARJUNA012142")); - } - case WARN_EACH -> { - recorder.allowUnsafeMultipleLastResources(capabilities.isPresent(Capability.AGROAL), false); - // we will handle the warnings ourselves at runtime init when the option is set explicitly - // but we still want Narayana to produce one warning per offending transaction - logCleanupFilters.produce( - new LogCleanupFilterBuildItem("com.arjuna.ats.arjuna", "ARJUNA012139", "ARJUNA012142")); - } - case FAIL -> { // No need to do anything, this is the default behavior of Narayana - } - } - } - @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) public void nativeImageFeature(TransactionManagerBuildTimeConfig transactionManagerBuildTimeConfig, BuildProducer nativeImageFeatures) { @@ -271,4 +242,35 @@ void unremovableBean(BuildProducer unremovableBeans) { void logCleanupFilters(BuildProducer logCleanupFilters) { logCleanupFilters.produce(new LogCleanupFilterBuildItem("com.arjuna.ats.jbossatx", "ARJUNA032010:", "ARJUNA032013:")); } + + private void allowUnsafeMultipleLastResources(NarayanaJtaRecorder recorder, + TransactionManagerBuildTimeConfig transactionManagerBuildTimeConfig, + Capabilities capabilities, BuildProducer logCleanupFilters, + BuildProducer nativeImageFeatures) { + switch (transactionManagerBuildTimeConfig.unsafeMultipleLastResources + .orElse(UnsafeMultipleLastResourcesMode.DEFAULT)) { + case ALLOW -> { + recorder.allowUnsafeMultipleLastResources(capabilities.isPresent(Capability.AGROAL), true); + // we will handle the warnings ourselves at runtime init when the option is set explicitly + logCleanupFilters.produce( + new LogCleanupFilterBuildItem("com.arjuna.ats.arjuna", "ARJUNA012139", "ARJUNA012141", "ARJUNA012142")); + } + case WARN_FIRST -> { + recorder.allowUnsafeMultipleLastResources(capabilities.isPresent(Capability.AGROAL), true); + // we will handle the warnings ourselves at runtime init when the option is set explicitly + // but we still want Narayana to produce a warning on the first offending transaction + logCleanupFilters.produce( + new LogCleanupFilterBuildItem("com.arjuna.ats.arjuna", "ARJUNA012139", "ARJUNA012142")); + } + case WARN_EACH -> { + recorder.allowUnsafeMultipleLastResources(capabilities.isPresent(Capability.AGROAL), false); + // we will handle the warnings ourselves at runtime init when the option is set explicitly + // but we still want Narayana to produce one warning per offending transaction + logCleanupFilters.produce( + new LogCleanupFilterBuildItem("com.arjuna.ats.arjuna", "ARJUNA012139", "ARJUNA012142")); + } + case FAIL -> { // No need to do anything, this is the default behavior of Narayana + } + } + } }