Class 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
    • 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 interface javax.transaction.Synchronization
      • afterCompletion

        public void afterCompletion​(int status)
        Specified by:
        afterCompletion in interface javax.transaction.Synchronization
      • translateStatus

        public static java.lang.String translateStatus​(int status)
        Translate the transaction Status value to a meaningful name
        Parameters:
        status - a value from Status
        Returns:
        a string describing the transaction status