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


Java Status类代码示例

本文整理汇总了Java中javax.transaction.Status的典型用法代码示例。如果您正苦于以下问题:Java Status类的具体用法?Java Status怎么用?Java Status使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setRollbackOnly

import javax.transaction.Status; //导入依赖的package包/类
/**
 * Mark this index for roll back only. This action can not be reversed. It will reject all other work and only allow
 * roll back.
 */
public void setRollbackOnly()
{
    switch (getStatus().getStatus())
    {
    case Status.STATUS_COMMITTING:
        throw new IndexerException("Unable to mark for rollback: Transaction is committing");
    case Status.STATUS_COMMITTED:
        throw new IndexerException("Unable to mark for rollback: Transaction is committed");
    default:
        try
        {
            doSetRollbackOnly();
            setStatus(TransactionStatus.MARKED_ROLLBACK);
        }
        catch (IOException e)
        {
            throw new LuceneIndexException("Set rollback only failed ", e);
        }
        break;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:AbstractLuceneIndexerImpl.java

示例2: tearDown

import javax.transaction.Status; //导入依赖的package包/类
@Override
protected void tearDown() throws Exception
{
    deletePerson(USER_BOB);
    deletePerson(USER_TOM);
    deletePerson(USER_LISA);

    if (txn != null)
    {
        if (txn.getStatus() == Status.STATUS_MARKED_ROLLBACK)
        {
            txn.rollback();
        } else
        {
            txn.commit();
        }
        txn = null;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:SubscriptionServiceImplTest.java

示例3: tearDown

import javax.transaction.Status; //导入依赖的package包/类
@After
@Override
public void tearDown() throws Exception
{
    scheduler.getScheduler().unscheduleJob(scheduler.getTriggerName(), scheduler.getJobGroup());

    if (Status.STATUS_ROLLEDBACK != transaction.getStatus())
    {
        transaction.rollback();
    }

    freshNodes.clear();
    yesterdayNodes.clear();

    AuthenticationUtil.clearCurrentSecurityContext();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:CronScheduledQueryBasedTemplateActionDefinitionTest.java

示例4: test_RollbackExceptionHandling_rollbackafterthrown

import javax.transaction.Status; //导入依赖的package包/类
@Test
public void test_RollbackExceptionHandling_rollbackafterthrown()
        throws Exception {
    TransactionManager tm = mockTm();
    when(tm.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE, Status.STATUS_MARKED_ROLLBACK);
    doThrow(new RollbackException().initCause(new OptimisticLockException())).when(tm).commit();
    XAJpaTemplate tx = new XAJpaTemplate(emSupplier, tm, coordinator);
    try {
        tx.tx(TransactionType.Required, new EmConsumer() {
            public void accept(EntityManager em) {
                em.persist(new Object());
            }
        });
    } catch (RuntimeException e) {
        // this is ok
    }
    verify(tm, times(5)).getStatus();
    verify(tm, times(1)).commit();
    verify(tm, times(1)).rollback();
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:21,代码来源:XAJpaTemplateTest.java

示例5: testSimpleTxnWithRollback

import javax.transaction.Status; //导入依赖的package包/类
public void testSimpleTxnWithRollback() throws Exception
{
    testNoTxnStatus();
    try
    {
        txn.begin();

        throw new Exception("Blah");
    }
    catch (Throwable e)
    {
        txn.rollback();
    }
    assertEquals("Transaction status is not correct",
            Status.STATUS_ROLLEDBACK,
            txn.getStatus());
    assertEquals("Transaction manager not called correctly",
            txn.getStatus(),
            transactionManager.getStatus());
    checkNoStatusOnThread();
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:22,代码来源:SpringAwareUserTransactionTest.java

示例6: afterCompletion

import javax.transaction.Status; //导入依赖的package包/类
/**
 * JTA {@code afterCompletion} callback: invoked after commit/rollback.
 * <p>Needs to invoke the Spring synchronization's {@code beforeCompletion}
 * at this late stage in case of a rollback, since there is no corresponding
 * callback with JTA.
 * @see org.springframework.transaction.support.TransactionSynchronization#beforeCompletion
 * @see org.springframework.transaction.support.TransactionSynchronization#afterCompletion
 */
@Override
public void afterCompletion(int status) {
	if (!this.beforeCompletionCalled) {
		// beforeCompletion not called before (probably because of JTA rollback).
		// Perform the cleanup here.
		this.springSynchronization.beforeCompletion();
	}
	// Call afterCompletion with the appropriate status indication.
	switch (status) {
		case Status.STATUS_COMMITTED:
			this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_COMMITTED);
			break;
		case Status.STATUS_ROLLEDBACK:
			this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK);
			break;
		default:
			this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_UNKNOWN);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:SpringJtaSynchronizationAdapter.java

示例7: afterCompletion

import javax.transaction.Status; //导入依赖的package包/类
@Override
public void afterCompletion(int status) {
	switch (status) {
		case Status.STATUS_COMMITTED:
			try {
				TransactionSynchronizationUtils.invokeAfterCommit(this.synchronizations);
			}
			finally {
				TransactionSynchronizationUtils.invokeAfterCompletion(
						this.synchronizations, TransactionSynchronization.STATUS_COMMITTED);
			}
			break;
		case Status.STATUS_ROLLEDBACK:
			TransactionSynchronizationUtils.invokeAfterCompletion(
					this.synchronizations, TransactionSynchronization.STATUS_ROLLED_BACK);
			break;
		default:
			TransactionSynchronizationUtils.invokeAfterCompletion(
					this.synchronizations, TransactionSynchronization.STATUS_UNKNOWN);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:JtaAfterCompletionSynchronization.java

示例8: resolveUserTransaction

import javax.transaction.Status; //导入依赖的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

示例9: commit

import javax.transaction.Status; //导入依赖的package包/类
@Override
public void commit() throws HibernateException {
	if ( localStatus != LocalStatus.ACTIVE ) {
		throw new TransactionException( "Transaction not successfully started" );
	}

	LOG.debug( "committing" );

	beforeTransactionCommit();

	try {
		doCommit();
		localStatus = LocalStatus.COMMITTED;
		afterTransactionCompletion( Status.STATUS_COMMITTED );
	}
	catch (Exception e) {
		localStatus = LocalStatus.FAILED_COMMIT;
		afterTransactionCompletion( Status.STATUS_UNKNOWN );
		throw new TransactionException( "commit failed", e );
	}
	finally {
		invalidate();
		afterAfterCompletion();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:AbstractTransactionImpl.java

示例10: doBegin

import javax.transaction.Status; //导入依赖的package包/类
@Override
protected void doBegin() {
	LOG.debug( "begin" );

	userTransaction = locateUserTransaction();

	try {
		if ( userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION ) {
			userTransaction.begin();
			isInitiator = true;
			LOG.debug( "Began a new JTA transaction" );
		}
	}
	catch ( Exception e ) {
		throw new TransactionException( "JTA transaction begin failed", e );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:JtaTransaction.java

示例11: afterCompletion

import javax.transaction.Status; //导入依赖的package包/类
@Override
public void afterCompletion(int status) {
  try {
    TXCommitMessage txcm = this.firstProxy.afterCompletion(status, proxy.getTxId().getUniqId());
    if (status == Status.STATUS_COMMITTED) {
      if (txcm == null) {
        throw new TransactionInDoubtException(
            LocalizedStrings.ClientTXStateStub_COMMIT_FAILED_ON_SERVER.toLocalizedString());
      } else {
        afterServerCommit(txcm);
      }
    } else if (status == Status.STATUS_ROLLEDBACK) {
      if (this.internalAfterSendRollback != null) {
        this.internalAfterSendRollback.run();
      }
      this.firstProxy.getPool().releaseServerAffinity();
    }
  } finally {
    if (status == Status.STATUS_COMMITTED) {
      // rollback does not grab locks
      this.lockReq.releaseLocal();
    }
    this.firstProxy.getPool().releaseServerAffinity();
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:26,代码来源:ClientTXStateStub.java

示例12: restartTransaction

import javax.transaction.Status; //导入依赖的package包/类
/**
 * Commits or rolls back or does nothing with the current transaction and begins a new {@link UserTransaction}
 * 
 * @param transactionAction - one of the {@link TransactionActionEnum} values which specifies action to be done for the current transaction
 * @throws Exception
 */
private void restartTransaction(TransactionActionEnum transactionAction) throws Exception
{
    if ((null != transaction) && (Status.STATUS_ROLLEDBACK != transaction.getStatus()) && (Status.STATUS_COMMITTED != transaction.getStatus()))
    {
        if (TransactionActionEnum.ACTION_COMMIT == transactionAction)
        {
            transaction.commit();
        }
        else if (TransactionActionEnum.ACTION_ROLLBACK == transactionAction)
        {
            transaction.rollback();
        }
    }

    transaction = transactionService.getUserTransaction();
    transaction.begin();
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:GetMethodRegressionTest.java

示例13: buildErrorString

import javax.transaction.Status; //导入依赖的package包/类
/**
 * Utility method to report errors about invalid state.
 * 
 * @return - an error based on status
 */
private String buildErrorString()
{
    StringBuilder buffer = new StringBuilder(128);
    buffer.append("The indexer is unable to accept more work: ");
    switch (getStatus().getStatus())
    {
    case Status.STATUS_COMMITTED:
        buffer.append("The indexer has been committed");
        break;
    case Status.STATUS_COMMITTING:
        buffer.append("The indexer is committing");
        break;
    case Status.STATUS_MARKED_ROLLBACK:
        buffer.append("The indexer is marked for rollback");
        break;
    case Status.STATUS_PREPARED:
        buffer.append("The indexer is prepared to commit");
        break;
    case Status.STATUS_PREPARING:
        buffer.append("The indexer is preparing to commit");
        break;
    case Status.STATUS_ROLLEDBACK:
        buffer.append("The indexer has been rolled back");
        break;
    case Status.STATUS_ROLLING_BACK:
        buffer.append("The indexer is rolling back");
        break;
    case Status.STATUS_UNKNOWN:
        buffer.append("The indexer is in an unknown state");
        break;
    default:
        break;
    }
    return buffer.toString();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:41,代码来源:AbstractLuceneIndexerImpl.java

示例14: rollback

import javax.transaction.Status; //导入依赖的package包/类
/**
 * Roll back the index changes (this just means they are never added)
 * 
 * @throws LuceneIndexException
 */
public void rollback() throws LuceneIndexException
{
    switch (getStatus().getStatus())
    {

    case Status.STATUS_COMMITTED:
        throw new IndexerException("Unable to roll back: Transaction is committed ");
    case Status.STATUS_ROLLING_BACK:
        throw new IndexerException("Unable to roll back: Transaction is rolling back");
    case Status.STATUS_ROLLEDBACK:
        throw new IndexerException("Unable to roll back: Transaction is already rolled back");
    case Status.STATUS_COMMITTING:
        // Can roll back during commit
    default:
        try
        {
            setStatus(TransactionStatus.ROLLINGBACK);
            doRollBack();
            setStatus(TransactionStatus.ROLLEDBACK);
        }
        catch (IOException e)
        {
            throw new LuceneIndexException("rollback failed ", e);
        }
        break;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:33,代码来源:AbstractLuceneIndexerImpl.java

示例15: tearDown

import javax.transaction.Status; //导入依赖的package包/类
protected void tearDown() throws Exception
{

    if ((testTX.getStatus() == Status.STATUS_ACTIVE) || (testTX.getStatus() == Status.STATUS_MARKED_ROLLBACK))
    {
        testTX.rollback();
    }
    AuthenticationUtil.clearCurrentSecurityContext();
    super.tearDown();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:AclDaoComponentTest.java


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