
com.tqdev.metrics.spring.loaders.DatasourceProxyBeanPostProcessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of metrics-spring-loaders Show documentation
Show all versions of metrics-spring-loaders Show documentation
Package to scan for components in order to instrument a Spring application.
The newest version!
package com.tqdev.metrics.spring.loaders;
import javax.sql.DataSource;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;
import com.tqdev.metrics.core.MetricRegistry;
import com.tqdev.metrics.jdbc.InstrumentedDataSource;
@Component
public class DatasourceProxyBeanPostProcessor implements BeanPostProcessor {
@Autowired
private MetricRegistry metricRegistry;
@Override
public Object postProcessBeforeInitialization(final Object bean, final String beanName) throws BeansException {
return bean;
}
@Override
public Object postProcessAfterInitialization(final Object bean, final String beanName) throws BeansException {
if (bean instanceof DataSource) {
return new InstrumentedDataSource((DataSource) bean, metricRegistry);
}
return bean;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy