io.quarkus.datasource.runtime.DataSourceSupport Maven / Gradle / Ivy
package io.quarkus.datasource.runtime;
import java.util.HashSet;
import java.util.Set;
/**
* Helper class that holds the names of all configured data sources,
* along with the names of those that are inactive or excluded from health checks.
*
* This is used by any feature that needs runtime access to data sources,
* e.g. Flyway/Liquibase or health check implementation classes.
*/
public class DataSourceSupport {
private final Set healthCheckExcludedNames;
private final Set inactiveNames;
private final Set inactiveOrHealthCheckExcludedNames;
public DataSourceSupport(Set healthCheckExcludedNames,
Set inactiveNames) {
this.healthCheckExcludedNames = healthCheckExcludedNames;
this.inactiveOrHealthCheckExcludedNames = new HashSet<>();
inactiveOrHealthCheckExcludedNames.addAll(inactiveNames);
inactiveOrHealthCheckExcludedNames.addAll(healthCheckExcludedNames);
this.inactiveNames = inactiveNames;
}
/**
* @deprecated This may not account for datasources deactivated automatically (due to missing configuration, ...).
* To check if a datasource bean is active, use
* {@code Arc.container().select(...).getHandle().getBean().isActive()}.
* Alternatively, to check if a datasource is active, use the utils
* {@code AgroalDataSourceUtil#dataSourceIfActive(...)}/{@code AgroalDataSourceUtil#activeDataSourceNames()}
* or
* {@code ReactiveDataSourceUtil#dataSourceIfActive(...)}/{@code ReactiveDataSourceUtil#activeDataSourceNames()}.
*/
@Deprecated
public Set getInactiveNames() {
return inactiveNames;
}
/**
* @deprecated This may not account for datasources deactivated automatically (due to missing configuration, ...).
* To check if a datasource is excluded from health checks, use {@link #getHealthCheckExcludedNames()}.
* To check if a datasource bean is active, use
* {@code Arc.container().select(...).getHandle().getBean().isActive()}.
* Alternatively, to check if a datasource is active, use the utils
* {@code AgroalDataSourceUtil#dataSourceIfActive(...)}/{@code AgroalDataSourceUtil#activeDataSourceNames()}
* or
* {@code ReactiveDataSourceUtil#dataSourceIfActive(...)}/{@code ReactiveDataSourceUtil#activeDataSourceNames()}.
*/
@Deprecated
public Set getInactiveOrHealthCheckExcludedNames() {
return inactiveOrHealthCheckExcludedNames;
}
public Set getHealthCheckExcludedNames() {
return healthCheckExcludedNames;
}
}