/*
(non-Javadoc)

@see javax.transaction.xa.XAResource#getTransactionTimeout()
778713
public int getTransactionTimeout() throws XAException {

        final String methodName = "getTransactionTimeout";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName);
        }

        final int timeout = _siXaResource.getTransactionTimeout();

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName, timeout);
        }
        return timeout;

    }
485992
private static Long getTimeout(final Ticket ticket) {
        val ttl = ticket.getExpirationPolicy().getTimeToLive();
        if (ttl > Integer.MAX_VALUE) {
            return (long) Integer.MAX_VALUE;
        } else if (ttl <= 0) {
            return 1L;
        }
        return ttl;
    }
1175169
public Transaction getTransaction() {
        try {
            return getTransactionManager().getTransaction();
        }
        catch (Exception ex) {
            StandardLogger logger = LoggerUtil.getStandardLogger();
            logger.severeException(ex.getMessage(), ex);
            return null;
        }
    }
700112
protected int getTimeoutForResponse() {
        String timeout_s = null;
        int timeout;
        try {
            timeout_s = this.getAttributeValueSmart(TIMEOUT);
            timeout = timeout_s==null?30:Integer.parseInt(timeout_s);
            if (timeout<0) timeout = 30;
        } catch (NumberFormatException e) {
            logger.severeException("Cannot parse timeout value " + timeout_s, e);
            timeout = 30;
        } catch (PropertyException e) {
            logger.severeException("Cannot read timeout attribute " + TIMEOUT, e);
            timeout = 30;
        }
        return timeout;
    }
666309
@Override
	public void setTransactionTimeout(int seconds) throws TransactionManagementException {
		logger.entering(CLASSNAME, "setTransactionTimeout", seconds);
		logger.fine("do nothing");
		logger.exiting(CLASSNAME, "setTransactionTimeout");
	}
835644
public final Transaction getTransaction()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass
                        , "getTransaction"
                            );
        // If the log is full introduce a delay for a checkpoiunt before allowing the 
        // application to proceed.
        objectManagerState.transactionPacing();
        Transaction transaction = objectManagerState.getTransaction();

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "getTransaction"
                       , "returns transaction=" + transaction + "(Transaction)"
                            );
        return transaction;
    }
427605
public synchronized void inactivityTimeout() {
        final boolean traceOn = TraceComponent.isAnyTracingEnabled();

        if (traceOn && tc.isEntryEnabled())
            Tr.entry(tc, "inactivityTimeout", this);

        _inactivityTimerActive = false;

        if (_inactivityTimer != null) {
            try {
                // important that this runs as part of synchronized block
                // to prevent context being re-imported while processing.
                _inactivityTimer.alarm();
            } catch (Throwable exc) {
                FFDCFilter.processException(exc, "com.ibm.ws.tx.jta.TransactionImpl.inactivityTimeout", "2796", this);
                if (traceOn && tc.isEventEnabled())
                    Tr.event(tc, "exception caught in inactivityTimeout", exc);
                // swallow
            } finally {
                _inactivityTimer = null;
            }

        } else {
            if (_activeAssociations <= 0) // off server ... do the rollback
            {
                final EmbeddableTranManagerSet tranManager = (EmbeddableTranManagerSet) TransactionManagerFactory.getTransactionManager();

                try {
                    // resume this onto the current thread and roll it back
                    tranManager.resume(this);
                    // PK15024
                    // If there is a superior server involved in this transaction, make sure it is told about this inactivity timeout.
                    try {
                        tranManager.setRollbackOnly();
                    } catch (Exception e) {
                        FFDCFilter.processException(e, "com.ibm.ws.Transaction.JTA.TransactionImpl.inactivityTimeout", "4353", this);
                        if (traceOn && tc.isDebugEnabled())
                            Tr.debug(tc, "inactivityTimeout setRollbackOnly threw exception", e);
                    }
                    // Mark it so that a bean on the superior server can test its status on return.
                    // PK15024
                    tranManager.rollback();
                } catch (Exception ex) {
                    if (traceOn && tc.isDebugEnabled())
                        Tr.debug(tc, "inactivityTimeout resume/rollback threw exception", ex);
                    // swallow this exception
                    // main timeout may have already rolled back!
                }
            }
        }

        if (traceOn && tc.isEntryEnabled())
            Tr.exit(tc, "inactivityTimeout");
    }
575858
public void processTimeout(TimeoutEvent timeout) {
    ClientTransaction trans = timeout.getClientTransaction();
    if (trans == null) {
      return;
    }

    SipTransaction sip_trans = null;
    synchronized (respTransactions) {
      sip_trans = (SipTransaction) respTransactions.get(trans);
    }

    if (sip_trans == null) {
      return;
    }

    if (trans.getState().getValue() == TransactionState._TERMINATED) {
      synchronized (respTransactions) {
        respTransactions.remove(trans);
      }
    }

    // check for listener handling
    MessageListener listener = sip_trans.getClientListener();
    if (listener != null) {
      listener.processEvent(timeout);
      return;
    }

    // if no listener, use the default blocking mechanism
    synchronized (sip_trans.getBlock()) {
      sip_trans.getEvents().addLast(timeout);
      sip_trans.getBlock().notifyEvent();
    }
  }
340589
@Override
    public void setTransactionTimeout(int timeout) throws SystemException {
        if (isJustLazyNow()) {
            arrangeLazyProcessIfAllowed(() -> {
                if (logger.isDebugEnabled()) {
                    logger.debug("#lazyTx ...Setting transaction timeout {}: {}", timeout, buildLazyTxExp());
                }
                doSuperSetTransactionTimeout(timeout);
            });
        } else {
            doSuperSetTransactionTimeout(timeout);
        }
    }
467909
@Override
   public synchronized TransactionManager getTransactionManager() {
      if (!lookupDone) {
         doLookups(globalCfg.classLoader());
      }
      if (tm != null)
         return tm;
      if (lookupFailed) {
         if (!noJBossTM) {
            // First try an embedded JBossTM/Wildly instance
            tryEmbeddedJBossTM();
         }

         if (noJBossTM) {
            //fall back to a dummy from Infinispan
            useDummyTM();
         }
      }
      return tm;
   }
1223246
private Long getTransactorID() {
    if (tnode == null) {
      tnode = env.getSharedResources().getTransactorNode();
    }
    return tnode.getTransactorID().getLongID();
  }
97602
@Override
    public void setUOWTimeout(int uowType, int timeout) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "setUOWTimeout", new Object[] { Integer.valueOf(uowType), Integer.valueOf(timeout) });

        switch (uowType) {
            case UOWSynchronizationRegistry.UOW_TYPE_GLOBAL_TRANSACTION:
                try {
                    EmbeddableTransactionManagerFactory.getTransactionManager().setTransactionTimeout(timeout);
                } catch (Exception e) {
                    final IllegalArgumentException iae = new IllegalArgumentException(e);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                        Tr.exit(tc, "setUOWTimeout", iae);
                    throw iae;
                }
                break;

            default:
                final IllegalArgumentException iae = new IllegalArgumentException("Invalid UOW type: " + uowType);
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    Tr.exit(tc, "setUOWTimeout", iae);
                throw iae;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "setUOWTimeout");
    }
307466
private SITransaction getCurrentTransaction() {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "getCurrentTransaction");
        }

        SITransaction currentTransaction = null;

        // Is there a current local transaction?

        if (_localTransaction != null) {

            currentTransaction = _localTransaction.getCurrentTransaction();

        }

        // If not, is there a current global transaction?

        if ((currentTransaction == null) && (_xaResource != null)) {

            currentTransaction = _xaResource.getCurrentTransaction();

        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr
                    .exit(this, TRACE, "getCurrentTransaction",
                            currentTransaction);
        }
        return currentTransaction;

    }
1228938
public long getTimeout()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "getTimeout");
      
    long timeout = aiRequestedTick.getTimeout();
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "getTimeout", new Long(timeout));
    return timeout;
  }
678526
public Long getLastTransactionID(){
        
        if(logger.isDebugEnabled()){
            logger.debug("[getLastTransactionID]");
        }
        
        return (Long) template.selectOne(SELECT_LAST_TRANSACTION_ID);
    }
644314
public ServerTransaction getAssociatedServerTransaction(ClientTransaction ct) {
		
		if(ct == null) {
			throw new NullPointerException("Passed Client Transaction is null!");
		}
		
		final ClientTransactionWrapper ctw = (ClientTransactionWrapper) ct;
		final String associatedServerTransactionId = ctw.getAssociatedServerTransactionId();
		if (associatedServerTransactionId != null) {
			SIPServerTransaction st = (SIPServerTransaction) ra.getProviderWrapper().getSipStackImpl().findTransaction(associatedServerTransactionId, true);
			return (ServerTransaction) ra.getTransactionWrapper(st);
		}
		else {
			return null;
		}
	}
78689
public static void rcvXA_setTxTimeout(CommsByteBuffer request, Conversation conversation,
                                         int requestNumber, boolean allocatedFromBufferPool,
                                         boolean partOfExchange)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "rcvXA_setTxTimeout",
                                           new Object[]
                                           {
                                              request,
                                              conversation,
                                              ""+requestNumber,
                                              ""+allocatedFromBufferPool,
                                              ""+partOfExchange
                                            });

      try
      {
         int clientTransactionId = request.getInt();
         int timeout = request.getInt();

         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
         {
            SibTr.debug(tc, "XAResource Object ID", clientTransactionId);
            SibTr.debug(tc, "Timeout", timeout);
         }

         // Get the transaction out of the table
         ServerLinkLevelState linkState = (ServerLinkLevelState) conversation.getLinkLevelAttachment();
         SITransaction tran = linkState.getTransactionTable().get(clientTransactionId, true);

         boolean success = false;
         if ((tran != null) && (tran != IdToTransactionTable.INVALID_TRANSACTION))
         {
                 // tran may be null if the client is calling this method on
                 // an unenlisted XA resource.

                 // Get the actual transaction ...
                 SIXAResource xaResource = (SIXAResource) tran;

                 // Now call the method on the XA resource
                 success = xaResource.setTransactionTimeout(timeout);
         }
         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Result: " + success);

         CommsByteBuffer reply = poolManager.allocate();
         if (success)
         {
            reply.put((byte) 1);
         }
         else
         {
            reply.put((byte) 0);
         }

         try
         {
            conversation.send(reply,
                              JFapChannelConstants.SEG_XA_SETTXTIMEOUT_R,
                              requestNumber,
                              JFapChannelConstants.PRIORITY_MEDIUM,
                              true,
                              ThrottlingPolicy.BLOCK_THREAD,
                              null);
         }
         catch (SIException e)
         {
            FFDCFilter.processException(e,
                                        CLASS_NAME + ".rcvXA_setTxTimeout",
                                        CommsConstants.STATICCATXATRANSACTION_SETTXTIMEOUT_01);

            SibTr.error(tc, "COMMUNICATION_ERROR_SICO2027", e);
         }
      }
      catch (XAException e)
      {
         FFDCFilter.processException(e,
                                     CLASS_NAME + ".rcvXA_setTxTimeout",
                                     CommsConstants.STATICCATXATRANSACTION_SETTXTIMEOUT_02);

         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "XAException - RC: " + e.errorCode, e);

         StaticCATHelper.sendExceptionToClient(e,
                                               CommsConstants.STATICCATXATRANSACTION_SETTXTIMEOUT_02,
                                               conversation, requestNumber);
      }

      request.release(allocatedFromBufferPool);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "rcvXA_setTxTimeout");
   }