Class CacheTransactionSync
- java.lang.Object
-
- org.linuxforhealth.fhir.persistence.jdbc.impl.CacheTransactionSync
-
- All Implemented Interfaces:
javax.transaction.Synchronization
public class CacheTransactionSync extends java.lang.Object implements javax.transaction.Synchronization
Adapter to synchronize the thread-local caches with the shared caches when the transaction commits. It's important that we don't share ids created inside a transaction with other threads until the data is committed - those ids are not visible to other threads/transactions (the 'I' in ACID).
-
-
Constructor Summary
Constructors Constructor Description CacheTransactionSync(javax.transaction.TransactionSynchronizationRegistry txSyncRegistry, FHIRPersistenceJDBCCache cache, java.lang.String transactionDataKey, java.util.function.Consumer<java.lang.Boolean> afterTransactionHandler)
Public constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterCompletion(int status)
void
beforeCompletion()
static java.lang.String
translateStatus(int status)
Translate the transaction Status value to a meaningful name
-
-
-
Constructor Detail
-
CacheTransactionSync
public CacheTransactionSync(javax.transaction.TransactionSynchronizationRegistry txSyncRegistry, FHIRPersistenceJDBCCache cache, java.lang.String transactionDataKey, java.util.function.Consumer<java.lang.Boolean> afterTransactionHandler)
Public constructor- Parameters:
txSyncRegistry
-cache
-transactionDataKey
-afterTransactionHandler
- a handler called after the transaction completes (true == committed; false == rolled back)
-
-
Method Detail
-
beforeCompletion
public void beforeCompletion()
- Specified by:
beforeCompletion
in interfacejavax.transaction.Synchronization
-
afterCompletion
public void afterCompletion(int status)
- Specified by:
afterCompletion
in interfacejavax.transaction.Synchronization
-
translateStatus
public static java.lang.String translateStatus(int status)
Translate the transaction Status value to a meaningful name- Parameters:
status
- a value fromStatus
- Returns:
- a string describing the transaction status
-
-