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


Java Status.STATUS_COMMITTED属性代码示例

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


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

示例1: setRollbackOnly

/**
 * 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,代码行数:25,代码来源:AbstractLuceneIndexerImpl.java

示例2: restartTransaction

/**
 * 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,代码行数:23,代码来源:GetMethodRegressionTest.java

示例3: afterCompletion

/**
 * 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,代码行数:27,代码来源:SpringJtaSynchronizationAdapter.java

示例4: afterCompletion

@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,代码行数:21,代码来源:JtaAfterCompletionSynchronization.java

示例5: afterCompletion

@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,代码行数:25,代码来源:ClientTXStateStub.java

示例6: buildErrorString

/**
 * 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,代码行数:40,代码来源:AbstractLuceneIndexerImpl.java

示例7: rollback

/**
 * 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,代码行数:32,代码来源:AbstractLuceneIndexerImpl.java

示例8: tearDown

public void tearDown() throws Exception
{
    try
    {
        if (txn.getStatus() != Status.STATUS_ROLLEDBACK && txn.getStatus() != Status.STATUS_COMMITTED)
        {
            txn.rollback();
        }
    }
    catch (Throwable e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:14,代码来源:LanguagesTest.java

示例9: tearDown

@After
public void tearDown() throws Exception
{
    try
    {
        if (txn.getStatus() != Status.STATUS_ROLLEDBACK && txn.getStatus() != Status.STATUS_COMMITTED)
        {
            txn.commit();
        }
    }
    catch (Throwable e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:15,代码来源:HiddenAspectTest.java

示例10: tearDown

@Override
protected void tearDown() throws Exception
{
    try
    {
        if (txn.getStatus() != Status.STATUS_ROLLEDBACK && txn.getStatus() != Status.STATUS_COMMITTED)
        {
            txn.rollback();
        }
    }
    catch (Throwable e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:15,代码来源:DocumentLinkServiceImplTest.java

示例11: tearDown

@After
public void tearDown() throws Exception
{
    AuthenticationUtil.clearCurrentSecurityContext();

    if ((null != transaction) && (Status.STATUS_COMMITTED != transaction.getStatus()) && (Status.STATUS_ROLLEDBACK != transaction.getStatus()))
    {
        transaction.rollback();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:10,代码来源:ProcessesImplTest.java

示例12: tearDown

@After
public void tearDown() throws Exception
{
    if ((null != transaction) && (Status.STATUS_ROLLEDBACK != transaction.getStatus()) && (Status.STATUS_COMMITTED != transaction.getStatus()))
    {
        transaction.rollback();
    }

    AuthenticationUtil.clearCurrentSecurityContext();
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:10,代码来源:GetMethodRegressionTest.java

示例13: registerSynchronization

@Override
public void registerSynchronization(final Synchronization synchronization)
		throws RollbackException, IllegalStateException,
		SystemException {

	final InvocationHandler ih = new InvocationHandler() {

		@Override
		public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
			if ( "afterCompletion".equals( method.getName() ) ) {
				int status = args[2].equals(Boolean.TRUE) ?
						Status.STATUS_COMMITTED :
						Status.STATUS_UNKNOWN;
				synchronization.afterCompletion(status);
			}
			else if ( "beforeCompletion".equals( method.getName() ) ) {
				synchronization.beforeCompletion();
			}
			else if ( "toString".equals( method.getName() ) ) {
				return synchronization.toString();
			}
			return null;
		}

	};

	final Object synchronizationCallback = Proxy.newProxyInstance(
			getClass().getClassLoader(),
			new Class[] {synchronizationCallbackClass},
			ih
	);

	try {
		registerSynchronizationMethod.invoke( extendedJTATransaction, synchronizationCallback );
	}
	catch (Exception e) {
		throw new HibernateException(e);
	}

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:WebSphereExtendedJtaPlatform.java

示例14: afterCompletion

public void afterCompletion(int status) {
  // System.err.println("start afterCompletion");
  final long opStart = CachePerfStats.getStatTime();
  switch (status) {
    case Status.STATUS_COMMITTED:
      // System.err.println("begin commit in afterCompletion");
      Assert.assertTrue(this.locks != null,
          "Gemfire Transaction afterCompletion called with illegal state.");
      try {
        this.proxy.getTxMgr().setTXState(null);
        commit();
      } catch (CommitConflictException error) {
        Assert.assertTrue(false, "Gemfire Transaction " + getTransactionId()
            + " afterCompletion failed.due to CommitConflictException: " + error);
      }

      this.proxy.getTxMgr().noteCommitSuccess(opStart, this.jtaLifeTime, this);
      this.locks = null;
      // System.err.println("end commit in afterCompletion");
      break;
    case Status.STATUS_ROLLEDBACK:
      this.jtaLifeTime = opStart - getBeginTime();
      this.proxy.getTxMgr().setTXState(null);
      rollback();
      this.proxy.getTxMgr().noteRollbackSuccess(opStart, this.jtaLifeTime, this);
      break;
    default:
      Assert.assertTrue(false, "Unknown JTA Synchronization status " + status);
  }
  // System.err.println("end afterCompletion");
}
 
开发者ID:ampool,项目名称:monarch,代码行数:31,代码来源:TXState.java

示例15: commit

/**
 * Commit this index
 * 
 * @throws LuceneIndexException
 */
public void commit() throws LuceneIndexException
{
    if (s_logger.isDebugEnabled())
    {
        s_logger.debug(Thread.currentThread().getName() + " Starting Commit");
    }
    switch (getStatus().getStatus())
    {
    case Status.STATUS_COMMITTING:
        throw new LuceneIndexException("Unable to commit: Transaction is committing");
    case Status.STATUS_COMMITTED:
        throw new LuceneIndexException("Unable to commit: Transaction is commited ");
    case Status.STATUS_ROLLING_BACK:
        throw new LuceneIndexException("Unable to commit: Transaction is rolling back");
    case Status.STATUS_ROLLEDBACK:
        throw new LuceneIndexException("Unable to commit: Transaction is aleady rolled back");
    case Status.STATUS_MARKED_ROLLBACK:
        throw new LuceneIndexException("Unable to commit: Transaction is marked for roll back");
    case Status.STATUS_PREPARING:
        throw new LuceneIndexException("Unable to commit: Transaction is preparing");
    case Status.STATUS_ACTIVE:
        // special case - commit from active
        prepare();
        // drop through to do the commit;
    default:
        if (getStatus().getStatus() != Status.STATUS_PREPARED)
        {
            throw new LuceneIndexException("Index must be prepared to commit");
        }
        try
        {
            setStatus(TransactionStatus.COMMITTING);
            if (isModified())
            {
                doCommit();
            }
            setStatus(TransactionStatus.COMMITTED);
        }
        catch (LuceneIndexException e)
        {
            // If anything goes wrong we try and do a roll back
            rollback();
            if (s_logger.isDebugEnabled())
            {
                s_logger.debug(Thread.currentThread().getName() + " Commit Failed", e);
            }
            throw new LuceneIndexException("Commit failed", e);
        }
        catch (Throwable t)
        {
            // If anything goes wrong we try and do a roll back
            rollback();
            if (s_logger.isDebugEnabled())
            {
                s_logger.debug(Thread.currentThread().getName() + " Commit Failed", t);
            }
            throw new LuceneIndexException("Commit failed", t);                
        }
        finally
        {
            if (s_logger.isDebugEnabled())
            {
                s_logger.debug(Thread.currentThread().getName() + " Ending Commit");
            }
            
            // Make sure we tidy up
            // deleteDelta();
        }
        break;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:76,代码来源:AbstractLuceneIndexerImpl.java


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