io.quarkiverse.doma.runtime.DataSourceResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-doma Show documentation
Show all versions of quarkus-doma Show documentation
Simplify your database accesses with compile-time code generation
The newest version!
package io.quarkiverse.doma.runtime;
import java.util.Objects;
import javax.sql.DataSource;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import io.quarkus.agroal.runtime.DataSources;
import io.quarkus.arc.DefaultBean;
import io.quarkus.arc.Unremovable;
public interface DataSourceResolver {
DataSource resolve(String dataSourceName);
@Singleton
@DefaultBean
@Unremovable
class DefaultDataSourceResolver implements DataSourceResolver {
private final DataSources dataSources;
@Inject
public DefaultDataSourceResolver(DataSources dataSources) {
this.dataSources = Objects.requireNonNull(dataSources);
}
@Override
public DataSource resolve(String dataSourceName) {
Objects.requireNonNull(dataSourceName);
return dataSources.getDataSource(dataSourceName);
}
}
}