Package io.helidon.integrations.jta.jdbc
Class JtaAdaptingDataSource
java.lang.Object
io.helidon.integrations.jdbc.AbstractCommonDataSource
io.helidon.integrations.jdbc.AbstractDataSource
io.helidon.integrations.jta.jdbc.JtaAdaptingDataSource
- All Implemented Interfaces:
Wrapper,CommonDataSource,DataSource
An
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
ConstructorsConstructorDescriptionJtaAdaptingDataSource(TransactionSupplier ts, TransactionSynchronizationRegistry tsr, boolean interposedSynchronizations, ExceptionConverter ec, DataSource ds, boolean immediateEnlistment) Creates a newJtaAdaptingDataSourcethat wraps the suppliedDataSourceand helps its connections participate in XA transactions.JtaAdaptingDataSource(TransactionSupplier ts, TransactionSynchronizationRegistry tsr, boolean interposedSynchronizations, ExceptionConverter ec, XADataSource xads, boolean immediateEnlistment, boolean closeXac) Deprecated. -
Method Summary
Methods inherited from class io.helidon.integrations.jdbc.AbstractDataSource
isWrapperFor, unwrapMethods inherited from class io.helidon.integrations.jdbc.AbstractCommonDataSource
getLoginTimeout, getLogWriter, getParentLogger, setLoginTimeout, setLogWriterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder, getParentLoggerMethods 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 newJtaAdaptingDataSourcethat wraps the suppliedDataSourceand 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 benulltsr- aTransactionSynchronizationRegistry; must not benullinterposedSynchronizations- whether anySynchronizations registered should be registered as interposed synchronizations; seeTransactionSynchronizationRegistry.registerInterposedSynchronization(jakarta.transaction.Synchronization)andTransaction.registerSynchronization(jakarta.transaction.Synchronization)ec- anExceptionConverter; may benullin which case a default implementation will be used insteadds- aDataSourcethat may not be XA-compliant; must not benull; normally supplied by a connection pool implementationimmediateEnlistment- whether attempts to enlist newConnections in a global transaction should be made immediately uponConnectionallocation- Throws:
NullPointerException- ifts,tsrordsisnull
-
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"XAConnections and to "return" them using theirclose()methods, a non-standard practice which is discouraged by the documentation ofPooledConnection(from whichXAConnectioninherits). For such connection pools,XAConnections 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 theXADataSourcehas the behavior described above; normally anXAConnectionshould not be used directly or closed by end-user code.Creates a newJtaAdaptingDataSourcethat adapts the suppliedXADataSourceand helpsConnections it indirectly supplies (by way of its associatedXAConnection) participate in XA transactions.- Parameters:
ts- aTransactionSupplier; must not benulltsr- aTransactionSynchronizationRegistry; must not benullinterposedSynchronizations- whether anySynchronizations registered should be registered as interposed synchronizations; seeTransactionSynchronizationRegistry.registerInterposedSynchronization(jakarta.transaction.Synchronization)andTransaction.registerSynchronization(jakarta.transaction.Synchronization)ec- anExceptionConverter; may benullin which case a default implementation will be used insteadxads- anXADataSourcesupplied by a connection pool implementation; must not benullimmediateEnlistment- whether attempts to enlist newConnections in a global transaction should be made immediately uponConnectionallocationcloseXac- whether or notXAConnections supplied by the suppliedXADataSourceshould be closed when theirConnections are closed (in a non-standard fashion)- Throws:
NullPointerException- ifts,tsrorxadsisnull
-
-
Method Details
-
getConnection
- Throws:
SQLException
-
getConnection
- Throws:
SQLException
-
XAConnections and to "return" them using theirclose()methods, a non-standard practice which is discouraged by the documentation ofPooledConnection(from whichXAConnectioninherits).