All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkiverse.doma.runtime.DataSourceResolver Maven / Gradle / Ivy

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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy