Examples of TransactionContext


Examples of org.apache.geronimo.transaction.context.TransactionContext

        assertTrue("Expected TransactionContext to report inactive", !transactionContext.isActive());

    }

    public void testGetUnshareableConnectionsInTransaction() throws Exception {
        TransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
        ConnectionInfo connectionInfo1 = makeConnectionInfo();
        connectionInfo1.setUnshareable(true);
        transactionCachingInterceptor.getConnection(connectionInfo1);
        assertTrue("Expected to get an initial connection", obtainedConnectionInfo != null);
        assertTrue("Expected nothing returned yet", returnedConnectionInfo == null);
        assertTrue("Expected different ManagedConnectionInfo in the TransactionContext as was returned",
                connectionInfo1.getManagedConnectionInfo()
                != getSharedManagedConnectionInfo(transactionContext));
        //2nd is shared, modelling a call into another ejb
        obtainedConnectionInfo = null;
        ConnectionInfo connectionInfo2 = makeConnectionInfo();
        transactionCachingInterceptor.getConnection(connectionInfo2);
        assertTrue("Expected to get a second connection", obtainedConnectionInfo != null);
        assertTrue("Expected nothing returned yet", returnedConnectionInfo == null);
        assertTrue("Expected the same ManagedConnectionInfo in both ConnectionInfos",
                connectionInfo1.getManagedConnectionInfo() != connectionInfo2.getManagedConnectionInfo());
        assertTrue("Expected the same ManagedConnectionInfo in the TransactionContext as was returned",
                connectionInfo2.getManagedConnectionInfo() == getSharedManagedConnectionInfo(transactionContext));
        //3rd is unshared, modelling a call into a third ejb
        obtainedConnectionInfo = null;
        ConnectionInfo connectionInfo3 = makeConnectionInfo();
        connectionInfo3.setUnshareable(true);
        transactionCachingInterceptor.getConnection(connectionInfo3);
        assertTrue("Expected to get a third connection", obtainedConnectionInfo != null);
        assertTrue("Expected nothing returned yet", returnedConnectionInfo == null);
        assertTrue("Expected different ManagedConnectionInfo in both unshared ConnectionInfos",
                connectionInfo1.getManagedConnectionInfo() != connectionInfo3.getManagedConnectionInfo());
        assertTrue("Expected different ManagedConnectionInfo in the TransactionContext as was returned",
                connectionInfo3.getManagedConnectionInfo() != getSharedManagedConnectionInfo(transactionContext));
        //commit, see if connection returned.
        //we didn't create any handles, so the "ManagedConnection" should be returned.
        assertTrue("Expected TransactionContext to report active", transactionContext.isActive());
        transactionContext.commit();
        assertTrue("Expected connection to be returned", returnedConnectionInfo != null);
        assertTrue("Expected TransactionContext to report inactive", !transactionContext.isActive());
    }
View Full Code Here

