io.vertx.ext.jdbc.spi.DataSourceProvider Java Examples

The following examples show how to use io.vertx.ext.jdbc.spi.DataSourceProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JDBCClientImpl.java    From vertx-jdbc-client with Apache License 2.0 5 votes vote down vote up
/**
 * Create client with shared datasource.
 */
public JDBCClientImpl(Vertx vertx, JsonObject config, String datasourceName) {
  Objects.requireNonNull(vertx);
  Objects.requireNonNull(config);
  Objects.requireNonNull(datasourceName);
  this.vertx = (VertxInternal) vertx;
  this.datasourceName = datasourceName;
  this.config = config;
  holders = vertx.sharedData().getLocalMap(DS_LOCAL_MAP_NAME);
  DataSourceProvider provider = createProvider();
  holders.compute(datasourceName, (k, h) -> h == null ? new DataSourceHolder(provider) : h.increment());
  this.helper = new JDBCStatementHelper(config);
  setupCloseHook();
}
 
Example #2
Source File: DataSourceHolder.java    From vertx-jdbc-client with Apache License 2.0 5 votes vote down vote up
private DataSourceHolder(TaskQueue creationQueue, DataSourceProvider provider, DataSource dataSource, ExecutorService exec, PoolMetrics metrics, int refCount) {
  if (dataSource != null) {
    Objects.requireNonNull(exec);
  } else {
    Objects.requireNonNull(creationQueue);
    Objects.requireNonNull(provider);
  }
  this.creationQueue = creationQueue;
  this.provider = provider;
  this.dataSource = dataSource;
  this.exec = exec;
  this.metrics = metrics;
  this.refCount = refCount;
}
 
Example #3
Source File: CloseTest.java    From vertx-jdbc-client with Apache License 2.0 5 votes vote down vote up
@Test
public void testUsingProvidedDataSourceVerticle() throws Exception {
  DataSourceProvider provider = new C3P0DataSourceProvider();
  ds = provider.getDataSource(theConfig);
  CompletableFuture<String> id = new CompletableFuture<>();
  vertx.deployVerticle(ProvidedDataSourceVerticle.class.getName(), new DeploymentOptions().setInstances(1), onSuccess(id::complete));
  close(id.get(10, TimeUnit.SECONDS), true);
}
 
Example #4
Source File: DataSourceHolder.java    From vertx-jdbc-client with Apache License 2.0 4 votes vote down vote up
DataSourceHolder(DataSourceProvider provider) {
  this(new TaskQueue(), provider, null, null, null, 1);
}