package io.bootique.jdbc.instrumented;

import com.codahale.metrics.MetricRegistry;
import io.bootique.annotation.BQConfig;
import io.bootique.jdbc.LazyDataSourceFactoryFactory;
import io.bootique.jdbc.TomcatDataSourceFactory;
import io.bootique.log.BootLogger;
import io.bootique.shutdown.ShutdownManager;

import java.util.Map;

@BQConfig
public class InstrumentedLazyDataSourceFactoryFactory {

    private Map<String, TomcatDataSourceFactory> configs;

    public InstrumentedLazyDataSourceFactoryFactory(Map<String, TomcatDataSourceFactory> configs) {
        this.configs = configs;
    }

    public InstrumentedLazyDataSourceFactory create(
            ShutdownManager shutdownManager,
            BootLogger bootLogger,
            MetricRegistry metricRegistry) {

        InstrumentedLazyDataSourceFactory factory = new InstrumentedLazyDataSourceFactory(
                LazyDataSourceFactoryFactory.prunePartialConfigs(configs),
                metricRegistry);

        shutdownManager.addShutdownHook(() -> {
            bootLogger.trace(() -> "shutting down InstrumentedLazyDataSourceFactory...");
            factory.shutdown();
        });

        return factory;
    }
}

@@ -81,48 +81,8 @@
 ry;%0A
-import io.bootique.annotation.BQConfig;%0A
 impo
@@ -288,18 +288,8 @@
 p;%0A%0A
-@BQConfig%0A
 publ

Upgrade to Bootique 0.21 and annotate config factories #26