Search in sources :

Example 1 with DataSourcePoolMetadataProviders

use of org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProviders in project spring-boot by spring-projects.

the class DataSourcePublicMetrics method initialize.

@PostConstruct
public void initialize() {
    DataSource primaryDataSource = getPrimaryDataSource();
    DataSourcePoolMetadataProvider provider = new DataSourcePoolMetadataProviders(this.providers);
    for (Map.Entry<String, DataSource> entry : this.applicationContext.getBeansOfType(DataSource.class).entrySet()) {
        String beanName = entry.getKey();
        DataSource bean = entry.getValue();
        String prefix = createPrefix(beanName, bean, bean.equals(primaryDataSource));
        DataSourcePoolMetadata poolMetadata = provider.getDataSourcePoolMetadata(bean);
        if (poolMetadata != null) {
            this.metadataByPrefix.put(prefix, poolMetadata);
        }
    }
}
Also used : DataSourcePoolMetadataProviders(org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProviders) DataSourcePoolMetadata(org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadata) DataSourcePoolMetadataProvider(org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProvider) HashMap(java.util.HashMap) Map(java.util.Map) DataSource(javax.sql.DataSource) PostConstruct(javax.annotation.PostConstruct)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 PostConstruct (javax.annotation.PostConstruct)1 DataSource (javax.sql.DataSource)1 DataSourcePoolMetadata (org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadata)1 DataSourcePoolMetadataProvider (org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProvider)1 DataSourcePoolMetadataProviders (org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProviders)1