Examples of org.apache.geronimo.transaction.context.TransactionContext

        transactionCachingInterceptor.returnConnection(connectionInfo2, ConnectionReturnAction.RETURN_HANDLE);
        assertTrue("Expected connection to be returned", returnedConnectionInfo != null);
    }

    public void testTransactionIndependence() throws Exception {
        TransactionContext transactionContext1 = transactionContextManager.newContainerTransactionContext();
        ConnectionInfo connectionInfo1 = makeConnectionInfo();
        transactionCachingInterceptor.getConnection(connectionInfo1);
        obtainedConnectionInfo = null;

        //start a second transaction
        transactionContext1.suspend();
        TransactionContext transactionContext2 = transactionContextManager.newContainerTransactionContext();
        ConnectionInfo connectionInfo2 = makeConnectionInfo();
        transactionCachingInterceptor.getConnection(connectionInfo2);
        assertTrue("Expected to get a second connection", obtainedConnectionInfo != null);
        assertTrue("Expected nothing returned yet", returnedConnectionInfo == null);
        assertTrue("Expected different ManagedConnectionInfo in each ConnectionInfos",
                connectionInfo1.getManagedConnectionInfo() != connectionInfo2.getManagedConnectionInfo());
        assertTrue("Expected the same ManagedConnectionInfo in the TransactionContext as was returned",
                connectionInfo2.getManagedConnectionInfo() == getSharedManagedConnectionInfo(transactionContext2));
        //commit 2nd transaction, see if connection returned.
        //we didn't create any handles, so the "ManagedConnection" should be returned.
        assertTrue("Expected TransactionContext to report active", transactionContext2.isActive());
        transactionContext2.commit();
        assertTrue("Expected connection to be returned", returnedConnectionInfo != null);
        assertTrue("Expected TransactionContext to report inactive", !transactionContext2.isActive());
        returnedConnectionInfo = null;
        //resume first transaction
        transactionContext1.resume();
        transactionContext1.commit();
        assertTrue("Expected connection to be returned", returnedConnectionInfo != null);
View Full Code Here

Examples of org.apache.geronimo.transaction.context.TransactionContext

        startLatch.release();
        //Implementation note: we assume this is being called without an interesting TransactionContext,
        //and ignore/replace whatever is associated with the current thread.
        try {
            if (executionContext == null || executionContext.getXid() == null) {
                TransactionContext context = transactionContextManager.newUnspecifiedTransactionContext();
                try {
                    adaptee.run();
                } finally {
                    TransactionContext returningContext = transactionContextManager.getContext();
                    transactionContextManager.setContext(null);
                    if (context != returningContext) {
                        throw new WorkCompletedException("Wrong TransactionContext on return from work done");
                    }
                }
View Full Code Here

Examples of org.apache.jackrabbit.data.core.TransactionContext

    public void start(Xid xid, int flags) throws XAException {
        if (isAssociated()) {
            log.error("Resource already associated with a transaction.");
            throw new XAException(XAException.XAER_PROTO);
        }
        TransactionContext tx = txGlobal.get(xid);
        if (flags == TMNOFLAGS) {
            if (tx != null) {
                throw new XAException(XAException.XAER_DUPID);
            }
            tx = createTransaction(xid);
        } else if (flags == TMJOIN) {
            if (tx == null) {
                throw new XAException(XAException.XAER_NOTA);
            }
        } else if (flags == TMRESUME) {
            if (tx == null) {
                throw new XAException(XAException.XAER_NOTA);
            }
            if (!tx.isSuspended()) {
                log.error("Unable to resume: transaction not suspended.");
                throw new XAException(XAException.XAER_PROTO);
            }
            tx.setSuspended(false);
        } else {
            throw new XAException(XAException.XAER_INVAL);
        }

        associate(tx);
View Full Code Here

Examples of org.apache.openejb.cdi.transactional.TransactionContext

            } else {
                webBeansContext = new WebappWebBeansContext(services, properties, appContext.getWebBeansContext());
                startupObject.getWebContext().setWebbeansContext(webBeansContext);
            }
            final BeanManagerImpl beanManagerImpl = webBeansContext.getBeanManagerImpl();
            beanManagerImpl.addContext(new TransactionContext());
            beanManagerImpl.addAdditionalInterceptorBindings(Transactional.class);

            SystemInstance.get().fireEvent(new WebBeansContextCreated(webBeansContext));
            OpenEJBTransactionService.class.cast(services.get(TransactionService.class)).setWebBeansContext(webBeansContext);
View Full Code Here

Examples of org.apache.openejb.core.transaction.TransactionContext

        mdbCallContext.deliveryMethod = method;
        mdbCallContext.oldCallContext = oldContext;

        // add tx data
        mdbCallContext.txPolicy = deployInfo.getTransactionPolicy(method);
        mdbCallContext.txContext = new TransactionContext(callContext, transactionManager);

        // call the tx before method
        try {
            boolean adapterTransaction = transactionManager.getTransaction() != null;
            mdbCallContext.txPolicy.beforeInvoke(instance, mdbCallContext.txContext);
View Full Code Here

Examples of org.camunda.bpm.engine.impl.cfg.TransactionContext

              entityManager.getTransaction().rollback();
            }
          }
        };

        TransactionContext transactionContext = Context.getCommandContext().getTransactionContext();
        transactionContext.addTransactionListener(TransactionState.COMMITTED, jpaTransactionCommitListener);
        transactionContext.addTransactionListener(TransactionState.ROLLED_BACK, jpaTransactionRollbackListener);

        // Also, start a transaction, if one isn't started already
        if (!isTransactionActive()) {
          entityManager.getTransaction().begin();
        }
View Full Code Here

Examples of org.castor.persist.TransactionContext

            throw new PersistenceException("Identities can't be null!");
        }
        if (_scope == null) {
            throw new PersistenceException(Messages.message("jdo.dbClosed"));
        }
        TransactionContext tx = getTransaction();
        ClassMolder molder = _scope.getClassMolder(type);
        ProposedEntity proposedObject = new ProposedEntity(molder);
        return tx.load(new Identity(identity), proposedObject, mode);
    }
View Full Code Here

Examples of org.exolab.castor.persist.TransactionContext

        _dbEngine = _dbImpl.getLockEngine();
        if ( _dbEngine == null )
            throw new QueryException( "Could not get a persistence engine" );

      TransactionContext trans = _dbImpl.getTransaction();
      DbMetaInfo dbInfo = trans.getConnectionInfo(_dbEngine);

      ParseTreeWalker walker = new ParseTreeWalker(_dbEngine, parseTree, _dbImpl.getClassLoader(), dbInfo);

        _objClass = walker.getObjClass();
        _clsDesc = walker.getClassDescriptor();
View Full Code Here

Examples of org.hibernate.engine.transaction.spi.TransactionContext

  @Override
  protected void beforeTransactionCommit() {
    final TransactionCoordinator coordinator = transactionCoordinator();
    coordinator.sendBeforeTransactionCompletionNotifications( this );
    final TransactionContext transactionContext = coordinator.getTransactionContext();

    final boolean flush = ! transactionContext.isFlushModeNever() &&
        ( isDriver || ! transactionContext.isFlushBeforeCompletionEnabled() );

    if ( flush ) {
      // if an exception occurs during flush, user must call rollback()
      transactionContext.managedFlush();
    }

    if ( isDriver && isInitiator ) {
      transactionContext.beforeTransactionCompletion( this );
    }

    closeIfRequired();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.