Adds the {@link EmbeddedTransaction} in the local transaction table.
499857
public void createLocalTx(Xid xid, EmbeddedTransaction tx) {
      localTxTable.put(xid, tx);
      if (trace) {
         log.tracef("[%s] New tx=%s", xid, tx);
      }
   }
1347356
final void localTransactionStarted() {

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

        final ConnectionEvent event = new ConnectionEvent(this,
                        ConnectionEvent.LOCAL_TRANSACTION_STARTED);

        // Copy list to protect against concurrent modification by listener

        final List<ConnectionEventListener> copy;
        synchronized (_connectionListeners) {
            copy = new ArrayList<ConnectionEventListener>(_connectionListeners);
        }

        for (final Iterator iterator = copy.iterator(); iterator.hasNext();) {
            final Object object = iterator.next();
            if (object instanceof ConnectionEventListener) {
                ((ConnectionEventListener) object)
                                .localTransactionStarted(event);
            }
        }

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

    }
489622
public void assignTransaction(TransactionImpl v)
   {
      txs.put(Long.valueOf(Thread.currentThread().getId()), v);
   }
1168531
void startTransactionalBranch(Xid xid) {

        cleanupTransactionBinding();

        final TransactionBindingType transactionBindingType = this.transactionBinding.getTransactionBindingType();

        // already associated to a local transaction
        if (transactionBindingType == TransactionBindingType.LocalTransaction) {
            LocalTransactionProxy<C> localTransactionProxy = this.toLocalTransaction();
            Validate.isTrue(!localTransactionProxy.hasTransactionalData(),
                    "Connection is associated to a local transaction and has uncommitted transactional data");
            if (localTransactionProxy.hasTransactionalData()) {
                throw new IllegalStateException(
                        "Connection is associated to a local transaction and has uncommitted transactional data");
            }

            XATransactionalBranch<C> xaTransactionalBranch = 
                    this.xaTransactionalBranchDictionary.findTransactionalBranch(xid);
            // xaTransactionalBranch!=null => joining a existing transactional branch
            if (xaTransactionalBranch == null) {
                IPhynixxManagedConnection<C> connection = localTransactionProxy.getConnection();
                if( connection==null || connection.isClosed()) {
                    connection= this.createPhysicalConnection();
                }
                xaTransactionalBranch = this.xaTransactionalBranchDictionary.instanciateTransactionalBranch(xid, connection);
            } else {
                localTransactionProxy.close();
            }
            // forget the Local transaction
            this.transactionBinding.release();

            XATransactionalBranch<C> transactionalBranch = this.xaTransactionalBranchDictionary
                    .findTransactionalBranch(xid);
            Validate.isTrue(xaTransactionalBranch != null, "Expect a transactional branch to be created");

            this.transactionBinding.activateGlobalTransaction(new GlobalTransactionProxy<C>(transactionalBranch));

            // no transaction binding
        } else if (transactionBindingType == TransactionBindingType.NoTransaction) {
            XATransactionalBranch<C> transactionalBranch = this.xaTransactionalBranchDictionary
                    .findTransactionalBranch(xid);

            // / xaTransactionalBranch!=null => joining a existing transactional
            // branch
            if (transactionalBranch == null) {
                IPhynixxManagedConnection<C> physicalConnection = this.createPhysicalConnection();
                transactionalBranch = this.xaTransactionalBranchDictionary.instanciateTransactionalBranch(xid,
                        physicalConnection);
                this.xaTransactionalBranchDictionary.instanciateTransactionalBranch(xid, physicalConnection);
            }
            this.transactionBinding.activateGlobalTransaction(new GlobalTransactionProxy<C>(transactionalBranch));

            // if bound to a global TX , check if same XID
        } else if (transactionBindingType == TransactionBindingType.GlobalTransaction) {

            XATransactionalBranch<C> transactionalBranch = this.xaTransactionalBranchDictionary
                    .findTransactionalBranch(xid);

            // xaTransactionalBranch!=null => joining a existing transactional
            // branch
            if (transactionalBranch == null) {
                IPhynixxManagedConnection<C> physicalConnection = this.createPhysicalConnection();
                transactionalBranch = this.xaTransactionalBranchDictionary.instanciateTransactionalBranch(xid,
                        physicalConnection);
                this.xaTransactionalBranchDictionary.instanciateTransactionalBranch(xid, physicalConnection);
            }

            // Check if previous XID are compatible to the current
            GlobalTransactionProxy<C> previousGlobalTransactionProxy = this.transactionBinding
                    .getEnlistedGlobalTransaction();
            if (previousGlobalTransactionProxy != null) {
                Xid previousXid = previousGlobalTransactionProxy.getXid();
                byte[] currentTransactionId = previousXid.getGlobalTransactionId();
                if (!Arrays.equals(xid.getGlobalTransactionId(), currentTransactionId)) {
                    LOG.warn("TransactionId of the new Transaction doenn't corresponds to the transactionId of the previous Ids");
                }
                previousGlobalTransactionProxy.release();
            }

            this.transactionBinding.activateGlobalTransaction(new GlobalTransactionProxy<C>(transactionalBranch));

        }

    }
