docs: @Override
      public final synchronized boolean enlist(ContainerTx tx) // d114677
      throws RemoteException
      {
          final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
          if (isTraceOn && tc.isEntryEnabled())
              Tr.entry(tc, "enlist: " + getStateName(state),
                       new Object[] { tx, currentTx }); //123293
  
          boolean result = false;
  
          switch (state)
          {
              case METHOD_READY:
  
                  // The only way we could be enlisted in this state is at
                  // activation; it is not possible for tx to be a global
                  // transaction; we do not care about enlistments for
                  // non-global transactions
  
                  // LIDB1181.23.5.1
                  // A new possibility exists now for the create case of a BMT bean.
                  // The home of this BMT session bean will also be configured as
                  // a BMT bean too.  This means that during the Home create method
                  // the container will have put a local transaction context (LTC)
                  // on the thread.  During postCreate the BMStatefulBeanO enlist
                  // will be invoked and a containerTx will already exist
                  // (ie. passed in ContainerTx is not null any more)
  
                  if (currentTx != null) {
                      if (isTraceOn && tc.isEntryEnabled()) // d144064
                          Tr.exit(tc, "enlist: unexpected non-null currentTx"); //123293
                      throw new BeanNotReentrantException(getStateName(state) +
                                                          ": enlist: unexpected non-null currentTx"); //123293  //PQ99986
                  }
  
                  // Note, for BM stateful bean, the transaction may have
                  // already been rolled back as a result of a prior business
                  // method being called and an unchecked exception occurring.
                  // when that happens, the next business method call will
                  // eventually get to this code with tx set to null.
                  // for that case, we simply skip doing the enlist and
                  // return boolean false to caller so that the business
                  // method gets dispatched.  Needed to pass CTS testcase
                  // which is checking for the TransactionRolledBackException
                  // occurring when client tries to commit a UserTransaction
                  // that was already rolled back as a result of the
                  // unchecked exception that previously occurred.
                  if (tx != null) //123393
                  {
                      result = tx.enlist(this);
                      currentTx = tx;
                      setState(TX_METHOD_READY);
                  }
  
                  if (isTraceOn && tc.isEntryEnabled())
                      Tr.exit(tc, "enlist: " + result + ": " + getStateName(state));
  
                  return result;
  
              case TX_METHOD_READY:
  
                  // The only way we could be enlisted in this state is at
                  // activation; tx must be the same as currentTx, since
                  // TransactionControl should have resumed our transaction
                  if (tx != currentTx)
                  {
                      if (isTraceOn && tc.isEntryEnabled()) // d144064
                          Tr.exit(tc, "enlist: unexpected non-null currentTx"); // 123293
                      String expected = "METHOD_READY"; // 123293
                      if (currentTx == null) // 123293
                      {
                          // This should never happened. Resume did not occur?
                          expected = "MAYBE_RESUME_DID_NOT_OCCUR"; // 123293
                      }
                      throw new InvalidBeanOStateException(getStateName(state)
                                      , expected); // 123293
                  }
  
                  if (isTraceOn && tc.isEntryEnabled())
                      Tr.exit(tc, "enlist: false");
  
                  return false;
  
              case IN_METHOD:
  
                  // We've got two possibilities: either the bean has just begun
                  // a transaction or we're attempting to activate for a re-entrant
                  // call from a different thread (which is an error); in the case of
                  // a re-entrant call, we must catch it here (cannot defer to
                  // preinvoke) since the other thread may change the state of the
                  // bean before preInvoke would be called in this thread.
  
                  // LIDB1181.23.5.1
                  // A new possibility exists now for the create case of a BMT bean.
                  // The home of this BMT session bean will also be configured as
                  // a BMT bean too.  This means that during the Home create method
                  // the container will have put a local transaction context (LTC)
                  // on the thread.  During postCreate the BMStatefulBeanO enlist
                  // will be invoked and a containerTx will already exist
                  // (ie. passed in ContainerTx is not null any more)
  
                  if (currentTx != null)
                  {
                      if (isTraceOn && tc.isEntryEnabled()) // d144064
                          Tr.exit(tc, "enlist: unexpected non-null currentTx"); //123293
                      throw new InvalidBeanOStateException(getStateName(state)
                                      , "TX_METHOD_READY"); //123293
                  }
  
                  if (tx == null) // d149781
                  {
                      // The only way for the bean to be in the IN_METHOD state with
                      // no transaction is if a different thread is already using it.
                      if (isTraceOn && tc.isEntryEnabled())
                          Tr.exit(tc, "enlist: reentrant call from different thread");
                      throw new BeanNotReentrantException(StateStrs[state] +
                                                          ": wrong thread");
                  }
  
                  result = tx.enlist(this);
                  currentTx = tx;
  
                  setState(TX_IN_METHOD);
  
                  if (isTraceOn && tc.isEntryEnabled())
                      Tr.exit(tc, "enlist: " + result + ": " + getStateName(state));
  
                  return result;
  
              case CREATING: // PQ56091
              case ACTIVATING: // d159252
              case PASSIVATING: // d159152
  
                  // For all of these states, the EJB Specification allows the use of
                  // UserTransaction methods.  However, it is not appropriate to
                  // enlist this bean at this time (enlist will be called later
                  // for the CREATING and ACTIVATING scenarios).
  
                  if (currentTx != null) {
                      if (isTraceOn && tc.isEntryEnabled()) // d144064
                          Tr.exit(tc, "enlist: unexpected non-null currentTx"); //1233293
                      throw new InvalidBeanOStateException(getStateName(state)
                                      , "TX_METHOD_READY"); //123293
                  }
                  if (isTraceOn && tc.isEntryEnabled())
                      Tr.exit(tc, "enlist: false - unexpected state!");
                  return false;
  
              case TX_IN_METHOD:
              case COMMITTING_IN_METHOD:
              case COMMITTING_OUTSIDE_METHOD:
  
                  // This bean is already in a transaction - and any of these states
                  // could be seen by a different transaction calling a method on it,
                  // or they could also be due to a customer coded callback to the same
                  // bean.
                  if (isTraceOn && tc.isEntryEnabled())
                      Tr.exit(tc, "enlist: not re-entrant");
                  if (currentTx != tx)
                      throw new BeanNotReentrantException(StateStrs[state] +
                                                          ": wrong transaction");
  
                  // This isn't a different thread/tran, but it is a reentrant call,
                  // which must be caught here rather than preInvoke to insure the
                  // extra cache pins are undone in the activation strategy.     d159152
                  throw new BeanNotReentrantException(getStateName(state));
  
              case REMOVING:
  
                  // Note: prior to the access timeout support added in EJB 3.1, there
                  // were issues for the REMOVING state where multiple threads might
                  // attempt to enter the bean concurrently, but now that the bean is
                  // properly locked, it is safe to just not enlist the bean and thus
                  // support UserTransaction methods in ejbRemove/PreDestroy per spec,
                  // though if there is a transaction then verify this is the EJB 3.x
                  // remove scenario.
  
                  if (currentTx != null && currentTx.ivRemoveBeanO != this) {
                      if (isTraceOn && tc.isEntryEnabled())
                          Tr.exit(tc, "enlist: unexpected non-null currentTx");
                      throw new InvalidBeanOStateException(getStateName(state), "TX_METHOD_READY");
                  }
                  if (isTraceOn && tc.isEntryEnabled())
                      Tr.exit(tc, "enlist: false - not enlisted for REMOVING state");
                  return false;
  
              default:
                  // Any other state is a programming error... there should be no
                  // way to encounter these states even from another thread/transaction.
                  if (isTraceOn && tc.isEntryEnabled()) // d144064
                      Tr.exit(tc, "enlist: invalid state: " + getStateName(state)); //123293
                  throw new InvalidBeanOStateException(getStateName(state),
                                  "METHOD_READY | " +
                                                  "TX_METHOD_READY | " +
                                                  "IN_METHOD");
  
          }
  
      }