Class TransactionConnector<T,R>

java.lang.Object
org.frankframework.jta.TransactionConnector<T,R>
Type Parameters:
T - the transaction
R - a holder of suspended resources
All Implemented Interfaces:
AutoCloseable

public class TransactionConnector<T,R> extends Object implements AutoCloseable
This TransactionConnector suspends the transaction in the main thread, and resumes it in the child thread, for as long as it runs. The calling party (e.g. the party that is using a streaming transformer, or is using a provided OutputStream that may lead to a ContentHandlerOutputStream or JsonEventHandlerOutputStream) must make sure that no transaction related code (e.g. obtaining connections) is executed during the life of the TransactionConnector (between construction and calling of close()).
Author:
Gerrit van Brakel
  • Field Details

    • log

      protected org.apache.logging.log4j.Logger log
  • Method Details

    • getInstance

      public static <T, R> TransactionConnector<T,R> getInstance(IThreadConnectableTransactionManager<T,R> txManager, Object owner, String description)
      factory method, to be called from 'main' thread. When a transaction connector has been set up, new transactional resources can only be introduced after beginChildThread() has been called, not on the main thread anymore, because the transaction must be suspended there. TODO: This also means that objects further downstream might need to restore the transaction context before they can add new transactional resources. This is currently not implemented; therefore a FixedQuerySender providing an UpdateClob or UpdateBlob outputstream might behave incorrectly.
    • beginChildThread

      public void beginChildThread()
      resume transaction, that was saved in parent thread, in the child thread. After beginChildThread() has been called, new transactional resources cannot be enlisted in the parentThread, because the transaction context has been prepared to be transferred to the childThread.
    • endChildThread

      public void endChildThread()
      endThread() to be called from child thread in a finally clause
    • onEndChildThread

      public void onEndChildThread(List<ThrowingRunnable<?>> actions)
    • close

      public void close()
      close() to be called from parent thread, when child thread has ended.
      Specified by:
      close in interface AutoCloseable
    • toString

      public String toString()
      Overrides:
      toString in class Object