SingleConnectionFactory
instead.@Deprecated public class SingleConnectionConnectionFactory extends DelegatingConnectionFactory implements SmartConnectionFactory, DisposableBean
SmartConnectionFactory
that wraps a single R2DBC Connection which is not closed after use.
Obviously, this is not multi-threading capable.
Note that at shutdown, someone should close the underlying Connection via the close()
method. Client code
will never call close on the Connection handle if it is SmartDataSource-aware (e.g. uses
ConnectionFactoryUtils.releaseConnection(io.r2dbc.spi.Connection, ConnectionFactory)
).
If client code will call Connection.close()
in the assumption of a pooled Connection, like when using
persistence tools, set "suppressClose" to "true". This will return a close-suppressing proxy instead of the physical
Connection.
This is primarily intended for testing. For example, it enables easy testing outside an application server, for code
that expects to work on a ConnectionFactory
.
create()
,
Connection.close()
,
ConnectionFactoryUtils.releaseConnection(io.r2dbc.spi.Connection, ConnectionFactory)
Constructor and Description |
---|
SingleConnectionConnectionFactory(Connection target,
ConnectionFactoryMetadata metadata,
boolean suppressClose)
Deprecated.
Create a new
SingleConnectionConnectionFactory with a given Connection and
ConnectionFactoryMetadata . |
SingleConnectionConnectionFactory(ConnectionFactory targetConnectionFactory)
Deprecated.
Constructor for bean-style configuration.
|
SingleConnectionConnectionFactory(String url,
boolean suppressClose)
Deprecated.
Create a new
SingleConnectionConnectionFactory using a R2DBC connection URL. |
Modifier and Type | Method and Description |
---|---|
reactor.core.publisher.Mono<? extends Connection> |
create()
Deprecated.
|
void |
destroy()
Deprecated.
Close the underlying
Connection . |
protected Boolean |
getAutoCommitValue()
Deprecated.
Return whether the returned
Connection 's "autoCommit" setting should be overridden. |
protected Connection |
getCloseSuppressingConnectionProxy(Connection target)
Deprecated.
Wrap the given
Connection with a proxy that delegates every method call to it but suppresses close calls. |
protected boolean |
isSuppressClose()
Deprecated.
Return whether the returned
Connection will be a close-suppressing proxy or the physical
Connection . |
protected reactor.core.publisher.Mono<Connection> |
prepareConnection(Connection connection)
Deprecated.
Prepare the
Connection before using it. |
reactor.core.publisher.Mono<Void> |
resetConnection()
Deprecated.
Reset the underlying shared Connection, to be reinitialized on next access.
|
void |
setAutoCommit(boolean autoCommit)
Deprecated.
Set whether the returned
Connection 's "autoCommit" setting should be overridden. |
void |
setSuppressClose(boolean suppressClose)
Deprecated.
Set whether the returned
Connection should be a close-suppressing proxy or the physical Connection . |
boolean |
shouldClose(Connection con)
Deprecated.
This is a single Connection: Do not close it when returning to the "pool".
|
getMetadata, getTargetConnectionFactory, obtainTargetConnectionFactory, unwrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMetadata
public SingleConnectionConnectionFactory(ConnectionFactory targetConnectionFactory)
public SingleConnectionConnectionFactory(String url, boolean suppressClose)
SingleConnectionConnectionFactory
using a R2DBC connection URL.url
- the R2DBC URL to use for accessing ConnectionFactory
discovery.suppressClose
- if the returned Connection
should be a close-suppressing proxy or the physical
Connection
.ConnectionFactories.get(String)
public SingleConnectionConnectionFactory(Connection target, ConnectionFactoryMetadata metadata, boolean suppressClose)
SingleConnectionConnectionFactory
with a given Connection
and
ConnectionFactoryMetadata
.target
- underlying target Connection
.metadata
- ConnectionFactory
metadata to be associated with this ConnectionFactory
.suppressClose
- if the Connection
should be wrapped with a Connection
that suppresses
close()
calls (to allow for normal close()
usage in applications that expect a pooled
Connection
but do not know our SmartConnectionFactory
interface).public void setSuppressClose(boolean suppressClose)
Connection
should be a close-suppressing proxy or the physical Connection
.protected boolean isSuppressClose()
Connection
will be a close-suppressing proxy or the physical
Connection
.public void setAutoCommit(boolean autoCommit)
Connection
's "autoCommit" setting should be overridden.@Nullable protected Boolean getAutoCommitValue()
Connection
's "autoCommit" setting should be overridden.null
if none to be appliedpublic reactor.core.publisher.Mono<? extends Connection> create()
create
in interface ConnectionFactory
create
in class DelegatingConnectionFactory
public boolean shouldClose(Connection con)
shouldClose
in interface SmartConnectionFactory
con
- the Connection
to check.Connection
should be closed.Connection.close()
public void destroy()
Connection
. The provider of this ConnectionFactory
needs to care for proper
shutdown.
As this bean implements DisposableBean
, a bean factory will automatically invoke this on destruction of its
cached singletons.
destroy
in interface DisposableBean
public reactor.core.publisher.Mono<Void> resetConnection()
protected reactor.core.publisher.Mono<Connection> prepareConnection(Connection connection)
Connection
before using it. Applies auto-commit
settings if
configured.connection
- the requested Connection
.Connection
.protected Connection getCloseSuppressingConnectionProxy(Connection target)
Connection
with a proxy that delegates every method call to it but suppresses close calls.target
- the original Connection
to wrap.Copyright © 2018–2022 Pivotal Software, Inc.. All rights reserved.