コード例 #1
0
ファイル: MultiClose.java プロジェクト: radeshrao/narayana
  @Test
  public void testMultiClose() throws Exception {
    UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();

    BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
    com.arjuna.wst11.BAParticipantManager bpm1 = null;
    com.arjuna.wst11.BAParticipantManager bpm2 = null;
    DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CLOSE, "1240");
    FailureBusinessParticipant fp =
        new FailureBusinessParticipant(FailureBusinessParticipant.FAIL_IN_CLOSE, "5679");

    try {
      uba.begin();

      bpm1 = bam.enlistForBusinessAgreementWithParticipantCompletion(p, "1240");
      bpm2 = bam.enlistForBusinessAgreementWithParticipantCompletion(fp, "5679");
      bpm1.completed();
      bpm2.completed();
    } catch (Exception eouter) {
      try {
        uba.cancel();
      } catch (Exception einner) {
      }
      throw eouter;
    }
    // the close should succeed even though the participant fails
    uba.close();
    assertTrue(p.passed());
  }
コード例 #2
0
  /** Suspend the current transaction. */
  protected void suspendTransaction() {
    try {
      /*
       * There should either be an Atomic Transaction *or* a Business Activity
       * associated with the thread.
       */
      final TransactionManager transactionManager = TransactionManagerFactory.transactionManager();
      final BusinessActivityManager businessActivityManager =
          BusinessActivityManagerFactory.businessActivityManager();

      if (transactionManager != null) {
        transactionManager.suspend();
      }

      if (businessActivityManager != null) {
        businessActivityManager.suspend();
      }
    } catch (final Throwable th) {
      wstxLogger.i18NLogger.warn_mw_wst11_service_JaxHC11P_1(
          "com.arjuna.mw.wst11.service.JaxBaseHeaderContextProcessor.suspendTransaction()", th);
    }
  }