|
|
|
@ -30,11 +30,15 @@ import java.util.TreeSet;
|
|
|
|
|
import java.util.concurrent.ThreadFactory;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
import javax.naming.InitialContext;
|
|
|
|
|
import javax.naming.NamingException;
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import com.codahale.metrics.MetricRegistry;
|
|
|
|
|
import com.codahale.metrics.health.HealthCheckRegistry;
|
|
|
|
|
import com.zaxxer.hikari.proxy.JavassistProxyFactory;
|
|
|
|
|
import com.zaxxer.hikari.util.PropertyBeanSetter;
|
|
|
|
|
import com.zaxxer.hikari.util.UtilityElf;
|
|
|
|
@ -506,9 +510,22 @@ public class HikariConfig implements HikariConfigMBean
|
|
|
|
|
*/
|
|
|
|
|
public void setMetricRegistry(Object metricRegistry)
|
|
|
|
|
{
|
|
|
|
|
if (metricRegistry != null && !metricRegistry.getClass().getName().contains("MetricRegistry")) {
|
|
|
|
|
throw new IllegalArgumentException("Class must be an instance of com.codahale.metrics.MetricRegistry");
|
|
|
|
|
if (metricRegistry != null) {
|
|
|
|
|
if (metricRegistry instanceof String) {
|
|
|
|
|
try {
|
|
|
|
|
InitialContext initCtx = new InitialContext();
|
|
|
|
|
metricRegistry = (MetricRegistry) initCtx.lookup((String) metricRegistry);
|
|
|
|
|
}
|
|
|
|
|
catch (NamingException e) {
|
|
|
|
|
throw new IllegalArgumentException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(metricRegistry instanceof MetricRegistry)) {
|
|
|
|
|
throw new IllegalArgumentException("Class must be an instance of com.codahale.metrics.MetricRegistry");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.metricRegistry = metricRegistry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -529,9 +546,22 @@ public class HikariConfig implements HikariConfigMBean
|
|
|
|
|
*/
|
|
|
|
|
public void setHealthCheckRegistry(Object healthCheckRegistry)
|
|
|
|
|
{
|
|
|
|
|
if (healthCheckRegistry != null && !healthCheckRegistry.getClass().getName().contains("HealthCheckRegistry")) {
|
|
|
|
|
throw new IllegalArgumentException("Class must be an instance of com.codahale.metrics.health.HealthCheckRegistry");
|
|
|
|
|
if (healthCheckRegistry != null) {
|
|
|
|
|
if (healthCheckRegistry instanceof String) {
|
|
|
|
|
try {
|
|
|
|
|
InitialContext initCtx = new InitialContext();
|
|
|
|
|
healthCheckRegistry = (MetricRegistry) initCtx.lookup((String) healthCheckRegistry);
|
|
|
|
|
}
|
|
|
|
|
catch (NamingException e) {
|
|
|
|
|
throw new IllegalArgumentException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(healthCheckRegistry instanceof HealthCheckRegistry)) {
|
|
|
|
|
throw new IllegalArgumentException("Class must be an instance of com.codahale.metrics.health.HealthCheckRegistry");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.healthCheckRegistry = healthCheckRegistry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|