Package com.sun.enterprise

Examples of com.sun.enterprise.J2EETransactionManager


        // can use this method.
        if ( container.isBeanManagedTx() )
            throw new IllegalStateException(
                "Illegal operation for bean-managed transactions");
       
        J2EETransactionManager tm = Switch.getSwitch().getTransactionManager();
       
        try {
            if ( tm.getStatus() == Status.STATUS_NO_TRANSACTION ) {
                // EJB might be in a non-business method (for SessionBeans)
                // or afterCompletion.
                // OR this was a NotSupported/Never/Supports
                // EJB which was invoked without a global transaction.
                // In that case the JDBC connection would have autoCommit=true
                // so the container doesnt have to do anything.
                throw new IllegalStateException("No transaction context.");
            }
           
            ComponentInvocation compInv = container.invocationManager.getCurrentInvocation();
            checkActivatePassivate(compInv);

            if (compInv instanceof Invocation) {
                Invocation inv = (Invocation) compInv;
                if (inv.invocationInfo != null) {
                    switch (inv.invocationInfo.txAttr) {
                        case Container.TX_NOT_SUPPORTED:
                        case Container.TX_SUPPORTS:
                        case Container.TX_NEVER:
                            throw new IllegalStateException("setRollbackOnly() not allowed from this method");
                    }
                }
            }
           
            tm.setRollbackOnly();
        } catch (IllegalStateException illegalEx) {
            throw illegalEx;
        } catch (Exception ex) {
            IllegalStateException illEx = new IllegalStateException(ex.toString());
            illEx.initCause(ex);
View Full Code Here


        // can use this method.
        if ( container.isBeanManagedTx() )
            throw new IllegalStateException(
                "Illegal operation for bean-managed transactions");
       
        J2EETransactionManager tm = Switch.getSwitch().getTransactionManager();
       
        try {
            int status = tm.getStatus();
            if ( status == Status.STATUS_NO_TRANSACTION ) {
                // EJB which was invoked without a global transaction.
                throw new IllegalStateException("No transaction context.");
            }
           
View Full Code Here

            Switch.getSwitch().getTransactionManager();
      if ( tm != null )
    tm.checkTransactionExport();
  }
  **/
  J2EETransactionManager tm = Switch.getSwitch().getTransactionManager();
  if ( tm != null )
      tm.checkTransactionImport();
    }
View Full Code Here

    public void lazyEnlist( ManagedConnection mc ) throws ResourceException {
        if ( _logger.isLoggable(Level.FINE) ) {
            _logger.fine("Entering lazyEnlist");
        }

        J2EETransactionManager tm = Switch.getSwitch().getTransactionManager();
                       
        Transaction tran = null;
       
        try {
            tran = tm.getTransaction();
            if ( tran == null ) {
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.fine(" Transaction null - not enlisting ");
                }

                return;
            }
        } catch( SystemException se ) {
            ResourceException re = new ResourceException( se.getMessage() );
            re.initCause( se );
            throw re;
        }

        List invList = Switch.getSwitch().getInvocationManager().getAllInvocations();

        ResourceHandle h = null;
        for ( int j = invList.size(); j > 0; j-- ) {
            ComponentInvocation inv = (ComponentInvocation) invList.get( j - 1 );
            Object comp = inv.getInstance();

            List l = ((J2EETransactionManagerImpl)tm).getResourceList( comp, inv );
           
            ListIterator it = l.listIterator();
            while( it.hasNext()) {
                ResourceHandle hand = (ResourceHandle) it.next();
                ManagedConnection toEnlist = (ManagedConnection) hand.getResource();
                if ( mc.equals( toEnlist ) ) {
                    h = hand;
                    break;
                }
            }
        }
       
        //NOTE: Notice that here we are always assuming that the connection we
        //are trying to enlist was acquired in this component only. This
        //might be inadequate in situations where component A acquires a connection
        //and passes it on to a method of component B, and the lazyEnlist is
        //triggered in B
        //At this point however, we will only support the straight and narrow
        //case where a connection is acquired and then used in the same component.
        //The other case might or might not work
        if( h != null && h.getResourceState().isUnenlisted()) {
            try {
                //Enable the suspended lazyenlistment so as to enlist the resource.
                    h.setEnlistmentSuspended(false);
                    tm.enlistResource( tran, h );
                //Suspend it back
                    h.setEnlistmentSuspended(true);
            } catch( Exception e ) {
                //In the rare cases where enlistResource throws exception, we
              //should return the resource to the pool
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();
            }
View Full Code Here

           
        } else { //the rest are considered methods for message delivery
           
            //RA did not call beforeDelivery, handle it here
            if (!beforeDeliveryCalled) {
                J2EETransactionManager txManager =
                    Switch.getSwitch().getTransactionManager();
                boolean txImported = (txManager.getTransaction() != null);
                listener_.beforeMessageDelivery(method, txImported);
            }
           
            try {
                //returnValue = listener_.deliverMessage(method, args);
View Full Code Here

  // the ORBManager
  PEORBConfigurator.initTransactionService(null, new Properties() );
 
  /* Create the transaction manager and set it in the switch. */
  // J2EETransactionManager tm = new J2EETransactionManagerImpl();
  J2EETransactionManager tm =
    J2EETransactionManagerImpl.createTransactionManager();
  sw.setTransactionManager(tm);

        // Create the Injection Manager and set it on the switch.
        InjectionManager injectionMgr = new InjectionManagerImpl();
View Full Code Here

                new WorkEvent(this, WorkEvent.WORK_STARTED, work, null));
        }


        try {
            J2EETransactionManager tm = Switch.getSwitch().getTransactionManager();
            if (ec != null && ec.getXid() != null) {
                tm.recreate(ec.getXid(), ec.getTransactionTimeout());
            }
        } catch(WorkException we) {
            this.exception = we;
        } catch(Exception e) {
            setException(e);
View Full Code Here

     * </pre>
     */
    public void postInvoke() {
        boolean txImported = (ec != null && ec.getXid() != null);
        try {
            J2EETransactionManager tm = Switch.getSwitch().getTransactionManager();
            if (txImported) {
                tm.release(ec.getXid());
            }
        } catch (WorkException ex) {
            setException(ex);
        } finally {
            try {
                if(workStats != null) {
                    workStats.setActiveWorkCount
                                (--workStats.currentActiveWorkCount);
                    workStats.completedWorkCount++;
                }
               
                //If exception is not null, the work has already been rejected.
                if (listener != null) {
                    if (!isTimedOut()) {
                        listener.workCompleted(
                            new WorkEvent(this, WorkEvent.WORK_COMPLETED, work,
                                            getException()));
                    }
                }

                //Also release the TX from the record of TX Optimizer
                if (txImported) {
                    J2EETransactionManager tm =
                    Switch.getSwitch().getTransactionManager();
                    if (tm instanceof J2EETransactionManagerOpt) {
                        ((J2EETransactionManagerOpt) tm).clearThreadTx();
                    }
                }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.J2EETransactionManager

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.