1182745
public void put(@NotNull final PersistentStoreTransaction txn,
                    final long localId,
                    @NotNull final ByteIterable value,
                    @Nullable final ByteIterable oldValue,
                    final int propertyId,
                    @NotNull final ComparableValueType type) {
        final Store valueIdx = getOrCreateValueIndex(txn, propertyId);
        final ByteIterable key = PropertyKey.propertyKeyToEntry(new PropertyKey(localId, propertyId));
        final Transaction envTxn = txn.getEnvironmentTransaction();
        primaryStore.put(envTxn, key, value);
        final ByteIterable secondaryValue = LongBinding.longToCompressedEntry(localId);
        boolean success;
        if (oldValue == null) {
            success = allPropsIndex.put(envTxn, IntegerBinding.intToCompressedEntry(propertyId), secondaryValue);
        } else {
            success = deleteFromStore(envTxn, valueIdx, secondaryValue, createSecondaryKeys(store.getPropertyTypes(), oldValue, type));
        }
        if (success) {
            for (final ByteIterable secondaryKey : createSecondaryKeys(store.getPropertyTypes(), value, type)) {
                valueIdx.put(envTxn, secondaryKey, secondaryValue);
            }
        }
        checkStatus(success, "Failed to put");
    }
1078392
def AddTransaction(self, tx):
        
        if BC.Default() is None:
            return False

        if tx.Hash.ToBytes() in self.MemPool.keys():
            return False

        if BC.Default().ContainsTransaction(tx.Hash):
            return False

        if not tx.Verify(self.MemPool.values()):
            logger.error("Verifying tx result... failed")
            return False

        self.MemPool[tx.Hash.ToBytes()] = tx

        return True
1195011
public boolean add(T transaction, I item) {
		return matrix.add(transactionToIndex(transaction), itemToIndex(item));
	}
602222
public boolean add(Token token,
                       Transaction transaction)
                    throws ObjectManagerException
    {
        addEntry(token, transaction);
        return true;
    }
816314
public void addOngoingTransaction(Transaction transaction) {

		if(transaction != null && ongoingTransactions != null  && !isReadyToInvalidate() ) {
			boolean added = this.ongoingTransactions.add(transaction);
			if(added) {
				if(logger.isDebugEnabled()) {
					logger.debug("transaction "+ transaction +" has been added to sip session's ongoingTransactions" );
				}
				setReadyToInvalidate(false);
			}
		}
	}
911480
private J2EETransactionImpl newInternTransaction()
    {
        if (log.isDebugEnabled()) log.debug("obtain new intern odmg-transaction");
        J2EETransactionImpl tx = new J2EETransactionImpl(this);
        try
        {
            getConfigurator().configure(tx);
        }
        catch (ConfigurationException e)
        {
            throw new OJBRuntimeException("Cannot create new intern odmg transaction", e);
        }
        return tx;
    }
1161395
public boolean add(Token token,
                       Transaction transaction)
                    throws ObjectManagerException
    {
        List.Entry entry = addEntry(token, transaction);
        return (entry != null);
    }
859851
private void beginInternTransaction()
    {
        if (log.isDebugEnabled()) log.debug("beginInternTransaction was called");
        J2EETransactionImpl tx = (J2EETransactionImpl) super.currentTransaction();
        if (tx == null) tx = newInternTransaction();
        if (!tx.isOpen())
        {
            // start the transaction
            tx.begin();
            tx.setInExternTransaction(true);
        }
    }
679674
public void put(@NotNull final Transaction txn, final long localId,
                    final int blobId, @NotNull final ByteIterable value) {
        primaryStore.put(txn, PropertyKey.propertyKeyToEntry(new PropertyKey(localId, blobId)), value);
        allBlobsIndex.put(txn, IntegerBinding.intToCompressedEntry(blobId), LongBinding.longToCompressedEntry(localId));
    }
