org.jooq.Configuration Maven / Gradle / Ivy
/**
* Copyright (c) 2009-2014, Data Geekery GmbH (http://www.datageekery.com)
* All rights reserved.
*
* This work is dual-licensed
* - under the Apache Software License 2.0 (the "ASL")
* - under the jOOQ License and Maintenance Agreement (the "jOOQ License")
* =============================================================================
* You may choose which license applies to you:
*
* - If you're using this work with Open Source databases, you may choose
* either ASL or jOOQ License.
* - If you're using this work with at least one commercial database, you must
* choose jOOQ License
*
* For more information, please visit http://www.jooq.org/licenses
*
* Apache Software License 2.0:
* -----------------------------------------------------------------------------
* 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.
*
* jOOQ License and Maintenance Agreement:
* -----------------------------------------------------------------------------
* Data Geekery grants the Customer the non-exclusive, timely limited and
* non-transferable license to install and use the Software under the terms of
* the jOOQ License and Maintenance Agreement.
*
* This library is distributed with a LIMITED WARRANTY. See the jOOQ License
* and Maintenance Agreement for more details: http://www.jooq.org/licensing
*/
package org.jooq;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.Savepoint;
import java.util.Map;
import javax.sql.DataSource;
import org.jooq.conf.Settings;
import org.jooq.impl.DataSourceConnectionProvider;
import org.jooq.impl.DefaultConnectionProvider;
import org.jooq.impl.DefaultRecordMapper;
import org.jooq.impl.DefaultRecordMapperProvider;
import org.jooq.impl.DefaultTransactionProvider;
import org.jooq.tools.LoggerListener;
import org.jooq.tools.StopWatchListener;
/**
* A Configuration
configures a {@link DSLContext}, providing it
* with information for query rendering and execution.
*
* A Configuration
wraps all information elements that are
* needed...
*
* - by a {@link RenderContext} to render {@link Query} objects and
* {@link QueryPart}s
* - by a {@link BindContext} to bind values to {@link Query} objects and
* {@link QueryPart}s
* - by a {@link Query} or {@link Routine} object to execute themselves
*
*
* The simplest usage of a Configuration
instance is to use it
* exactly for a single Query
execution, disposing it immediately.
* This will make it very simple to implement thread-safe behaviour.
*
* At the same time, jOOQ does not require Configuration
instances
* to be that short-lived. Thread-safety will then be delegated to component
* objects, such as the {@link ConnectionProvider}, the {@link ExecuteListener}
* list, etc.
*
* A Configuration
is composed of types composing its state and of
* SPIs:
*
Types composing its state:
*
* - {@link #dialect()}: The {@link SQLDialect} that defines the underlying
* database's behaviour when generating SQL syntax, or binding variables, or
* when executing the query
* - {@link #settings()}: The {@link Settings} that define general jOOQ
* behaviour
* - {@link #data()}: A {@link Map} containing user-defined data for the
* {@link Scope} of this configuration.
*
* SPIs:
*
* - {@link #connectionProvider()}: The {@link ConnectionProvider} that
* defines the semantics of {@link ConnectionProvider#acquire()} and
* {@link ConnectionProvider#release(Connection)} for all queries executed in
* the context of this
Configuration
.
*
* jOOQ-provided default implementations include:
*
* - {@link DefaultConnectionProvider}: a non-thread-safe implementation that
* wraps a single JDBC {@link Connection}. Ideal for batch processing.
* - {@link DataSourceConnectionProvider}: a possibly thread-safe
* implementation that wraps a JDBC {@link DataSource}. Ideal for use with
* connection pools, Java EE, or Spring.
*
*
* - {@link #transactionProvider()}: The {@link TransactionProvider} that
* defines and implements the behaviour of the
* {@link DSLContext#transaction(TransactionalRunnable)} and
* {@link DSLContext#transactionResult(TransactionalCallable)} methods.
*
* jOOQ-provided default implementations include:
*
* - {@link DefaultTransactionProvider}: an implementation backed by JDBC
* directly, via {@link Connection#commit()}, {@link Connection#rollback()}, and
* {@link Connection#rollback(Savepoint)} for nested transactions.
*
*
* - {@link #recordMapperProvider()}: The {@link RecordMapperProvider} that
* defines and implements the behaviour of {@link Record#into(Class)},
* {@link ResultQuery#fetchInto(Class)}, {@link Cursor#fetchInto(Class)}, and
* various related methods.
*
* jOOQ-provided default implementations include:
*
* - {@link DefaultRecordMapperProvider}: an implementation delegating to the
* {@link DefaultRecordMapper}, which implements the most common mapping
* use-cases.
*
*
* - {@link #recordListenerProviders()}: A set of
* {@link RecordListenerProvider} that implement {@link Record} fetching and
* storing lifecycle management, specifically for use with
* {@link UpdatableRecord}.
*
* jOOQ does not provide any implementations.
* - {@link #executeListenerProviders()}: A set of
* {@link ExecuteListenerProvider} that implement {@link Query} execution
* lifecycle management.
*
* jOOQ-provided example implementations include:
*
* - {@link LoggerListener}: generating default query execution log output
* - {@link StopWatchListener}: generating default query execution speed log
* output
*
* - {@link #visitListenerProviders()}: A set of {@link VisitListenerProvider}
* that implement {@link Query} rendering and variable binding lifecycle
* management, and that are allowed to implement query transformation - e.g. to
* implement row-level security, or multi-tenancy.
*
* jOOQ does not provide any implementations.
*
*
*
* @author Lukas Eder
*/
public interface Configuration extends Serializable {
// -------------------------------------------------------------------------
// Custom data
// -------------------------------------------------------------------------
/**
* Get all custom data from this Configuration
.
*
* This is custom data that was previously set to the configuration using
* {@link #data(Object, Object)}. Use custom data if you want to pass data
* to your custom {@link QueryPart} or {@link ExecuteListener} objects to be
* made available at render, bind, execution, fetch time.
*
* See {@link ExecuteListener} for more details.
*
* @return The custom data. This is never null
* @see ExecuteListener
*/
Map