All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.sqlclient.impl.PoolBase Maven / Gradle / Ivy

/*
 * Copyright (C) 2019,2020 IBM Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.vertx.sqlclient.impl;

import io.vertx.codegen.annotations.Nullable;
import io.vertx.core.AsyncResult;
import io.vertx.core.Context;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.impl.CloseFuture;
import io.vertx.core.impl.ContextInternal;
import io.vertx.core.impl.VertxInternal;
import io.vertx.core.impl.future.PromiseInternal;
import io.vertx.sqlclient.*;
import io.vertx.sqlclient.spi.Driver;

import java.util.function.Function;

public class PoolBase

implements Pool, SqlClientInternal { private final VertxInternal vertx; private final CloseFuture closeFuture; private final Pool delegate; public PoolBase(VertxInternal vertx, CloseFuture closeFuture, Pool delegate) { this.vertx = vertx; this.closeFuture = closeFuture; this.delegate = delegate; } @Override public Driver driver() { return ((SqlClientInternal)delegate).driver(); } @Override public void group(Handler block) { } @Override public void getConnection(Handler> handler) { delegate.getConnection(handler); } @Override public Future getConnection() { return delegate.getConnection(); } @Override public Query> query(String sql) { return delegate.query(sql); } @Override public PreparedQuery> preparedQuery(String sql) { return delegate.preparedQuery(sql); } @Override public Future<@Nullable T> withTransaction(TransactionPropagation txPropagation, Function> function) { return delegate.withTransaction(txPropagation, function); } @Override public P connectHandler(Handler handler) { delegate.connectHandler(handler); return (P) this; } @Override public P connectionProvider(Function> provider) { delegate.connectionProvider(provider); return (P) this; } @Override public int size() { return delegate.size(); } @Override public PreparedQuery> preparedQuery(String sql, PrepareOptions options) { return delegate.preparedQuery(sql, options); } @Override public void close(Handler> handler) { ContextInternal closingCtx = vertx.getOrCreateContext(); closeFuture.close(handler != null ? closingCtx.promise(handler) : null); } @Override public Future close() { ContextInternal closingCtx = vertx.getOrCreateContext(); PromiseInternal promise = closingCtx.promise(); closeFuture.close(promise); return promise.future(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy