public boolean enlistResource(XAResource xaRes)
      throws RollbackException, IllegalStateException, SystemException {
    XAResource xar = null;
    try {
      synchronized (this) {
        if (status == Status.STATUS_MARKED_ROLLBACK) {
          String exception =
              "GlobalTransaction::enlistResource::Cannot enlist resource as the transaction has been marked for rollback";
          LogWriter writer = TransactionUtils.getLogWriter();
          if (VERBOSE) {
            writer.fine(exception);
          }
          throw new RollbackException(exception);
        } else if (status != Status.STATUS_ACTIVE) {
          String exception =
              "GlobalTransaction::enlistResource::Cannot enlist a resource to a transaction which is not active";
          LogWriter writer = TransactionUtils.getLogWriter();
          if (VERBOSE) {
            writer.fine(exception);
          }
          throw new IllegalStateException(exception);
        }
        if (resourceMap.isEmpty()) {
          xaRes.start(xid, XAResource.TMNOFLAGS);
          int delay = (int) ((expirationTime - System.currentTimeMillis()) / 1000);
          try {
            if (!DISABLE_TRANSACTION_TIMEOUT_SETTING) {
              xaRes.setTransactionTimeout(delay);
            }
          } catch (XAException xe) {
            String exception =
                String.format(
                    "GlobalTransaction::enlistResource:Exception occurred in trying to set XAResource timeout due to %s Error Code, %s",
                    xe, xe.errorCode);
            LogWriter writer = TransactionUtils.getLogWriter();
            if (VERBOSE) {
              writer.fine(exception);
            }
            throw new SystemException(exception);
          }
          resourceMap.put(xaRes, Boolean.TRUE);
        } else {
          synchronized (resourceMap) {
            Iterator iterator = resourceMap.keySet().iterator();
            xar = (XAResource) iterator.next();
          }
          if (!xar.isSameRM(xaRes)) {
            LogWriter writer = TransactionUtils.getLogWriter();
            if (writer.severeEnabled()) {
              writer.severe(
                  "GlobalTransaction::enlistResource::Only one Resouce Manager supported");
            }
            throw new SystemException(
                "GlobalTransaction::enlistResource::Only one Resouce Manager supported");
          } else {
            xaRes.start(xid, XAResource.TMJOIN);
            resourceMap.put(xaRes, Boolean.TRUE);
          }
        }
      }
    } catch (Exception e) {
      String addon =
          (e instanceof XAException ? ("Error Code =" + ((XAException) e).errorCode) : "");
      LogWriter writer = TransactionUtils.getLogWriter();
      if (VERBOSE) {
        writer.fine(
            String.format(
                "GlobalTransaction::enlistResource::error while enlisting XAResource %s %s",
                e, addon),
            e);
      }
      SystemException sysEx = new SystemException(
          String.format("GlobalTransaction::enlistResource::error while enlisting XAResource %s %s",
              e, addon));
      sysEx.initCause(e);
      throw sysEx;
    }
    return true;
  }
Enlist the specified XAResource with this transaction. Currently only one Resource Manager is
being supported. enlistResource checks if there is no XAResource, then enlists the current
XAResource. For subsequent XAResources, it checks if is the same Resource Manager. If it is,
then the XAResources are addded, else an exception is thrown

Concurrency: The order of acquiring lock will be lock on "this" followed by lock on
resourceMap. It is possible that in some functions of this class both the locks are not needed
, but if the two are acquired then the realitive order will always be"this" followed by
resourceMap.

@param xaRes XAResource to be enlisted
@return true, if resource was enlisted successfully, otherwise false.
@throws SystemException - Thrown if the transaction manager encounters an unexpected error
        condition.
@throws IllegalStateException - Thrown if the transaction in the target object is in the
        prepared state or the transaction is inactive.
@throws RollbackException - Thrown to indicate that the transaction has been marked for
        rollback only.

@see Transaction#enlistResource(XAResource)
geode-core/src/main/java/org/apache/geode/internal/jta/GlobalTransaction.java