javax.transaction.Synchronization.beforeCompletion()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(80)

本文整理了Java中javax.transaction.Synchronization.beforeCompletion()方法的一些代码示例,展示了Synchronization.beforeCompletion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Synchronization.beforeCompletion()方法的具体详情如下:
包路径:javax.transaction.Synchronization
类名称:Synchronization
方法名:beforeCompletion

Synchronization.beforeCompletion介绍

[英]This method is invoked before the start of the commit process. The method invocation is done in the context of the transaction that is about to be committed.
[中]在提交过程开始之前调用此方法。方法调用是在即将提交的事务的上下文中完成的。

代码示例

代码示例来源:origin: apache/geode

/**
 * Iterate over the list of Synchronizations to complete all the methods to be performed before
 * completion
 */
boolean notifyBeforeCompletion() {
 Iterator iterator = syncList.iterator();
 boolean result = true;
 while (iterator.hasNext()) {
  sync = ((Synchronization) iterator.next());
  sync.beforeCompletion();
 }
 return result;
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public void notifySynchronizationsBeforeTransactionCompletion() {
  if ( synchronizations != null ) {
    for ( Synchronization synchronization : synchronizations ) {
      try {
        synchronization.beforeCompletion();
      }
      catch ( Throwable t ) {
        LOG.synchronizationFailed( synchronization, t );
      }
    }
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@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;
}

代码示例来源:origin: ehcache/ehcache3

private void fireBeforeCompletion() {
 for (Synchronization synchronization : synchronizations) {
  synchronization.beforeCompletion();
 }
}

代码示例来源:origin: wildfly/wildfly

@Override
public void beforeCompletion() {
  try {
    NamespaceContextSelector.pushCurrentSelector(selector);
    synchronization.beforeCompletion();
  } finally {
    NamespaceContextSelector.popCurrentSelector();
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public void notifySynchronizationsBeforeTransactionCompletion() {
  log.trace( "SynchronizationRegistryStandardImpl.notifySynchronizationsBeforeTransactionCompletion" );
  if ( synchronizations != null ) {
    for ( Synchronization synchronization : synchronizations ) {
      try {
        synchronization.beforeCompletion();
      }
      catch (Throwable t) {
        log.synchronizationFailed( synchronization, t );
        throw new LocalSynchronizationException(
            "Exception calling user Synchronization (beforeCompletion): " + synchronization.getClass().getName(),
            t
        );
      }
    }
  }
}

代码示例来源:origin: wildfly/wildfly

+ preJcaSync);
preJcaSync.beforeCompletion();
lastIndexProcessed = lastIndexProcessed + 1;
    + jcaSync);
jcaSync.beforeCompletion();
lastIndexProcessed = lastIndexProcessed + 1;

代码示例来源:origin: wildfly/wildfly

public void beforeCompletion() {
  try {
    if (importBacking()) try {
      sync.beforeCompletion();
    } finally {
      unimportBacking();
    } else {
      performConsumer(Synchronization::beforeCompletion, sync);
    }
  } catch (SystemException e) {
    throw new SynchronizationException(e);
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void jtaTransactionManagerWithExistingTransactionAndJtaSynchronization() throws Exception {
  UserTransaction ut = mock(UserTransaction.class);
  TransactionManager tm = mock(TransactionManager.class);
  MockJtaTransaction tx = new MockJtaTransaction();
  given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
  given(tm.getTransaction()).willReturn(tx);
  final TransactionSynchronization synch = mock(TransactionSynchronization.class);
  JtaTransactionManager ptm = newJtaTransactionManager(ut, tm);
  TransactionTemplate tt = new TransactionTemplate(ptm);
  assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
  tt.execute(new TransactionCallbackWithoutResult() {
    @Override
    protected void doInTransactionWithoutResult(TransactionStatus status) {
      assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
      TransactionSynchronizationManager.registerSynchronization(synch);
      status.setRollbackOnly();
    }
  });
  assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
  assertNotNull(tx.getSynchronization());
  tx.getSynchronization().beforeCompletion();
  tx.getSynchronization().afterCompletion(Status.STATUS_ROLLEDBACK);
  verify(ut).setRollbackOnly();
  verify(synch).beforeCompletion();
  verify(synch).afterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK);
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
   * BeforeCompletion wrapper. Translates WAS proprietary call to a
   * javax.transaction.Synchronization call.
   */
  public void beforeCompletion(int arg0, byte[] arg1) {
    if (_sync != null) {
      _sync.beforeCompletion();
    }
  }
}

代码示例来源:origin: org.jboss.cache/jbosscache-core

public void beforeCompletion()
{
 for (Synchronization sync : handlers)
 {
   sync.beforeCompletion();
 }
}

代码示例来源:origin: liuyangming/ByteJTA

public void beforeCompletion() {
  if (this.beforeRequired) {
    try {
      this.delegate.beforeCompletion();
    } catch (RuntimeException rex) {
      // ignore
    } finally {
      this.beforeRequired = false;
    }
  }
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

/**
   * BeforeCompletion wrapper. Translates WAS proprietary call to a
   * javax.transaction.Synchronization call.
   */
  public void beforeCompletion(int arg0, byte[] arg1) {
    if (_sync != null) {
      _sync.beforeCompletion();
    }
  }
}

代码示例来源:origin: org.apache.tomee/openejb-core

private void doBeforeCompletion() {
  for (final Synchronization sync : new ArrayList<Synchronization>(registeredSynchronizations)) {
    sync.beforeCompletion();
  }
}

代码示例来源:origin: org.apache.geronimo.ext.openejb/openejb-core

private void doBeforeCompletion() {
  for (Synchronization sync : new ArrayList<Synchronization>(registeredSynchronizations)) {
    sync.beforeCompletion();
  }
}

代码示例来源:origin: com.github.ns2j/nos2jdbc-core

public void beforeCompletion() {
  for (int i = 0; i < interposedSynchronizations.size(); ++i) {
    final Synchronization sync = (Synchronization) interposedSynchronizations
        .get(i);
    sync.beforeCompletion();
  }
}

代码示例来源:origin: org.lastaflute/lasta-di

public void beforeCompletion() {
  for (int i = 0; i < interposedSynchronizations.size(); ++i) {
    final Synchronization sync = (Synchronization) interposedSynchronizations.get(i);
    sync.beforeCompletion();
  }
}

代码示例来源:origin: hibernate/hibernate-search

@Override
  public void doBeforeTransactionCompletion(SessionImplementor sessionImplementor) {
    try {
      synchronization.beforeCompletion();
    }
    catch (Exception e) {
      throw new HibernateException( "Error while indexing in Hibernate Search (before transaction completion)", e );
    }
  }
}

代码示例来源:origin: com.atomikos/transactions-jta

@Override
public void beforeCompletion ()
{
  this.sync.beforeCompletion ();
  resetForReuse();
  LOGGER.logDebug("beforeCompletion() called on Synchronization: " + this.sync.toString());
}

代码示例来源:origin: com.github.ns2j/nos2jdbc-core

private void beforeCompletion(Synchronization sync) {
  try {
    sync.beforeCompletion();
  } catch (Throwable t) {
    logger.log(t);
    status = Status.STATUS_MARKED_ROLLBACK;
    endResources(XAResource.TMFAIL);
    rollbackResources();
  }
}

相关文章