Package com.sun.enterprise.transaction.api

Examples of com.sun.enterprise.transaction.api.JavaEETransaction


       
        return txData.activeTxCache;
    }

    public void setActiveTxCache(Transaction jtx, Object cache) {
      JavaEETransaction tx = (JavaEETransaction) jtx;
        TxData txData = getTxData(tx);
       
        txData.activeTxCache = cache;
    }
View Full Code Here


            cleanupNonTxEntityManager();
        }

        if( contextType == PersistenceContextType.TRANSACTION ) {

            JavaEETransaction tx = null;
            try {
                tx = (JavaEETransaction) txManager.getTransaction();
            } catch(Exception e) {
                throw new IllegalStateException("exception retrieving tx", e);
            }
           
            if( tx != null ) {

                // If there is an active extended persistence context
                // for the same entity manager factory and the same tx,
                // it takes precendence.
                delegate = tx.getExtendedEntityManager(entityManagerFactory);

                if( delegate == null ) {

                    delegate = tx.getTxEntityManager(entityManagerFactory);

                    if( delegate == null ) {

                        // If there is a transaction and this is the first
                        // access of the wrapped entity manager, create an
                        // actual entity manager and associate it with the
                        // entity manager factory.
                        delegate = entityManagerFactory.
                            createEntityManager(emProperties);

                        tx.addTxEntityManagerMapping(entityManagerFactory,
                                                     delegate);
                    }
                }

            } else {
View Full Code Here

        EntityManager delegate;

        if( contextType == PersistenceContextType.TRANSACTION ) {

            JavaEETransaction tx = getCurrentTransaction();

            if( tx != null ) {

                // If there is an active extended persistence context
                // for the same entity manager factory and the same tx,
                // it takes precedence.
                PhysicalEntityManagerWrapper propagatedPersistenceContext = getExtendedEntityManager(tx, entityManagerFactory);
                if(propagatedPersistenceContext == null) {

                    propagatedPersistenceContext = getTxEntityManager(tx, entityManagerFactory);


                    if( propagatedPersistenceContext == null ) {

                        // If there is a transaction and this is the first
                        // access of the wrapped entity manager, create an
                        // actual entity manager and associate it with the
                        // entity manager factory.
                        EntityManager em = entityManagerFactory.createEntityManager(synchronizationType, emProperties);
                        propagatedPersistenceContext = new PhysicalEntityManagerWrapper(em, synchronizationType);
                        tx.addTxEntityManagerMapping(entityManagerFactory, propagatedPersistenceContext);
                    } else {

                        //Check if sync type of current persistence context is compatible with persistence context being propagated
                        if(synchronizationType == SYNCHRONIZED && propagatedPersistenceContext.getSynchronizationType() == UNSYNCHRONIZED) {
                            throw new IllegalStateException("Detected an UNSYNCHRONIZED  persistence context being propagated to SYNCHRONIZED persistence context.");
View Full Code Here

    private void forceTransactionCompletion(XAResource xares) throws SystemException {
        if(transactionCompletionMode != null){
            if(xares instanceof ConnectorXAResource){
                ConnectorXAResource connectorXARes = (ConnectorXAResource)xares;
                JavaEETransaction j2eetran = connectorXARes.getAssociatedTransaction();
                if(j2eetran != null && j2eetran.isLocalTx()){
                    if(j2eetran.getStatus() == (Status.STATUS_ACTIVE)){
                        try{
                            if(transactionCompletionMode.equalsIgnoreCase(COMMIT)){
                                if(_logger.isLoggable(Level.FINEST)){
                                    _logger.log(Level.FINEST,"Transaction Completion Mode for LocalTx resource is " +
                                            "set as COMMIT, committing transaction");
                                }
                                j2eetran.commit();
                            }else if(transactionCompletionMode.equalsIgnoreCase(ROLLBACK)){
                                if(_logger.isLoggable(Level.FINEST)){
                                    _logger.log(Level.FINEST,"Transaction Completion Mode for LocalTx resource is " +
                                        "set as ROLLBACK, rolling back transaction");
                                }
                                j2eetran.rollback();
                            }else{
                                _logger.log(Level.WARNING,"Unknown transaction completion mode, no action made");
                            }
                        }catch(Exception e){
                            _logger.log(Level.WARNING, "Failure while forcibily completing an incomplete, " +
View Full Code Here

    }

    private ResourceHandle getResourceHandle() throws PoolingException {
        try {
            ResourceHandle h = null;
            JavaEETransaction j2eetran = getCurrentTransaction();
            if (j2eetran == null) {      //Only if some thing is wrong with tx manager.
                h = localHandle_;        //Just return the local handle.
            } else {
                h = (ResourceHandle)j2eetran.getNonXAResource();
            //make sure that if local-tx resource is set as 'unshareable', only one resource
            //can be acquired. If the resource in question is not the one in transaction, fail
            if(!localHandle_.isShareable()){
                   if(h != localHandle_){
                        throw new ResourceAllocationException("Cannot use more than one local-tx resource in unshareable scope");
View Full Code Here

            throws IllegalStateException {
        ResourceHandle res = (ResourceHandle) h;

        PoolInfo poolInfo = res.getResourceSpec().getPoolInfo();
        try {
            JavaEETransaction j2eeTran = (JavaEETransaction) tran;
            if (poolInfo != null && j2eeTran.getResources(poolInfo) == null) {
                addSyncListener(tran);
            }
        } catch (ClassCastException e) {
            addSyncListener(tran);
        }
View Full Code Here

        long remainingWaitTime = 0;

        while (true) {
            if (gateway.allowed()) {
                //See comment #1 above
                JavaEETransaction jtx = ((JavaEETransaction) txn);
                Set resourcesSet = null;
                if(jtx != null){
                  resourcesSet = jtx.getResources(poolInfo);
            }
                //allow when the pool is not blocked or at-least one resource is
                //already obtained in the current transaction.
                if (!blocked || (resourcesSet != null && resourcesSet.size() > 0)) {
                    try {
View Full Code Here

        try {
            //comment-1: sharing is possible only if caller is marked
            //shareable, so abort right here if that's not the case
            if (tran != null && alloc.shareableWithinComponent()) {
                //TODO should be handled by PoolTxHelper
                JavaEETransaction j2eetran = (JavaEETransaction) tran;
                // case 1. look for free and enlisted in same tx
                Set set = j2eetran.getResources(poolInfo);
                if (set != null) {
                    Iterator iter = set.iterator();
                    while (iter.hasNext()) {
                        ResourceHandle h = (ResourceHandle) iter.next();
                        if (h.hasConnectionErrorOccurred()) {
View Full Code Here

     *
     * @param h ResourceHandle to be delisted
     * @throws javax.transaction.SystemException when not able to delist the resource
     */
    private void enforceDelistment(ResourceHandle h) throws SystemException {
        JavaEETransaction txn = (JavaEETransaction) ConnectorRuntime.getRuntime().getTransaction();
        if (txn != null) {
            Set set = txn.getResources(poolInfo);
            if (set != null)
                set.remove(h);
        }
    }
View Full Code Here

     * @return true if a local transaction is in progress.
     */
    public boolean isLocalTransactionInProgress() {
        boolean result = false;
        try {
            JavaEETransaction txn = (JavaEETransaction) ConnectorRuntime.getRuntime().getTransaction();
            if(txn != null) {
                result = txn.isLocalTx();
            }
        } catch (SystemException e) {
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "Exception while checking whether a local "
                        + "transaction is in progress while using pool : " + poolInfo, e);
View Full Code Here

TOP

Related Classes of com.sun.enterprise.transaction.api.JavaEETransaction

Copyright © 2018 www.massapicom. 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.