Class MCRTransactionableRunnable

java.lang.Object
org.mycore.util.concurrent.MCRTransactionableRunnable
All Implemented Interfaces:
Runnable, MCRDecorator<Runnable>

public class MCRTransactionableRunnable extends Object implements Runnable, MCRDecorator<Runnable>
Encapsulates a Runnable with a mycore session and a database transaction.
Author:
Matthias Eichner
  • Field Details

    • runnable

      protected Runnable runnable
  • Constructor Details

    • MCRTransactionableRunnable

      public MCRTransactionableRunnable(Runnable runnable)
      Creates a new Runnable encapsulating the run() method with a new MCRSession and a database transaction. Afterwards the transaction will be committed and the session will be released and closed.

      If you want to execute your runnable in the context of an already existing session use the MCRTransactionableRunnable(Runnable, MCRSession) constructor instead.

      Parameters:
      runnable - the runnable to execute within a session and transaction
    • MCRTransactionableRunnable

      public MCRTransactionableRunnable(Runnable runnable, MCRSession session)
      Creates a new Runnable encapsulating the run() method with a new a database transaction. The transaction will be created in the context of the given session. Afterwards the transaction will be committed and the session will be released (but not closed!).
      Parameters:
      runnable - the runnable to execute within a session and transaction
      session - the session to use
  • Method Details