All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codahale.metrics.jdbi.strategies.DelegatingStatementNameStrategy Maven / Gradle / Ivy

Go to download

A JDBI wrapper providing Metrics instrumentation of query durations and rates.

There is a newer version: 4.2.28
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy