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

The following examples show how to use io.vertx.ext.jdbc.spi.DataSourceProvider. These examples are extracted from open source projects. 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 Project: vertx-jdbc-client   Source File: JDBCClientImpl.java    License: 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 Project: vertx-jdbc-client   Source File: DataSourceHolder.java    License: 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 Project: vertx-jdbc-client   Source File: CloseTest.java    License: 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 Project: vertx-jdbc-client   Source File: DataSourceHolder.java    License: Apache License 2.0 4 votes vote down vote up
DataSourceHolder(DataSourceProvider provider) {
  this(new TaskQueue(), provider, null, null, null, 1);
}