public abstract class ConnectionFactoryUtils extends Object
ConnectionFactory
.
Used internally by Spring's DatabaseClient
, Spring's R2DBC operation
objects. Can also be used directly in application code.
Modifier and Type | Field and Description |
---|---|
static int |
CONNECTION_SYNCHRONIZATION_ORDER
Order value for ReactiveTransactionSynchronization objects that clean up R2DBC Connections.
|
Modifier and Type | Method and Description |
---|---|
static reactor.core.publisher.Mono<Void> |
closeConnection(io.r2dbc.spi.Connection connection,
io.r2dbc.spi.ConnectionFactory connectionFactory)
Close the
Connection . |
static reactor.core.publisher.Mono<ReactiveTransactionSynchronization> |
currentActiveReactiveTransactionSynchronization()
Obtain the currently active
ReactiveTransactionSynchronization from the current subscriber
Context . |
static reactor.core.publisher.Mono<io.r2dbc.spi.ConnectionFactory> |
currentConnectionFactory(io.r2dbc.spi.ConnectionFactory connectionFactory)
Obtain the
ConnectionFactory from the current subscriber Context . |
static reactor.core.publisher.Mono<ReactiveTransactionSynchronization> |
currentReactiveTransactionSynchronization()
Obtain the currently
ReactiveTransactionSynchronization from the current subscriber
Context . |
static reactor.core.publisher.Mono<Void> |
doCloseConnection(io.r2dbc.spi.Connection connection,
io.r2dbc.spi.ConnectionFactory connectionFactory)
Close the
Connection , unless a SmartConnectionFactory doesn't want us to. |
static reactor.core.publisher.Mono<reactor.util.function.Tuple2<io.r2dbc.spi.Connection,io.r2dbc.spi.ConnectionFactory>> |
doGetConnection(io.r2dbc.spi.ConnectionFactory connectionFactory)
Actually obtain a R2DBC Connection from the given
ConnectionFactory . |
static reactor.core.publisher.Mono<Void> |
doReleaseConnection(io.r2dbc.spi.Connection con,
io.r2dbc.spi.ConnectionFactory connectionFactory)
Actually close the given
Connection , obtained from the given ConnectionFactory . |
static reactor.core.publisher.Mono<reactor.util.function.Tuple2<io.r2dbc.spi.Connection,io.r2dbc.spi.ConnectionFactory>> |
getConnection(io.r2dbc.spi.ConnectionFactory connectionFactory)
Obtain a
Connection from the given ConnectionFactory . |
static io.r2dbc.spi.Connection |
getTargetConnection(io.r2dbc.spi.Connection con)
Return the innermost target
Connection of the given Connection . |
static reactor.core.publisher.Mono<Void> |
releaseConnection(io.r2dbc.spi.Connection con,
io.r2dbc.spi.ConnectionFactory connectionFactory)
Close the given
Connection , obtained from the given ConnectionFactory , if it is not
managed externally (that is, not bound to the thread). |
public static final int CONNECTION_SYNCHRONIZATION_ORDER
public static reactor.core.publisher.Mono<reactor.util.function.Tuple2<io.r2dbc.spi.Connection,io.r2dbc.spi.ConnectionFactory>> getConnection(io.r2dbc.spi.ConnectionFactory connectionFactory)
Connection
from the given ConnectionFactory
. Translates
exceptions into the Spring hierarchy of unchecked generic data access exceptions, simplifying calling code and
making any exception that is thrown more meaningful.
Is aware of a corresponding Connection bound to the current Context
. Will bind a
Connection to the Context
if transaction synchronization is active.
connectionFactory
- the ConnectionFactory
to obtain Connections fromConnectionFactory
.DataAccessResourceFailureException
- if the attempt to get a Connection
failedreleaseConnection(io.r2dbc.spi.Connection, io.r2dbc.spi.ConnectionFactory)
public static reactor.core.publisher.Mono<reactor.util.function.Tuple2<io.r2dbc.spi.Connection,io.r2dbc.spi.ConnectionFactory>> doGetConnection(io.r2dbc.spi.ConnectionFactory connectionFactory)
ConnectionFactory
. Same as getConnection(io.r2dbc.spi.ConnectionFactory)
, but
preserving the original exceptions.
Is aware of a corresponding Connection bound to the current Context
. Will bind a
Connection to the Context
if transaction synchronization is active.
connectionFactory
- the ConnectionFactory
to obtain Connections from.Connection
from the given ConnectionFactory
.public static reactor.core.publisher.Mono<Void> releaseConnection(@Nullable io.r2dbc.spi.Connection con, @Nullable io.r2dbc.spi.ConnectionFactory connectionFactory)
Connection
, obtained from the given ConnectionFactory
, if it is not
managed externally (that is, not bound to the thread).con
- the Connection
to close if necessary.connectionFactory
- the ConnectionFactory
that the Connection was obtained from (may be
null).getConnection(io.r2dbc.spi.ConnectionFactory)
public static reactor.core.publisher.Mono<Void> doReleaseConnection(@Nullable io.r2dbc.spi.Connection con, @Nullable io.r2dbc.spi.ConnectionFactory connectionFactory)
Connection
, obtained from the given ConnectionFactory
. Same
as releaseConnection(io.r2dbc.spi.Connection, io.r2dbc.spi.ConnectionFactory)
, but preserving the original exception.con
- the Connection
to close if necessary.connectionFactory
- the ConnectionFactory
that the Connection was obtained from (may be
null).doGetConnection(io.r2dbc.spi.ConnectionFactory)
public static reactor.core.publisher.Mono<Void> closeConnection(io.r2dbc.spi.Connection connection, io.r2dbc.spi.ConnectionFactory connectionFactory)
Connection
. Translates exceptions into the Spring hierarchy of unchecked generic
data access exceptions, simplifying calling code and making any exception that is thrown more meaningful.connectionFactory
- the ConnectionFactory
to obtain Connections fromConnectionFactory
.DataAccessResourceFailureException
- if the attempt to get a Connection
failedpublic static reactor.core.publisher.Mono<Void> doCloseConnection(io.r2dbc.spi.Connection connection, @Nullable io.r2dbc.spi.ConnectionFactory connectionFactory)
Connection
, unless a SmartConnectionFactory
doesn't want us to.connection
- the Connection
to close if necessary.connectionFactory
- the ConnectionFactory
that the Connection was obtained from.Connection.close()
,
SmartConnectionFactory.shouldClose(Connection)
public static reactor.core.publisher.Mono<ReactiveTransactionSynchronization> currentReactiveTransactionSynchronization()
ReactiveTransactionSynchronization
from the current subscriber
Context
.NoTransactionException
- if no active ReactiveTransactionSynchronization
is associated with the
current subscription.Mono.subscriberContext()
,
ReactiveTransactionSynchronization
public static reactor.core.publisher.Mono<ReactiveTransactionSynchronization> currentActiveReactiveTransactionSynchronization()
ReactiveTransactionSynchronization
from the current subscriber
Context
.NoTransactionException
- if no active ReactiveTransactionSynchronization
is associated with the
current subscription.Mono.subscriberContext()
,
ReactiveTransactionSynchronization
public static reactor.core.publisher.Mono<io.r2dbc.spi.ConnectionFactory> currentConnectionFactory(io.r2dbc.spi.ConnectionFactory connectionFactory)
ConnectionFactory
from the current subscriber Context
.Mono.subscriberContext()
,
ReactiveTransactionSynchronization
,
TransactionResources
public static io.r2dbc.spi.Connection getTargetConnection(io.r2dbc.spi.Connection con)
Connection
of the given Connection
. If the given Connection
is
a proxy, it will be unwrapped until a non-proxy Connection
is found. Otherwise, the passed-in Connection
will be returned as-is.con
- the Connection
proxy to unwrapConnectionProxy.getTargetConnection()
Copyright © 2018–2019 Pivotal Software, Inc.. All rights reserved.