Interface ITransactionService


public interface ITransactionService
Author:
POLARION SOFTWARE
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This is a shortcut for getUserTransaction().begin(), that wraps all checked exceptions thrown by the UserTransaction.begin() into unchecked RuntimeException, so that the users don't have to handle them (since they typically cannot be handled anyway).
    boolean
    Shortcut method to determine, whether a transaction COULD be open.
    void
    This is a shortcut for getUserTransaction().commit(), that wraps all checked exceptions thrown by UserTransaction.commit() into generic Exceptions.
    default void
    endTx(boolean rollback)
    Shortcut for
    Returns a new instance of an executor that simplifies the transaction execution.
    javax.transaction.Transaction
    Deprecated.
    since 3.24.4.
    javax.transaction.UserTransaction
    Deprecated.
    since 3.24.4.
    void
    void
    This is a shortcut for getUserTransaction().rollback(), that wraps all exceptions thrown by the UserTransaction.rollback() into unchecked RuntimeException, so that the clients don't have to handle them (since they typically cannot be handled anyway).
    void
    Calls getTransaction().setRollbackOnly() and also registers a message for a future exception that will be thrown by commitTx() if somebody attempts to commit this transaction.
    void
    Calls getTransaction().setRollbackOnly() and also registers a throwable cause for a future exception that will be thrown by commitTx() if somebody attempts to commit this transaction.
    boolean
    Shortcut method to determine, whether a transaction is open.
  • Method Details

    • getUserTransaction

      @Deprecated javax.transaction.UserTransaction getUserTransaction()
      Deprecated.
      since 3.24.4. Please consider to use transaction service methods to manage transaction.
      Returns:
      user transaction
    • getTransaction

      @Deprecated javax.transaction.Transaction getTransaction()
      Deprecated.
      since 3.24.4. Please consider to use transaction service methods to manage transaction.
      Returns:
      user transaction
    • txExists

      boolean txExists()
      Shortcut method to determine, whether a transaction is open.
      Returns:
      true if there is an open transaction.
    • canBeginTx

      boolean canBeginTx()
      Shortcut method to determine, whether a transaction COULD be open.

      Unlike txExists(), this will return true if and only if beginTx() is permitted = there is no transaction (either active or after completion).

      Returns:
      true if the transaction can be opened.
    • beginTx

      void beginTx()
      This is a shortcut for getUserTransaction().begin(), that wraps all checked exceptions thrown by the UserTransaction.begin() into unchecked RuntimeException, so that the users don't have to handle them (since they typically cannot be handled anyway).
    • commitTx

      void commitTx() throws Exception
      This is a shortcut for getUserTransaction().commit(), that wraps all checked exceptions thrown by UserTransaction.commit() into generic Exceptions.

      This method intentionally declares a checked exception, since all clients should be prepared to handle commit failures appropriately.

      Throws:
      Exception
    • rollbackTx

      void rollbackTx()
      This is a shortcut for getUserTransaction().rollback(), that wraps all exceptions thrown by the UserTransaction.rollback() into unchecked RuntimeException, so that the clients don't have to handle them (since they typically cannot be handled anyway).
      Parameters:
      transaction - - transaction to be committed
    • endTx

      default void endTx(boolean rollback) throws Exception
      Shortcut for
              if(rollback) {
                      rollbackTx();
          } else {
                      commitTx();
           }
       
      Parameters:
      rollback - when true transaction will rollback, otherwise committed
      Throws:
      Exception
    • setRollbackOnly

      void setRollbackOnly(@NotNull String msg)
      Calls getTransaction().setRollbackOnly() and also registers a message for a future exception that will be thrown by commitTx() if somebody attempts to commit this transaction.
      Parameters:
      msg -
      Since:
      3.3.1
    • setRollbackOnly

      void setRollbackOnly(@NotNull Throwable th)
      Calls getTransaction().setRollbackOnly() and also registers a throwable cause for a future exception that will be thrown by commitTx() if somebody attempts to commit this transaction.
      Parameters:
      th -
      Since:
      3.5.3
    • execute

      @NotNull default TransactionExecuter execute()
      Returns a new instance of an executor that simplifies the transaction execution.
      Since:
      3.18.0
    • preventThreadKilling

      void preventThreadKilling()

      Used to prevent the killing of threads when called inside a custom extension.

      To prevent clogging up the server, a functionality was implemented in 18.2 that interrupts the processing of UI requests that take longer than a specified amount of time.

      Only read-only user requests are affected. Requests with write operations are not.

      All write operations performed via the Polarion API won't be interrupted, but if you have, or plan to implement, a custom extension that needs to write data to an external system, use this method to mark the current thread as non-interruptible prior to any write operation to prevent data inconsistency.

      For more information see

      Polarion ALM Platform Help --> Administrator's Guide --> System Maintenance --> Topics --> Prevent Long Running Transactions from Clogging up the Server

      Since:
      3.18.2