1124214
public void setLocal(boolean local)
   {
      // start local transaction
      if (local && changesList.get() == null)
      {
         beginTransaction();
      }
      this.local.set(local);
   }
59111
public synchronized void putSITransaction(SITransaction transaction)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "putSITransaction", transaction);
      Transaction commsTx = (Transaction)transaction;

      int flags = -1;

      if (transaction == null)
      {
         // No transaction - add "no transaction" flags to buffer.
        putInt(0x00000000);
      }
      else
      {
         // First we must search for any optimized transactions as they hold much more information
         // than the old-style ones.
         OptimizedTransaction optTx = null;

         // First see if the transaction is a global one. This could be both optimized or
         // unoptimized but the result is buried within it
         if (transaction instanceof SuspendableXAResource)
         {
            SIXAResource suspendableXARes = ((SuspendableXAResource) transaction).getCurrentXAResource();
            if (suspendableXARes instanceof OptimizedTransaction)
            {
               // The current XA Resource is indeed optimized
               optTx = (OptimizedTransaction) suspendableXARes;
            }
         }
         // Otherwise the actual transaction itself may be an optimized one - this is in the case
         // of an optimized local transaction.
         else if (transaction instanceof OptimizedTransaction)
         {
            optTx = (OptimizedTransaction) transaction;
         }

         // If we are optimized...
         if (optTx != null)
         {
            // Optimized transaction
            flags = CommsConstants.OPTIMIZED_TX_FLAGS_TRANSACTED_BIT;

            boolean local = optTx instanceof SIUncoordinatedTransaction;
            boolean addXid = false;
            boolean endPreviousUow = false;
            if (local)
            {
               flags |= CommsConstants.OPTIMIZED_TX_FLAGS_LOCAL_BIT;
            }
            if (!optTx.isServerTransactionCreated())
            {
               flags |= CommsConstants.OPTIMIZED_TX_FLAGS_CREATE_BIT;
               if (local && optTx.areSubordinatesAllowed())
                  flags |= CommsConstants.OPTIMIZED_TX_FLAGS_SUBORDINATES_ALLOWED;
               optTx.setServerTransactionCreated();
               addXid = !local;
            }
            if (addXid && (optTx.isEndRequired()))
            {
               flags |= CommsConstants.OPTIMIZED_TX_END_PREVIOUS_BIT;
               endPreviousUow = true;
            }
            putInt(flags);
            putInt(optTx.getCreatingConversationId());
            putInt(commsTx.getTransactionId());
            if (addXid)
            {
               if (endPreviousUow)
               {
                  putInt(optTx.getEndFlags());
                  optTx.setEndNotRequired();
               }
               putXid(new XidProxy(optTx.getXidForCurrentUow()));
            }
         }
         else
         {
            // This is an un-optimized transaction - simply append transaction ID.
            putInt(commsTx.getTransactionId());
         }
      }

      if (TraceComponent.isAnyTracingEnabled()) {
        int commsId = -1;
        if (commsTx != null)  commsId = commsTx.getTransactionId();
        CommsLightTrace.traceTransaction(tc, "PutTxnTrace", commsTx, commsId, flags);
      }

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "putSITransaction");
   }
279673
function addPostHooksTransaction() {
            // disable (post) hooks, we will only trigger them on transaction succceed
            this.__hooksEnabled = false;
            this.constructor.hooksTransaction.call(
                _this,
                transaction,
                this.__posts
                    ? this.__posts.save
                    : undefined
            );
        }
