Adds a TransactionManager

@param transactionManager the transaction manager or {@code null}.
354746
void addTransactionManager(TransactionManager transactionManager) {
		if (transactionManager == null) return;
		this.transactionManagers.add(new TransactionManagerDefinition(transactionManager.name()));
	}
759585
public function beginTransaction() {
		if ($this->transactionManager === null) {
			$this->performBeginTransaction();
			return;
		}
		
		if (!$this->transactionManager->hasOpenTransaction()) {
			$this->transactionManager->createTransaction();
		}
	}
447753
protected synchronized void add(ManagedObject managedObject,
                                    Transaction transaction,
                                    long logSpaceReservedDelta)
                    throws ObjectManagerException
    {
        throw new InvalidStateException(this, InternalTransaction.stateTerminated, InternalTransaction.stateNames[InternalTransaction.stateTerminated]);
    }
945922
public function addModifier(TransactionModifierInterface $modifier)
    {
        $this->modifiers[$modifier->getIdentifier()->getFull()] = $modifier;

        if ($modifier instanceof HasTransactionInterface) {
            $modifier->setTransaction($this);
        }
    }
1128489
@Override
    public void commit()
    {
        if (!getRollbackOnly())
        {
            onTransaction(TxAction.COMMIT);
            ((EntityManagerImpl) entityManager).getPersistenceDelegator().commit();
        }
    }
1113396
public static void setTransactionTime(Date transactionTime) {
        if (transactionTime == null) {
            String msg = "The argument 'transactionTime' should not be null.";
            throw new IllegalArgumentException(msg);
        }
        Stack<Date> stack = threadLocal.get();
        if (stack == null) {
            stack = new Stack<Date>();
            threadLocal.set(stack);
        }
        stack.push(transactionTime);
    }
817418
@Override
    public EntityManager createEntityManager()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "createEntityManager : " + this);

        EntityManager em = getEntityManager(false, false);
        JPAPooledEntityManager pem = new JPAPooledEntityManager(this, em, ivAbstractJpaComponent, true);
        return pem;
    }
279023
public PlatformTransactionManager getPlatformTransactionManager() {
        if (transactionManager != null) {
            return transactionManager;
        }
        transactionManager = (PlatformTransactionManager) ContainerManager.getComponent("transactionManager");
        return transactionManager;
    }
203220
public void reconstitute(BaseDestinationHandler destinationHandler,
                           SIMPTransactionManager txManager)
    throws MessageStoreException
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "reconstitute", new Object[] {destinationHandler, txManager}); 
      
    initializeNonPersistent(destinationHandler, txManager);
        
    if (tc.isEntryEnabled())
      SibTr.exit(tc, "reconstitute");           
  }
