code: public boolean canEnrollChangeToGlobalTx(final SessionImpl session, final PlainChangesLog changes)
     {
        try
        {
           int status;
           if (tm != null && (status = tm.getStatus()) != Status.STATUS_NO_TRANSACTION)
           {
              if (status != Status.STATUS_ACTIVE && status != Status.STATUS_PREPARING)
              {
                 throw new IllegalStateException("The session cannot be enrolled in the current global transaction due "
                    + "to an invalidate state, the current status is " + status
                    + " and only ACTIVE and PREPARING are allowed");
              }
              SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
              {
                 public Void run() throws Exception
                 {
                    add(session, changes);
                    return null;
                 }
              });
              return true;
           }
        }
        catch (PrivilegedActionException e)
        {
           log.warn("Could not check if a global Tx has been started or register the session into the resource manager",
              e);
        }
        catch (SystemException e)
        {
           log.warn("Could not check if a global Tx has been started or register the session into the resource manager",
              e);
        }
        return false;
     }
docs: Checks if a global Tx has been started if so the session and its change will be dynamically enrolled
  @param session the session to enlist in case a Global Tx has been started
  @param changes the changes to enlist in case a Global Tx has been started
  @return <code>true</code> if a global Tx has been started and the session and its change could
  be enrolled successfully, <code>false</code> otherwise
  @throws IllegalStateException if the current status of the global transaction is not appropriate