Interface ITransactionService
- Author:
- POLARION SOFTWARE
-
Method Summary
Modifier and TypeMethodDescriptionvoidbeginTx()This is a shortcut forgetUserTransaction().begin(), that wraps all checked exceptions thrown by theUserTransaction.begin()into uncheckedRuntimeException, so that the users don't have to handle them (since they typically cannot be handled anyway).booleanShortcut method to determine, whether a transaction COULD be open.voidcommitTx()This is a shortcut forgetUserTransaction().commit(), that wraps all checked exceptions thrown byUserTransaction.commit()into genericExceptions.default voidendTx(boolean rollback) Shortcut fordefault TransactionExecuterexecute()Returns a new instance of an executor that simplifies the transaction execution.javax.transaction.TransactionDeprecated.since 3.24.4.javax.transaction.UserTransactionDeprecated.since 3.24.4.voidvoidThis is a shortcut forgetUserTransaction().rollback(), that wraps all exceptions thrown by theUserTransaction.rollback()into uncheckedRuntimeException, so that the clients don't have to handle them (since they typically cannot be handled anyway).voidsetRollbackOnly(String msg) CallsgetTransaction().setRollbackOnly()and also registers a message for a future exception that will be thrown bycommitTx()if somebody attempts to commit this transaction.voidCallsgetTransaction().setRollbackOnly()and also registers a throwable cause for a future exception that will be thrown bycommitTx()if somebody attempts to commit this transaction.booleantxExists()Shortcut method to determine, whether a transaction is open.
-
Method Details
-
getUserTransaction
Deprecated.since 3.24.4. Please consider to use transaction service methods to manage transaction.- Returns:
- user 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:
trueif there is an open transaction.
-
canBeginTx
boolean canBeginTx()Shortcut method to determine, whether a transaction COULD be open.Unlike
txExists(), this will returntrueif and only ifbeginTx()is permitted = there is no transaction (either active or after completion).- Returns:
trueif the transaction can be opened.
-
beginTx
void beginTx()This is a shortcut forgetUserTransaction().begin(), that wraps all checked exceptions thrown by theUserTransaction.begin()into uncheckedRuntimeException, so that the users don't have to handle them (since they typically cannot be handled anyway). -
commitTx
This is a shortcut forgetUserTransaction().commit(), that wraps all checked exceptions thrown byUserTransaction.commit()into genericExceptions.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 forgetUserTransaction().rollback(), that wraps all exceptions thrown by theUserTransaction.rollback()into uncheckedRuntimeException, so that the clients don't have to handle them (since they typically cannot be handled anyway).- Parameters:
transaction- - transaction to be committed
-
endTx
Shortcut forif(rollback) { rollbackTx(); } else { commitTx(); }- Parameters:
rollback- when true transaction will rollback, otherwise committed- Throws:
Exception
-
setRollbackOnly
CallsgetTransaction().setRollbackOnly()and also registers a message for a future exception that will be thrown bycommitTx()if somebody attempts to commit this transaction.- Parameters:
msg-- Since:
- 3.3.1
-
setRollbackOnly
CallsgetTransaction().setRollbackOnly()and also registers a throwable cause for a future exception that will be thrown bycommitTx()if somebody attempts to commit this transaction.- Parameters:
th-- Since:
- 3.5.3
-
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
-