com.codahale.metrics.jdbi.strategies.DelegatingStatementNameStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of metrics-jdbi Show documentation
Show all versions of metrics-jdbi Show documentation
A JDBI wrapper providing Metrics instrumentation of query durations and rates.
package com.codahale.metrics.jdbi.strategies;
import org.skife.jdbi.v2.StatementContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public abstract class DelegatingStatementNameStrategy implements StatementNameStrategy {
private final List strategies = new ArrayList<>();
protected DelegatingStatementNameStrategy(StatementNameStrategy... strategies) {
registerStrategies(strategies);
}
protected void registerStrategies(StatementNameStrategy... strategies) {
this.strategies.addAll(Arrays.asList(strategies));
}
@Override
public String getStatementName(StatementContext statementContext) {
for (StatementNameStrategy strategy : strategies) {
final String statementName = strategy.getStatementName(statementContext);
if (statementName != null) {
return statementName;
}
}
return NameStrategies.UNKNOWN_SQL;
}
}