先来看下HikariDataSource是怎么往PlatformMBeanServer中注入mbean的
1.定义了一个满足规范的MXBean接口
public interface HikariPoolMXBean
{
int getIdleConnections();
int getActiveConnections();
int getTotalConnections();
int getThreadsAwaitingConnection();
void softEvictConnections();
void suspendPool();
void resumePool();
}
2.HikariPool的构造方法
public HikariPool(final HikariConfig config)
{
super(config);
this.connectionBag = new ConcurrentBag<>(this);
this.totalConnections = new AtomicInteger();
this.suspendResumeLock = config.isAllowPoolSuspension() ? new SuspendResumeLock() : SuspendResumeLock.FAUX_LOCK;
checkFailFast();
if (config.getMetricsTrackerFactory() != null) {
setMetricsTrackerFactory(config.getMetricsTrackerFactory());
}
else {
setMetricRegistry(config.getMetricRegistry());
}
setHealthCheckRegistry(config.getHeal