io.helidon.dbclient.DbClientServiceContext Maven / Gradle / Ivy
Show all versions of helidon-dbclient Show documentation
/*
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
*
* 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.helidon.dbclient;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletionStage;
import io.helidon.common.context.Context;
/**
* Interceptor context to get (and possibly manipulate) database operations.
*
* This is a mutable object - acts as a builder during the invocation of {@link DbClientService}.
* The interceptors are executed sequentially, so there is no need for synchronization.
*/
public interface DbClientServiceContext {
/**
* Create a new interceptor context for a database provider.
*
* @param dbType a short name of the db type (such as jdbc:mysql)
* @return a new interceptor context ready to be configured
*/
static DbClientServiceContext create(String dbType) {
return new DbClientServiceContextImpl(dbType);
}
/**
* Type of this database (usually the same string used by the {@link io.helidon.dbclient.spi.DbClientProvider#name()}).
*
* @return type of database
*/
String dbType();
/**
* Context with parameters passed from the caller, such as {@code SpanContext} for tracing.
*
* @return context associated with this request
*/
Context context();
/**
* Name of a statement to be executed.
* Ad hoc statements have names generated.
*
* @return name of the statement
*/
String statementName();
/**
* Text of the statement to be executed.
*
* @return statement text
*/
String statement();
/**
* A stage that is completed once the statement finishes execution.
*
* @return statement future
*/
CompletionStage statementFuture();
/**
* A stage that is completed once the results were fully read. The number returns either the number of modified
* records or the number of records actually read.
*
* @return stage that completes once all query results were processed.
*/
CompletionStage resultFuture();
/**
* Indexed parameters (if used).
*
* @return indexed parameters (empty if this statement parameters are not indexed)
*/
Optional> indexedParameters();
/**
* Named parameters (if used).
*
* @return named parameters (empty if this statement parameters are not named)
*/
Optional