/**
     * Global Transaction 
     */
    public void start(final String threadId, final XidImpl xid, int flags, int timeout, boolean singleTM) throws XATransactionException {
        
        TransactionContext tc = null;
        switch (flags) {
            case XAResource.TMNOFLAGS: {
                try {
          checkXAState(threadId, xid, false, false);
          tc = transactions.getOrCreateTransactionContext(threadId);
          if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
              throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
          }
          tc.setTransactionTimeout(timeout);
          tc.setXid(xid);
          tc.setTransactionType(TransactionContext.Scope.GLOBAL);
          if (singleTM) {
            tc.setTransaction(transactionManager.getTransaction());
            assert tc.getTransaction() != null;
          } else {
            FutureWork<Transaction> work = new FutureWork<Transaction>(new Callable<Transaction>() {
              @Override
              public Transaction call() throws Exception {
                return transactionManager.getTransaction();
              }
            }, 0);
            workManager.doWork(work, WorkManager.INDEFINITE, tc, null);
            tc.setTransaction(work.get());
          }
        } catch (NotSupportedException e) {
          throw new XATransactionException(e, XAException.XAER_INVAL);
        } catch (WorkException e) {
          throw new XATransactionException(e, XAException.XAER_INVAL);
        } catch (InterruptedException e) {
          throw new XATransactionException(e, XAException.XAER_INVAL);
        } catch (ExecutionException e) {
          throw new XATransactionException(e, XAException.XAER_INVAL);
        } catch (SystemException e) {
          throw new XATransactionException(e, XAException.XAER_INVAL);
        }
                break;
            }
            case XAResource.TMJOIN:
            case XAResource.TMRESUME: {
                tc = checkXAState(threadId, xid, true, false);
                TransactionContext threadContext = transactions.getOrCreateTransactionContext(threadId);
                if (threadContext.getTransactionType() != TransactionContext.Scope.NONE) {
                    throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
                }
                
                if (flags == XAResource.TMRESUME && !tc.getSuspendedBy().remove(threadId)) {
                    throw new XATransactionException(XAException.XAER_PROTO, QueryPlugin.Util.getString("TransactionServer.resume_failed", new Object[] {xid, threadId})); //$NON-NLS-1$