io.honeycomb.beeline.spring.beans.DataSourceProxyBeanPostProcessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of beeline-spring-boot-starter Show documentation
Show all versions of beeline-spring-boot-starter Show documentation
Spring Boot Starter module to auto-configure Spring Boot with the Honeycomb Beeline for Java
package io.honeycomb.beeline.spring.beans;
import net.ttddyy.dsproxy.support.ProxyDataSource;
import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder;
import org.springframework.beans.factory.config.BeanPostProcessor;
import javax.sql.DataSource;
public class DataSourceProxyBeanPostProcessor implements BeanPostProcessor {
private final BeelineQueryListenerForJDBC listener;
public DataSourceProxyBeanPostProcessor(BeelineQueryListenerForJDBC listener) {
this.listener = listener;
}
@Override
public Object postProcessAfterInitialization(final Object bean, final String beanName) {
if (!DataSource.class.isAssignableFrom(bean.getClass()) || ProxyDataSource.class.isAssignableFrom(bean.getClass())) {
return bean;
}
return ProxyDataSourceBuilder.create((DataSource) bean)
.name(beanName)
.listener(listener)
.build();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy