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

io.quarkus.agroal.runtime.AgroalDataSourceUtil Maven / Gradle / Ivy

There is a newer version: 3.17.5
Show newest version
package io.quarkus.agroal.runtime;

import java.lang.annotation.Annotation;

import jakarta.enterprise.inject.Default;
import jakarta.enterprise.inject.spi.Bean;

import io.quarkus.agroal.DataSource;
import io.quarkus.datasource.common.runtime.DataSourceUtil;

public final class AgroalDataSourceUtil {
    private AgroalDataSourceUtil() {
    }

    public static String dataSourceName(Bean bean) {
        for (Object qualifier : bean.getQualifiers()) {
            if (qualifier instanceof DataSource) {
                return ((DataSource) qualifier).value();
            }
        }
        return DataSourceUtil.DEFAULT_DATASOURCE_NAME;
    }

    public static Annotation qualifier(String dataSourceName) {
        if (DataSourceUtil.isDefault(dataSourceName)) {
            return Default.Literal.INSTANCE;
        } else {
            return new DataSource.DataSourceLiteral(dataSourceName);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy