@@ -0,0 +1,2426 @@
+package com.codacy.play.tomcatcp.pool;%0A%0Aimport com.codacy.play.tomcatcp.metrics.MetricsTracker;%0Aimport com.codacy.play.tomcatcp.metrics.MetricsTrackerFactory;%0Aimport com.codacy.play.tomcatcp.metrics.PoolStats;%0Aimport com.codacy.play.tomcatcp.metrics.dropwizard.CodahaleMetricsTrackerFactory;%0Aimport com.codahale.metrics.MetricRegistry;%0Aimport com.codahale.metrics.health.HealthCheckRegistry;%0Aimport com.zaxxer.hikari.metrics.CodahaleHealthChecker;%0Aimport org.apache.tomcat.jdbc.pool.ConnectionPool;%0Aimport org.apache.tomcat.jdbc.pool.PoolConfiguration;%0A%0Aimport java.sql.SQLException;%0A%0Aimport static java.util.concurrent.TimeUnit.SECONDS;%0A%0Apublic class TomcatCPPool extends ConnectionPool %7B%0A    private boolean isRecordMetrics;%0A    private MetricsTracker metricsTracker;%0A%0A    public TomcatCPPool(PoolConfiguration prop) throws SQLException %7B%0A        super(prop);%0A    %7D%0A%0A    public void setMetricRegistry(MetricRegistry metricRegistry) %7B%0A        this.isRecordMetrics = metricRegistry != null;%0A        if (isRecordMetrics) %7B%0A            setMetricsTrackerFactory(new CodahaleMetricsTrackerFactory(metricRegistry));%0A        %7D else %7B%0A            setMetricsTrackerFactory(null);%0A        %7D%0A    %7D%0A%0A    public void setMetricsTrackerFactory(MetricsTrackerFactory metricsTrackerFactory) %7B%0A        this.isRecordMetrics = metricsTrackerFactory != null;%0A        if (isRecordMetrics) %7B%0A            this.metricsTracker = metricsTrackerFactory.create(getName(), getPoolStats());%0A        %7D else %7B%0A            this.metricsTracker = new MetricsTracker();%0A        %7D%0A    %7D%0A%0A    public void setHealthCheckRegistry(HealthCheckRegistry healthCheckRegistry) %7B%0A        if (healthCheckRegistry != null) %7B%0A            //CodahaleHealthChecker.registerHealthChecks(this, config, healthCheckRegistry);%0A        %7D%0A    %7D%0A%0A    @Override%0A    protected void close(boolean force) %7B%0A        try %7B%0A            super.close(force);%0A        %7D finally %7B%0A            metricsTracker.close();%0A        %7D%0A    %7D%0A%0A    private PoolStats getPoolStats() %7B%0A        return new PoolStats(SECONDS.toMillis(1)) %7B%0A            @Override%0A            protected void update() %7B%0A                this.pendingThreads = TomcatCPPool.this.getWaitCount();%0A                this.idleConnections = TomcatCPPool.this.getIdle();%0A                this.totalConnections = TomcatCPPool.this.getSize();%0A                this.activeConnections = TomcatCPPool.this.getActive();%0A            %7D%0A        %7D;%0A    %7D%0A%7D%0A

Add a wrapper class for the pool