当前位置: 首页>>代码示例>>Java>>正文


Java UserTransaction.getStatus方法代码示例

本文整理汇总了Java中javax.transaction.UserTransaction.getStatus方法的典型用法代码示例。如果您正苦于以下问题:Java UserTransaction.getStatus方法的具体用法?Java UserTransaction.getStatus怎么用?Java UserTransaction.getStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.transaction.UserTransaction的用法示例。


在下文中一共展示了UserTransaction.getStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveUserTransaction

import javax.transaction.UserTransaction; //导入方法依赖的package包/类
/**
 * If the given UserTransaction is not null, it is committed/rolledback,
 * and then returned to the UserTransactionHelper.
 */
private void resolveUserTransaction(UserTransaction userTransaction) {
    if (userTransaction != null) {
        try {
            if (userTransaction.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
                userTransaction.rollback();
            } else {
                userTransaction.commit();
            } 
        } catch (Throwable t) {
            getLog().error("Failed to resolve UserTransaction for plugin: " + getName(), t);
        } finally {
            UserTransactionHelper.returnUserTransaction(userTransaction);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:SchedulerPluginWithUserTransactionSupport.java

示例2: getStatus

import javax.transaction.UserTransaction; //导入方法依赖的package包/类
/**
 * Extract the status code from a {@link UserTransaction}
 *
 * @param userTransaction The {@link UserTransaction} from which to extract the status.
 *
 * @return The transaction status
 *
 * @throws TransactionException If the {@link UserTransaction} reports the status as unknown
 */
public static int getStatus(UserTransaction userTransaction) {
	try {
		final int status = userTransaction.getStatus();
		if ( status == Status.STATUS_UNKNOWN ) {
			throw new TransactionException( "UserTransaction reported transaction status as unknown" );
		}
		return status;
	}
	catch ( SystemException se ) {
		throw new TransactionException( "Could not determine transaction status", se );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:JtaStatusHelper.java

示例3: endTransaction

import javax.transaction.UserTransaction; //导入方法依赖的package包/类
/**
     * End an active transaction
     * 
     * @param sess SrvSession
     * @param tx Object
     */
    public void endTransaction(SrvSession sess, Object tx) {

      // Check that the transaction object is valid
      
      if ( tx == null)
        return;
      
      // Get the filesystem transaction
      
      FilesysTransaction filesysTx = (FilesysTransaction) tx;

      // Check if there is an active transaction
      
      if ( filesysTx != null && filesysTx.hasTransaction())
      {
        // Get the active transaction
        
          UserTransaction ftx = filesysTx.getTransaction();
          
          try
          {
              // Commit or rollback the transaction
              
              if ( ftx.getStatus() == Status.STATUS_MARKED_ROLLBACK ||
            	   ftx.getStatus() == Status.STATUS_ROLLEDBACK ||
            	   ftx.getStatus() == Status.STATUS_ROLLING_BACK)
              {
                  // Transaction is marked for rollback
                  
                  ftx.rollback();
                  
                  // DEBUG
                  
                  if ( logger.isDebugEnabled())
                      logger.debug("End transaction (rollback)");
              }
              else
              {
            	  // Commit the transaction
                  
                  ftx.commit();
                  
                  // DEBUG
                  
                  if ( logger.isDebugEnabled())
                      logger.debug("End transaction (commit)");
              }
          }
          catch ( Exception ex)
          {
        	  if ( logger.isDebugEnabled())
        		  logger.debug("Failed to end transaction, " + ex.getMessage());
//              throw new AlfrescoRuntimeException("Failed to end transaction", ex);
          }
          finally
          {
              // Clear the current transaction
              
              sess.clearTransaction();
          }
        }
    }
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:69,代码来源:AlfrescoTxDiskDriver.java

示例4: testTransactionalCacheDisableSharedCaches

import javax.transaction.UserTransaction; //导入方法依赖的package包/类
public void testTransactionalCacheDisableSharedCaches() throws Throwable
{
    // add item to global cache
    TransactionalCache.putSharedCacheValue(backingCache, NEW_GLOBAL_ONE, NEW_GLOBAL_ONE, null);
    TransactionalCache.putSharedCacheValue(backingCache, NEW_GLOBAL_TWO, NEW_GLOBAL_TWO, null);
    TransactionalCache.putSharedCacheValue(backingCache, NEW_GLOBAL_THREE, NEW_GLOBAL_THREE, null);
    
    TransactionService transactionService = serviceRegistry.getTransactionService();
    UserTransaction txn = transactionService.getUserTransaction();
    try
    {
        // begin a transaction
        txn.begin();
        
        // Go directly past ALL shared caches
        transactionalCache.setDisableSharedCacheReadForTransaction(true);
        
        // Try to get results in shared caches
        assertNull("Read of mutable shared cache MUST NOT use backing cache", transactionalCache.get(NEW_GLOBAL_ONE));
        assertNull("Value should not be in any cache", transactionalCache.get(UPDATE_TXN_THREE));
        
        // Update the transactional caches
        transactionalCache.put(NEW_GLOBAL_TWO, "An update");
        transactionalCache.put(UPDATE_TXN_THREE, UPDATE_TXN_THREE);
        
        // Try to get results in shared caches
        assertNull("Read of mutable shared cache MUST NOT use backing cache", transactionalCache.get(NEW_GLOBAL_ONE));
        assertEquals("Value should be in transactional cache", "An update", transactionalCache.get(NEW_GLOBAL_TWO));
        assertEquals("Value should be in transactional cache", UPDATE_TXN_THREE, transactionalCache.get(UPDATE_TXN_THREE));
        
        txn.commit();
        
        // Now check that values were not written through for any caches
        assertEquals("Out-of-txn read must return shared value", NEW_GLOBAL_ONE, transactionalCache.get(NEW_GLOBAL_ONE));
        assertNull("Value should be removed from shared cache", transactionalCache.get(NEW_GLOBAL_TWO));
        assertEquals("New values must be written to shared cache", UPDATE_TXN_THREE, transactionalCache.get(UPDATE_TXN_THREE));
    }
    catch (Throwable e)
    {
        if (txn.getStatus() == Status.STATUS_ACTIVE)
        {
            txn.rollback();
        }
        throw e;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:47,代码来源:CacheTest.java


注:本文中的javax.transaction.UserTransaction.getStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。