diff --git a/extensions/agroal/deployment/src/main/java/io/quarkus/agroal/deployment/AgroalProcessor.java b/extensions/agroal/deployment/src/main/java/io/quarkus/agroal/deployment/AgroalProcessor.java index 7b6918145d288..bea70573a34d5 100644 --- a/extensions/agroal/deployment/src/main/java/io/quarkus/agroal/deployment/AgroalProcessor.java +++ b/extensions/agroal/deployment/src/main/java/io/quarkus/agroal/deployment/AgroalProcessor.java @@ -17,6 +17,7 @@ import javax.sql.XADataSource; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Singleton; import org.jboss.jandex.ClassType; import org.jboss.jandex.DotName; @@ -233,13 +234,15 @@ void generateDataSourceSupportBean(AgroalRecorder recorder, // make AgroalPoolInterceptor beans unremovable, users still have to make them beans unremovableBeans.produce(UnremovableBeanBuildItem.beanTypes(AgroalPoolInterceptor.class)); - // create the DataSourceSupport bean that DataSourceProducer uses as a dependency + // create the AgroalDataSourceSupport bean that DataSources/DataSourceHealthCheck use as a dependency AgroalDataSourceSupport agroalDataSourceSupport = getDataSourceSupport(aggregatedBuildTimeConfigBuildItems, sslNativeConfig, capabilities); syntheticBeanBuildItemBuildProducer.produce(SyntheticBeanBuildItem.configure(AgroalDataSourceSupport.class) .supplier(recorder.dataSourceSupportSupplier(agroalDataSourceSupport)) + .scope(Singleton.class) .unremovable() + .setRuntimeInit() .done()); } diff --git a/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSources.java b/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSources.java index b1156e9d9c8ca..4e08c4440c1cb 100644 --- a/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSources.java +++ b/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSources.java @@ -55,7 +55,7 @@ * For applications, use CDI to retrieve datasources instead. * For extensions, use {@link AgroalDataSourceUtil} instead. */ -@Deprecated +@Deprecated(since = "3.16", forRemoval = true) @Singleton public class DataSources { diff --git a/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/health/DataSourceHealthCheck.java b/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/health/DataSourceHealthCheck.java index 5fdc1975cabb6..55f2cd22b79ec 100644 --- a/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/health/DataSourceHealthCheck.java +++ b/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/health/DataSourceHealthCheck.java @@ -21,7 +21,6 @@ import io.agroal.api.AgroalDataSource; import io.quarkus.agroal.runtime.AgroalDataSourceSupport; import io.quarkus.agroal.runtime.AgroalDataSourceUtil; -import io.quarkus.arc.Arc; import io.quarkus.datasource.common.runtime.DataSourceUtil; import io.quarkus.datasource.runtime.DataSourceSupport; @@ -32,19 +31,20 @@ public class DataSourceHealthCheck implements HealthCheck { @Inject Instance dataSourceSupport; + @Inject + Instance agroalDataSourceSupport; + private final Map checkedDataSources = new HashMap<>(); @PostConstruct protected void init() { - if (!dataSourceSupport.isResolvable()) { - // No configured Agroal datasource at build time. + if (!dataSourceSupport.isResolvable() || !agroalDataSourceSupport.isResolvable()) { + // No configured Agroal datasources at build time. return; } DataSourceSupport support = dataSourceSupport.get(); - AgroalDataSourceSupport agroalSupport = Arc.container().instance(AgroalDataSourceSupport.class) - .get(); Set healthCheckExcludedNames = support.getHealthCheckExcludedNames(); - for (String name : agroalSupport.entries.keySet()) { + for (String name : agroalDataSourceSupport.get().entries.keySet()) { if (healthCheckExcludedNames.contains(name)) { continue; }