synchronized DataSource ds() { if (ds == null) { String providerClass = config.getString("provider_class"); if (providerClass == null) { providerClass = DEFAULT_PROVIDER_CLASS; } try { Class clazz = getClassLoader().loadClass(providerClass); provider = (DataSourceProvider) clazz.newInstance(); ds = provider.getDataSource(config); } catch (Exception e) { throw new RuntimeException(e); } } return ds; }
synchronized void close() { if (--refCount == 0) { if (provider != null) { vertx.executeBlocking( future -> { try { provider.close(ds); future.complete(); } catch (SQLException e) { future.fail(e); } }, null); } if (exec != null) { exec.shutdown(); } if (closeRunner != null) { closeRunner.run(); } } }