@@ -0,0 +1,2955 @@
+package com.codacy.play.tomcatcp.pool;%0A%0Aimport com.codacy.play.tomcatcp.metrics.MetricsTrackerFactory;%0Aimport com.codahale.metrics.MetricRegistry;%0Aimport com.codahale.metrics.health.HealthCheckRegistry;%0Aimport org.apache.tomcat.jdbc.pool.ConnectionPool;%0Aimport org.apache.tomcat.jdbc.pool.DataSource;%0Aimport org.apache.tomcat.jdbc.pool.PoolConfiguration;%0A%0Aimport java.sql.SQLException;%0A%0Apublic class TomcatCPDataSource extends DataSource %7B%0A%0A    private MetricsTrackerFactory metricsTrackerFactory;%0A    private MetricRegistry metricRegistry;%0A    private HealthCheckRegistry healthCheckRegistry;%0A    private TomcatCPPool TCPool;%0A%0A%0A    public TomcatCPDataSource() %7B%0A        super();%0A    %7D%0A%0A%0A    public TomcatCPDataSource(PoolConfiguration poolProperties) %7B%0A        super(poolProperties);%0A    %7D%0A%0A    @Override%0A    public ConnectionPool createPool() throws SQLException %7B%0A        if (pool != null) %7B%0A            return pool;%0A        %7D else %7B%0A            TCPool = new TomcatCPPool(poolProperties);%0A            pool = TCPool;%0A            return pool;%0A        %7D%0A    %7D%0A%0A%0A    public MetricRegistry getMetricRegistry() %7B%0A        return metricRegistry;%0A    %7D%0A%0A    public void setMetricRegistry(MetricRegistry metricRegistry) %7B%0A        if (metricsTrackerFactory != null) %7B%0A            throw new IllegalStateException(%22cannot use setMetricRegistry() and setMetricsTrackerFactory() together%22);%0A        %7D%0A%0A        boolean isAlreadySet = getMetricRegistry() != null;%0A%0A        if (pool != null) %7B%0A            if (isAlreadySet) %7B%0A                throw new IllegalStateException(%22MetricRegistry can only be set one time%22);%0A            %7D else %7B%0A                TCPool.setMetricRegistry(metricRegistry);%0A            %7D%0A        %7D%0A    %7D%0A%0A    public MetricsTrackerFactory getMetricsTrackerFactory() %7B%0A        return metricsTrackerFactory;%0A    %7D%0A%0A    public void setMetricsTrackerFactory(MetricsTrackerFactory metricsTrackerFactory) %7B%0A        if (metricRegistry != null) %7B%0A            throw new IllegalStateException(%22cannot use setMetricsTrackerFactory() and setMetricRegistry() together%22);%0A        %7D%0A%0A        boolean isAlreadySet = getMetricsTrackerFactory() != null;%0A%0A        if (pool != null) %7B%0A            if (isAlreadySet) %7B%0A                throw new IllegalStateException(%22MetricsTrackerFactory can only be set one time%22);%0A            %7D else %7B%0A                TCPool.setMetricsTrackerFactory(metricsTrackerFactory);%0A            %7D%0A        %7D%0A    %7D%0A%0A    public HealthCheckRegistry getHealthCheckRegistry() %7B%0A        return healthCheckRegistry;%0A    %7D%0A%0A    public void setHealthCheckRegistry(HealthCheckRegistry healthCheckRegistry) %7B%0A        boolean isAlreadySet = getHealthCheckRegistry() != null;%0A%0A        if (pool != null) %7B%0A            if (isAlreadySet) %7B%0A                throw new IllegalStateException(%22HealthCheckRegistry can only be set one time%22);%0A            %7D else %7B%0A                TCPool.setHealthCheckRegistry(healthCheckRegistry);%0A            %7D%0A        %7D%0A    %7D%0A%0A%7D%0A

Add a wrapper class for DataSource