310964
public List.Entry addEntry(Token token,
                               Transaction transaction)
                    throws ObjectManagerException
    {
        final String methodName = "addEntry";
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass, methodName, new Object[] { token,
                                                                transaction });

        // This differs from the default ObjectManager
        // behaviour because we optimistically add the link to the list and may need to 
        // undo this if the transaction backs out. Simply restoring before immages is not
        // enough because we dont lock the list during the prepare phase and other links
        // could be chanied off this one and commit their trandsactions before
        // this one.

        Link newLink = null;
        // Take a lock on transaction then the list itself, this protects the structure of the list 
        // and prevents deadlock with threads backing out the transaction. During backout the list 
        // lock is traven in the preBackout call back after the transaction lock has been taken. 
        synchronized (transaction.internalTransaction) {
            synchronized (this) {
                // Prevent other transactions using the list until its creation is commited.
                if (!(state == stateReady)
                    && !((state == stateAdded) && lockedBy(transaction))) {

                    if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                        trace.exit(this, cclass, methodName, new Object[] { new Integer(state),
                                                                           stateNames[state] });
                    throw new InvalidStateException(this, state, stateNames[state]);
                }

                // All optimistic replace updates to links in the list must be made
                // together, so we construct a single log record for all of them. 
                managedObjectsToAdd.clear();
                managedObjectsToReplace.clear();
                reservedSpaceInStore = storeSpaceForAdd();
                owningToken.objectStore.reserve((int) reservedSpaceInStore, false);

                // Create the new link and add it to its object store.
                newLink = new Link(this,
                                   token,
                                   tail,
                                   null,
                                   transaction);
                managedObjectsToAdd.add(newLink);

                // Chain the new Link in the list. If the transaction backs
                // out we will rewrite the links to remove the new one.
                if (head == null) // Only element in the list?
                {
                    head = newLink.getToken();
                    availableHead = head; // PK75215
                } else { // In the body of the list.
                    Link tailLink = (Link) tail.getManagedObject();
                    tailLink.next = newLink.getToken();
                    managedObjectsToReplace.add(tailLink);
                }
                tail = newLink.getToken();

                incrementSize(); // Adjust list length assuming we will commit.
                managedObjectsToReplace.add(this); // The anchor for the list.

                // Harden the updates. If the update fails, because the log is full,
                // we have affected the structure of the list so we will have to 
                // reverse the changes. Reserve enough space to reverse the update if the
                // transaction backs out.
                // TODO We need another optimistic replace with a more restricted state machine, this one
                // will allow an add after we have done prepare.
                try {
                    transaction.optimisticReplace(managedObjectsToAdd,
                                                  managedObjectsToReplace,
                                                  null, // No tokens to delete.
                                                  null, // No tokens to notify.
                                                  +logSpaceForDelete());
                    // Give up reserved space, but keep back enough to remove the entry if we have to.
                    owningToken.objectStore.reserve((int) (storeSpaceForRemove() - reservedSpaceInStore), false);

                } catch (InvalidStateException exception) {
                    // No FFDC Code Needed, user error.
                    // Remove the link we just added.
                    undoAdd(newLink);

                    if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                        trace.exit(this, cclass, methodName, exception);
                    throw exception;

                } catch (LogFileFullException exception) {
                    // No FFDC Code Needed, InternalTransaction has already done this.
                    // Remove the link we just added.
                    undoAdd(newLink);

                    if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                        trace.exit(this, cclass, methodName, exception);
                    throw exception;

                    // We should not see ObjectStoreFullException because we have preReserved 
                    // the ObjectStore space.
//        } catch (ObjectStoreFullException exception) {
//          // No FFDC Code Needed, InternalTransaction has already done this.
//          // Remove the link we just added.
//          undoAdd(newLink);
//          
//          if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
//            trace.exit(this, cclass, methodName, exception);
//          throw exception;
                } // try.

            } // synchronized (this).
        } // synchronized (transaction.internalTransaction)

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass, methodName, new Object[] { newLink });
        return (List.Entry) newLink;
    }
856370
private static TransactionManager getTransactionManagerFromCache(WorkspaceStorageCache cache)
   {
      try
      {
         return (TransactionManager)cache.getClass().getMethod("getTransactionManager", (Class<?>[])null)
            .invoke(cache, (Object[])null);
      }
      catch (Exception e)
      {
         LOG.debug("Could not get the transaction manager from the cache", e);
      }
      return null;
   }
360860
public static void rollbackQuietly(EntityManager entityManager) {
        if (entityManager.getTransaction().isActive()/* && entityManager.getTransaction().getRollbackOnly()*/) {
            try {
                entityManager.getTransaction().rollback();
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
        }
    }
664373
public void commitTransaction() throws MarkLogicTransactionException {
		if (isActiveTransaction()) {
			try {
				sync();
				this.tx.commit();
				this.tx=null;
			} catch (MarkLogicSesameException e) {
				logger.error(e.getLocalizedMessage());
				throw new MarkLogicTransactionException(e);
			}
		}else{
			throw new MarkLogicTransactionException("No active transaction to commit.");
		}
	}
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);
			}
		}
	}
368473
void rollback(long fromTransactionId) {
        long traceId = LoggerHelpers.traceEnterWithContext(log, this.traceObjectId, "rollback", fromTransactionId);
        List<Long> rolledBack = new ArrayList<>();
        while (!this.transactions.isEmpty() && this.transactions.peekLast().getTransactionId() >= fromTransactionId) {
            ContainerMetadataUpdateTransaction txn = this.transactions.removeLast();
            txn.seal();
            rolledBack.add(txn.getTransactionId());
        }

        // At this point, the transaction list is either empty or its last one is sealed; any further changes would
        // require creating a new transaction.
        LoggerHelpers.traceLeave(log, this.traceObjectId, "rollback", traceId, rolledBack);
    }
666309
@Override
	public void setTransactionTimeout(int seconds) throws TransactionManagementException {
		logger.entering(CLASSNAME, "setTransactionTimeout", seconds);
		logger.fine("do nothing");
		logger.exiting(CLASSNAME, "setTransactionTimeout");
	}
186992
public void addCommitAction(final Runnable action) throws HibernateException
	{
		if (action == null)
			return; // ignore null actions

		addAction(new BaseSessionEventListener()
		{
			@Override
			public void transactionCompletion(final boolean successful)
			{
				if (successful)
					action.run();
			}
		});
	}