本文整理匯總了Java中javax.transaction.TransactionManager.getStatus方法的典型用法代碼示例。如果您正苦於以下問題:Java TransactionManager.getStatus方法的具體用法?Java TransactionManager.getStatus怎麽用?Java TransactionManager.getStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.transaction.TransactionManager
的用法示例。
在下文中一共展示了TransactionManager.getStatus方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isTransactionActive
import javax.transaction.TransactionManager; //導入方法依賴的package包/類
/**
* Checks if the current transaction is active, rolled back or marked for
* rollback.
*
* @return {@code true} if the current transaction is active, rolled back or
* marked for rollback, {@code false} otherwise.
* @throws SystemException thrown if the transaction manager encounters an
* unexpected error condition
*/
private boolean isTransactionActive(TransactionManager transactionManager) throws SystemException {
switch (transactionManager.getStatus()) {
case Status.STATUS_ACTIVE:
case Status.STATUS_MARKED_ROLLBACK:
case Status.STATUS_ROLLEDBACK:
return true;
default:
return false;
}
}
示例2: registerTransactionSynchronization
import javax.transaction.TransactionManager; //導入方法依賴的package包/類
/**
* Register a transaction synchronization for closing the given LobCreator,
* preferring Spring transaction synchronization and falling back to
* plain JTA transaction synchronization.
* @param lobCreator the LobCreator to close after transaction completion
* @param jtaTransactionManager the JTA TransactionManager to fall back to
* when no Spring transaction synchronization is active (may be {@code null})
* @throws IllegalStateException if there is neither active Spring transaction
* synchronization nor active JTA transaction synchronization
*/
public static void registerTransactionSynchronization(
LobCreator lobCreator, TransactionManager jtaTransactionManager) throws IllegalStateException {
if (TransactionSynchronizationManager.isSynchronizationActive()) {
logger.debug("Registering Spring transaction synchronization for LobCreator");
TransactionSynchronizationManager.registerSynchronization(
new SpringLobCreatorSynchronization(lobCreator));
}
else {
if (jtaTransactionManager != null) {
try {
int jtaStatus = jtaTransactionManager.getStatus();
if (jtaStatus == Status.STATUS_ACTIVE || jtaStatus == Status.STATUS_MARKED_ROLLBACK) {
logger.debug("Registering JTA transaction synchronization for LobCreator");
jtaTransactionManager.getTransaction().registerSynchronization(
new JtaLobCreatorSynchronization(lobCreator));
return;
}
}
catch (Throwable ex) {
throw new TransactionSystemException(
"Could not register synchronization with JTA TransactionManager", ex);
}
}
throw new IllegalStateException("Active Spring transaction synchronization or active " +
"JTA transaction with specified [javax.transaction.TransactionManager] required");
}
}
示例3: getStatus
import javax.transaction.TransactionManager; //導入方法依賴的package包/類
/**
* Extract the status code from the current {@link javax.transaction.Transaction} associated with the
* given {@link TransactionManager}
*
* @param transactionManager The {@link TransactionManager} from which to extract the status.
*
* @return The transaction status
*
* @throws TransactionException If the {@link TransactionManager} reports the status as unknown
*/
public static int getStatus(TransactionManager transactionManager) {
try {
final int status = transactionManager.getStatus();
if ( status == Status.STATUS_UNKNOWN ) {
throw new TransactionException( "TransactionManager reported transaction status as unknwon" );
}
return status;
}
catch ( SystemException se ) {
throw new TransactionException( "Could not determine transaction status", se );
}
}