com.transferwise.common.entrypoints.transactionstatistics.TransactionStatisticsBeanPostProcessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tw-entrypoints-starter Show documentation
Show all versions of tw-entrypoints-starter Show documentation
Transferwise EntryPoints Starter - Spring Boot Starter for tw-entrypoints
package com.transferwise.common.entrypoints.transactionstatistics;
import com.transferwise.common.baseutils.meters.cache.IMeterCache;
import com.transferwise.common.entrypoints.BaseEntryPointsBeanProcessor;
import com.transferwise.common.spyql.SpyqlDataSource;
import org.springframework.beans.factory.BeanFactory;
public class TransactionStatisticsBeanPostProcessor extends BaseEntryPointsBeanProcessor {
private final BeanFactory beanFactory;
public TransactionStatisticsBeanPostProcessor(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}
@Override
protected void instrument(SpyqlDataSource spyqlDataSource, String databaseName) {
boolean isAlreadyAttached = spyqlDataSource.getDataSourceListeners().stream().anyMatch(
l -> l instanceof TransactionsStatisticsSpyqlListener);
if (isAlreadyAttached) {
return;
}
IMeterCache meterCache = beanFactory.getBean(IMeterCache.class);
TransactionsStatisticsSpyqlListener listener = new TransactionsStatisticsSpyqlListener(meterCache, databaseName);
spyqlDataSource.addListener(listener);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy