Package com.sun.enterprise.distributedtx

Examples of com.sun.enterprise.distributedtx.J2EETransaction$J2EEXid


        EntityContextImpl context = (EntityContextImpl) ctx;
        EJBLocalObjectImpl ejbLocalObjectImpl =
            internalGetEJBLocalObjectImpl(pkey);

        if (context.isCascadeDeleteBeforeEJBRemove()) {
            J2EETransaction current = null;
            try {
                current = (J2EETransaction) transactionManager.getTransaction();
            } catch ( SystemException ex ) {
                throw new EJBException(ex);
            }
      ActiveTxCache activeTxCache = (current == null) ? null :
    (ActiveTxCache) (current.getActiveTxCache());
            if (activeTxCache != null) {
    EntityContextImpl ctx2 = (EntityContextImpl)
      activeTxCache.get(this, pkey);
    if ((ctx2 != null) &&
        (ctx2.isCascadeDeleteAfterSuperEJBRemove())) {
View Full Code Here


        // invocations with same primary key and same client tx
        // get the SAME EJB instance.
        // So we need to maintain exactly one copy of an EJB's state
        // per transaction.
       
        J2EETransaction current = null;
        try {
            current = (J2EETransaction) transactionManager.getTransaction();
        } catch ( SystemException ex ) {
            throw new EJBException(ex);
        }
       
        EntityContextImpl ctx = null;
  if (current != null) {
      ActiveTxCache activeTxCache = (ActiveTxCache)
    current.getActiveTxCache();
      ctx = (activeTxCache == null)
        ? null : activeTxCache.get(this, inv.ejbObject.getKey());
        inv.foundInTxCache = (ctx != null);
  }
 
View Full Code Here

     * This EJB is invoked either with client's tx (in which case
     * it would already be in table), or with new tx (in which case
     * it would not be in table).
     */
    private void addIncompleteTxEJB(EntityContextImpl context) {
        J2EETransaction current = (J2EETransaction) context.getTransaction();
        if ( current == null ) {
            return;
        }
        if ( (context.getEJBObjectImpl() == null) &&
             (context.getEJBLocalObjectImpl() == null) ) {
            return;
        }

        // Its ok to add this context without checking if its already there.
  ActiveTxCache activeTxCache = (ActiveTxCache) current.getActiveTxCache();
  if (activeTxCache == null) {
      activeTxCache = new ActiveTxCache(DEFAULT_TX_CACHE_BUCKETS);
      current.setActiveTxCache(activeTxCache);
  }

  activeTxCache.add(context);
       
        Vector beans = containerFactory.getBeans(current);
View Full Code Here

     * and from passivateEJB.
     */
    protected void removeIncompleteTxEJB(EntityContextImpl context,
                                         boolean updateTxBeanTable)
    {
        J2EETransaction current = (J2EETransaction) context.getTransaction();

        if (current == null) {
            return;
        }
        if ( (context.getEJBObjectImpl() == null) &&
View Full Code Here

        }
    }
   
    protected void enlistExtendedEntityManagers(ComponentContext ctx) {
        if (isStatefulSession && (ctx.getTransaction() != null)) {
            J2EETransaction j2eeTx = (J2EETransaction) ctx.getTransaction();
            SessionContextImpl sessionCtx = (SessionContextImpl) ctx;
            Map<EntityManagerFactory, EntityManager> entityManagerMap =
                sessionCtx.getExtendedEntityManagerMap();
                   
            for (Map.Entry<EntityManagerFactory, EntityManager> entry :
                     entityManagerMap.entrySet()) {
                EntityManagerFactory emf = entry.getKey();
                EntityManager extendedEm = entry.getValue();

                EntityManager extendedEmAssociatedWithTx =
                    j2eeTx.getExtendedEntityManager(emf);

                // If there's not already an EntityManager registered for
                // this extended EntityManagerFactory within the current tx
                if (extendedEmAssociatedWithTx == null) {
                    j2eeTx.addExtendedEntityManagerMapping(emf,
                                                           extendedEm);
                    sessionCtx.setEmfRegisteredWithTx(emf, true);

                    // Tell persistence provider to associate the extended
                    // entity manager with the transaction.
View Full Code Here

                if (isStatefulSession
                        && (((EJBContextImpl) inv.context).getTransaction() != null)) {

                    SessionContextImpl sessionCtx = (SessionContextImpl) inv.context;
                    J2EETransaction j2eeTx = (J2EETransaction) sessionCtx
                            .getTransaction();

                    Map<EntityManagerFactory, EntityManager> entityManagerMap = sessionCtx
                            .getExtendedEntityManagerMap();
                    for (EntityManagerFactory emf : entityManagerMap.keySet()) {

                        if (sessionCtx.isEmfRegisteredWithTx(emf)) {
                            j2eeTx.removeExtendedEntityManagerMapping(emf);
                            sessionCtx.setEmfRegisteredWithTx(emf, false);
                        }
                    }
                }
            } else {
View Full Code Here

            SessionContextImpl sessionCtx = (SessionContextImpl) inv.context;
            Map<EntityManagerFactory, EntityManager> entityManagerMap =
                sessionCtx.getExtendedEntityManagerMap();

            J2EETransaction clientJ2EETx = (J2EETransaction) clientTx;
            for(EntityManagerFactory emf : entityManagerMap.keySet()) {

                // Make sure there is no Transactional persistence context
                // for the same EntityManagerFactory as this SFSB's
                // Extended persistence context for the propagated transaction.
                if( clientJ2EETx.getTxEntityManager(emf) != null ) {
                    throw new EJBException("There is an active transactional persistence context for the same EntityManagerFactory as the current stateful session bean's extended persistence context");
                }

                // Now see if there's already a *different* extended
                // persistence context within this transaction for the
                // same EntityManagerFactory.
                EntityManager em = clientJ2EETx.getExtendedEntityManager(emf);
                if( (em != null) && entityManagerMap.get(emf) != em ) {
                    throw new EJBException("Detected two different extended persistence contexts for the same EntityManagerFactory within a transaction");
                }

            }
View Full Code Here

        if( entityManagerFactory == null ) {
            init();
        }

        J2EETransaction tx = null;
        try {
            tx = (J2EETransaction) txManager.getTransaction();
        } catch(Exception e) {
            throw new IllegalStateException("exception retrieving tx", e);
        }
View Full Code Here

            cleanupNonTxEntityManager();
        }

        if( contextType == PersistenceContextType.TRANSACTION ) {

            J2EETransaction tx = null;
            try {
                tx = (J2EETransaction) 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

    private ResourceHandle getResourceHandle() throws PoolingException {
        try {
            ResourceHandle h = null;
            J2EETransactionManager txMgr = Switch.getSwitch().getTransactionManager();
            J2EETransaction j2eetran = (J2EETransaction) txMgr.getTransaction();
            if (j2eetran == null) {      //Only if some thing is wrong with tx manager.
                h = localHandle_;        //Just return the local handle.
            } else {
                h = j2eetran.getNonXAResource();
            }
            if (h.getResourceState().isUnenlisted()) {
                ManagedConnection mc = (ManagedConnection) h.getResource();
                // begin the local transaction if first time
                // this ManagedConnection is used in this JTA transaction
View Full Code Here

TOP

Related Classes of com.sun.enterprise.distributedtx.J2EETransaction$J2EEXid

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.