Exemplo n.º 1
0
  /**
   * This routine finds the new XAResource for the transaction that used the old resource we
   * couldn't serialize. It does this by looking up the XARecoveryModule in the recovery manager and
   * asking it for the XAResource. The recovery manager will then look through its list of
   * registered XARecoveryResource implementations for the appropriate instance. If the
   * XARecoveryModule hasn't been initialised yet then this routine will fail, but on the next scan
   * it should work.
   */
  private final XAResource getNewXAResource() {
    RecoveryManager recMan = RecoveryManager.manager();
    Vector recoveryModules = recMan.getModules();

    if (recoveryModules != null) {
      Enumeration modules = recoveryModules.elements();

      while (modules.hasMoreElements()) {
        RecoveryModule m = (RecoveryModule) modules.nextElement();

        if (m instanceof XARecoveryModule) {
          /*
           * Blaargh! There are better ways to do this!
           */

          return ((XARecoveryModule) m).getNewXAResource(this);
        }
      }
    }

    return null;
  }