813613
@Override
    public void localTransactionStarted(ConnectionEvent event) {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(this, tc, "localTransactionStarted");
        }

        if (event.getId() == ConnectionEvent.LOCAL_TRANSACTION_STARTED) {

            //
            // The LocalTransactionStarted event for local transaction connections is analogous to the
            //  InteractionPending event for xa transaction connections.  JMS's usage of ManagedSessions
            //  is very dependent on the ability to use these two events for properly enlisting their
            //  unshared connections.  When a ManagedSession is first created, it is done under an LTC.
            //  When that LTC ends, some partial cleanup is done on the MCWrapper, but it is not put
            //  back into the pool because the unshared connection handle is still active.  One of the
            //  items that gets cleaned up is the coordinator within the MCWrapper.  This makes sense
            //  since the LTC has ended.  But, when it is determined by JMS that it's time to get
            //  enlisted in the current transaction, a null coordinator causes all kinds of problems
            //  (reference the string of defects that have attempted to correct this situation).  The
            //  solution determined seems to be the right one.  In both localTransactionStarted
            //  and interactionPending methods, we need to check if the MCWrapper coordinator is null and
            //  if it is null, then go out to the TM and get it updated.
            //
            // Note that this special null coordinator processing is due to the SmartHandle support
            //  utilized by JMS and RRA.  Without smart handles, the coordinator would have gotten
            //  re-initialized during the handle re-association logic.
            //
            // In addition, we have determined that the check for involvedInTransaction() is not necessary
            //  (and causes problems for the scenario described just previous).  Since the getCurrentTranWrapper()
            //  already checks for a valid state setting before returning, we can just rely on that method to
            //  do the proper checking instead of calling the involvedInTransaction() method.
            //
            UOWCoordinator uowCoordinator = mcWrapper.getUOWCoordinator();

            if (uowCoordinator == null) {
                uowCoordinator = mcWrapper.updateUOWCoordinator();
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(this, tc, "uowCoord was null, updating it to current coordinator");
                }
            }

            // if the coordinator is still null, then we are running with NO transaction
            //  context on the thread.  This case currently needs to be supported because
            //  servlets can spin their own threads which would not have context.
            // Note: it is very rare that users do this.  All other occurances are
            //  considered to be an error.
            if (uowCoordinator == null) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
                    Tr.exit(this, tc, "localTransactionStarted", "no transaction context, return without enlisting");
                }
                return;
            }

            /*
             * We know we are in a transaction but we need to verify that it is not a global transaction
             * before continuing.
             */
            if (tc.isDebugEnabled() && uowCoordinator.isGlobal()) {
                IllegalStateException ise = new IllegalStateException("Illegal attempt to start a local transaction within a global (user) transaction");
                Tr.debug(this, tc, "ILLEGAL_USE_OF_LOCAL_TRANSACTION_J2CA0295", ise);
            }

            /*
             * The ManagedConnection should be associated with a transaction. And, if it's not,
             * the getCurrentTranWrapper() method will detect the situation and throw an
             * exception.
             *
             * enlist() the ManagedConnection from the transaction.
             */

            try {
                mcWrapper.getCurrentTranWrapper().enlist();
            } catch (ResourceException e) {
                /*
                 * // Can't enlist, something went wrong.
                 * // Destroy the connection(s) so it can't cause any future problems.
                 * try {
                 * mcWrapper.markStale();
                 * mcWrapper.releaseToPoolManager();
                 * }
                 * catch (Exception ex) {
                 * // Nothing to do here. PoolManager has already logged it.
                 * // Since we are in cleanup mode, we will not surface a Runtime exception to the ResourceAdapter
                 * FFDCFilter.processException(ex, "com.ibm.ejs.j2c.ConnectionEventListener.localTransactionStarted", "473", this);
                 * if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                 * Tr.debug(this, tc, "localTransactionStarted: Error when trying to enlist " + mcWrapper.getPoolManager().getPmiName() +
                 * " caught exception, but will continue processing: ", ex);
                 * }
                 * }
                 */

                FFDCFilter.processException(e, "com.ibm.ejs.j2c.ConnectionEventListener.localTransactionStarted", "481", this);
                // add datasource name to message
                Tr.error(tc, "ENLIST_FAILED_J2CA0074", "localTransactionStarted", e, mcWrapper.gConfigProps.cfName);
                // Moved event.getSource() inside of catch block for performance reasons
                ManagedConnection mc = null;
                try {
                    mc = (ManagedConnection) event.getSource();
                } catch (ClassCastException cce) {
                    Tr.error(tc, "GET_SOURCE_CLASS_CAST_EXCP_J2CA0098", cce);
                    throw new IllegalStateException("ClassCastException occurred attempting to cast event.getSource to ManagedConnection");
                }
                ConnectionEvent errorEvent = new ConnectionEvent(mc, ConnectionEvent.CONNECTION_ERROR_OCCURRED);
                this.connectionErrorOccurred(errorEvent);

                RuntimeException rte = new IllegalStateException(e.getMessage());
                throw rte;
            }
        } else {
            // Connection Event passed in doesn't match the method called.
            // This should never happen unless there is an error in the ResourceAdapter.
            processBadEvent("localTransactionStarted", ConnectionEvent.LOCAL_TRANSACTION_STARTED, event);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(this, tc, "localTransactionStarted");
        }
        return;
    }