Class JtaAdaptingDataSource
- All Implemented Interfaces:
Wrapper
,CommonDataSource
,DataSource
AbstractDataSource
that wraps another DataSource
that might not behave correctly in the presence
of JTA transaction management, such as one supplied by any of several freely and commercially available connection
pools, and that makes such a non-JTA-aware DataSource
behave as sensibly as possible in the presence of a
JTA-managed transaction.-
Constructor Summary
ConstructorDescriptionJtaAdaptingDataSource
(TransactionSupplier ts, TransactionSynchronizationRegistry tsr, boolean interposedSynchronizations, ExceptionConverter ec, DataSource ds, boolean immediateEnlistment) Creates a newJtaAdaptingDataSource
that wraps the suppliedDataSource
and helps its connections participate in XA transactions.JtaAdaptingDataSource
(TransactionSupplier ts, TransactionSynchronizationRegistry tsr, boolean interposedSynchronizations, ExceptionConverter ec, DataSource ds, boolean immediateEnlistment, boolean preemptiveEnlistmentChecks) Creates a newJtaAdaptingDataSource
that wraps the suppliedDataSource
and helps its connections participate in XA transactions.JtaAdaptingDataSource
(TransactionSupplier ts, TransactionSynchronizationRegistry tsr, boolean interposedSynchronizations, ExceptionConverter ec, XADataSource xads, boolean immediateEnlistment, boolean closeXac) Deprecated.JtaAdaptingDataSource
(TransactionSupplier ts, TransactionSynchronizationRegistry tsr, boolean interposedSynchronizations, ExceptionConverter ec, XADataSource xads, boolean immediateEnlistment, boolean preemptiveEnlistmentChecks, boolean closeXac) Deprecated.This constructor exists only to handle certain XA-aware connection pools that allow an end-user caller to "borrow"XAConnection
s and to "return" them using theirclose()
methods, a non-standard practice which is discouraged by the documentation ofPooledConnection
(from whichXAConnection
inherits). -
Method Summary
Methods inherited from class io.helidon.integrations.jdbc.AbstractDataSource
isWrapperFor, unwrap
Methods inherited from class io.helidon.integrations.jdbc.AbstractCommonDataSource
getLoginTimeout, getLogWriter, getParentLogger, setLoginTimeout, setLogWriter
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder, getParentLogger
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder, getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
-
Constructor Details
-
JtaAdaptingDataSource
public JtaAdaptingDataSource(TransactionSupplier ts, TransactionSynchronizationRegistry tsr, boolean interposedSynchronizations, ExceptionConverter ec, DataSource ds, boolean immediateEnlistment) Creates a newJtaAdaptingDataSource
that wraps the suppliedDataSource
and helps its connections participate in XA transactions.Behavior is left deliberately undefined if the supplied
DataSource
'sDataSource.getConnection()
orDataSource.getConnection(String, String)
methods are implemented to return or augment the return value of an invocation of theXAConnection#getConnection()
method. Less formally, and in general, this class is deliberately not designed to work with JDBC constructs that are already XA-aware.- Parameters:
ts
- aTransactionSupplier
; must not benull
tsr
- aTransactionSynchronizationRegistry
; must not benull
interposedSynchronizations
- whether anySynchronization
s registered should be registered as interposed synchronizations; seeTransactionSynchronizationRegistry.registerInterposedSynchronization(jakarta.transaction.Synchronization)
andTransaction.registerSynchronization(jakarta.transaction.Synchronization)
ec
- anExceptionConverter
; may benull
in which case a default implementation will be used insteadds
- aDataSource
that may not be XA-compliant; must not benull
; normally supplied by a connection pool implementationimmediateEnlistment
- whether attempts to enlist newConnection
s in a global transaction should be made immediately uponConnection
allocation- Throws:
NullPointerException
- ifts
,tsr
ords
isnull
- See Also:
-
JtaAdaptingDataSource
public JtaAdaptingDataSource(TransactionSupplier ts, TransactionSynchronizationRegistry tsr, boolean interposedSynchronizations, ExceptionConverter ec, DataSource ds, boolean immediateEnlistment, boolean preemptiveEnlistmentChecks) Creates a newJtaAdaptingDataSource
that wraps the suppliedDataSource
and helps its connections participate in XA transactions.Behavior is left deliberately undefined if the supplied
DataSource
'sDataSource.getConnection()
orDataSource.getConnection(String, String)
methods are implemented to return or augment the return value of an invocation of theXAConnection#getConnection()
method. Less formally, and in general, this class is deliberately not designed to work with JDBC constructs that are already XA-aware.- Parameters:
ts
- aTransactionSupplier
; must not benull
tsr
- aTransactionSynchronizationRegistry
; must not benull
interposedSynchronizations
- whether anySynchronization
s registered should be registered as interposed synchronizations; seeTransactionSynchronizationRegistry.registerInterposedSynchronization(jakarta.transaction.Synchronization)
andTransaction.registerSynchronization(jakarta.transaction.Synchronization)
ec
- anExceptionConverter
; may benull
in which case a default implementation will be used insteadds
- aDataSource
that may not be XA-compliant; must not benull
; normally supplied by a connection pool implementationimmediateEnlistment
- whether attempts to enlist newConnection
s in a global transaction should be made immediately uponConnection
allocationpreemptiveEnlistmentChecks
- whether early checks will be made to see if an enlistment attempt will succeed, or whether enlistment validation will be performed by the JTA implementation- Throws:
NullPointerException
- ifts
,tsr
ords
isnull
-
JtaAdaptingDataSource
@Deprecated(since="3.1.0") public JtaAdaptingDataSource(TransactionSupplier ts, TransactionSynchronizationRegistry tsr, boolean interposedSynchronizations, ExceptionConverter ec, XADataSource xads, boolean immediateEnlistment, boolean closeXac) Deprecated.This constructor exists only to handle certain XA-aware connection pools that allow an end-user caller to "borrow"XAConnection
s and to "return" them using theirclose()
methods, a non-standard practice which is discouraged by the documentation ofPooledConnection
(from whichXAConnection
inherits). For such connection pools,XAConnection
s that are "borrowed" must be returned in this manner to avoid leaks. This constructor implements this behavior. Before using it, you should make sure that the connection pool in question implementing or supplying theXADataSource
has the behavior described above; normally anXAConnection
should not be used directly or closed by end-user code.Creates a newJtaAdaptingDataSource
that adapts the suppliedXADataSource
and helpsConnection
s it indirectly supplies (by way of its associatedXAConnection
) participate in XA transactions.- Parameters:
ts
- aTransactionSupplier
; must not benull
tsr
- aTransactionSynchronizationRegistry
; must not benull
interposedSynchronizations
- whether anySynchronization
s registered should be registered as interposed synchronizations; seeTransactionSynchronizationRegistry.registerInterposedSynchronization(jakarta.transaction.Synchronization)
andTransaction.registerSynchronization(jakarta.transaction.Synchronization)
ec
- anExceptionConverter
; may benull
in which case a default implementation will be used insteadxads
- anXADataSource
supplied by a connection pool implementation; must not benull
immediateEnlistment
- whether attempts to enlist newConnection
s in a global transaction should be made immediately uponConnection
allocationcloseXac
- whether or notXAConnection
s supplied by the suppliedXADataSource
should be closed when theirConnection
s are closed (in a non-standard fashion)- Throws:
NullPointerException
- ifts
,tsr
orxads
isnull
-
JtaAdaptingDataSource
@Deprecated(since="3.1.0") public JtaAdaptingDataSource(TransactionSupplier ts, TransactionSynchronizationRegistry tsr, boolean interposedSynchronizations, ExceptionConverter ec, XADataSource xads, boolean immediateEnlistment, boolean preemptiveEnlistmentChecks, boolean closeXac) Deprecated.This constructor exists only to handle certain XA-aware connection pools that allow an end-user caller to "borrow"XAConnection
s and to "return" them using theirclose()
methods, a non-standard practice which is discouraged by the documentation ofPooledConnection
(from whichXAConnection
inherits). For such connection pools,XAConnection
s that are "borrowed" must be returned in this manner to avoid leaks. This constructor implements this behavior. Before using it, you should make sure that the connection pool in question implementing or supplying theXADataSource
has the behavior described above; normally anXAConnection
should not be used directly or closed by end-user code.Creates a newJtaAdaptingDataSource
that adapts the suppliedXADataSource
and helpsConnection
s it indirectly supplies (by way of its associatedXAConnection
) participate in XA transactions.- Parameters:
ts
- aTransactionSupplier
; must not benull
tsr
- aTransactionSynchronizationRegistry
; must not benull
interposedSynchronizations
- whether anySynchronization
s registered should be registered as interposed synchronizations; seeTransactionSynchronizationRegistry.registerInterposedSynchronization(jakarta.transaction.Synchronization)
andTransaction.registerSynchronization(jakarta.transaction.Synchronization)
ec
- anExceptionConverter
; may benull
in which case a default implementation will be used insteadxads
- anXADataSource
supplied by a connection pool implementation; must not benull
immediateEnlistment
- whether attempts to enlist newConnection
s in a global transaction should be made immediately uponConnection
allocationpreemptiveEnlistmentChecks
- whether early checks will be made to see if an enlistment attempt will succeed, or whether enlistment validation will be performed by the JTA implementationcloseXac
- whether or notXAConnection
s supplied by the suppliedXADataSource
should be closed when theirConnection
s are closed (in a non-standard fashion)- Throws:
NullPointerException
- ifts
,tsr
orxads
isnull
-
-
Method Details
-
getConnection
- Throws:
SQLException
-
getConnection
- Throws:
SQLException
-
XAConnection
s and to "return" them using theirclose()
methods, a non-standard practice which is discouraged by the documentation ofPooledConnection
(from whichXAConnection
inherits).