Examples of XAResourceTransaction


Examples of com.atomikos.datasource.xa.XAResourceTransaction

            throws javax.transaction.RollbackException,
            javax.transaction.SystemException, IllegalStateException
    {
        TransactionalResource res = null;
        XATransactionalResource xatxres = null;
        XAResourceTransaction restx = null;
        Stack errors = new Stack ();

        if ( getStatus () == Status.STATUS_MARKED_ROLLBACK ) {
          String msg =  "Transaction is already marked for rollback - enlisting more resources is useless.";
          LOGGER.logWarning ( msg );
            throw new javax.transaction.RollbackException ( msg );
        }

        // if this xares was suspended then it will still be in the map
        XAResourceTransaction active = findXAResourceTransaction ( xares );

        if ( active != null ) {

            // following violates XA state tables
            // and the invariant of the xaresToTxMap table
            if ( !active.isXaSuspended () ) {
              String msg = "The given XAResource instance is being enlisted a second time without delist in between?";
              LOGGER.logWarning ( msg );
                throw new IllegalStateException ( msg );
            }

            // note: for suspended XAResources, the lookup MUST SUCCEED
            // since the TMRESUME must be called on the SAME XAResource
            // INSTANCE, and lookup also works on the instance level
            try {
                // ADDED: resume should also refresh the xaresource
                active.setXAResource ( xares );
                active.xaResume ();
            } catch ( XAException xaerr ) {
                if ( (XAException.XA_RBBASE <= xaerr.errorCode)
                        && (xaerr.errorCode <= XAException.XA_RBEND) )
                  rethrowAsJtaRollbackException (
                            "Transaction was already rolled back inside the back-end resource. Further enlists are useless." , xaerr );
View Full Code Here

Examples of com.atomikos.datasource.xa.XAResourceTransaction

        if(LOGGER.isInfoEnabled()){
          LOGGER.logInfo( "delistResource ( " + xares + " ) with transaction "
                    + toString ());
        }

        XAResourceTransaction active = findXAResourceTransaction ( xares );
        // NOTE: the lookup MUST have succeeded since the delist must be
        // done by the same XAResource INSTANCE as the enlist before,
        // and lookup also uses instance comparison.
        if ( active == null ) {
          String msg = "Illegal attempt to delist an XAResource instance that was not previously enlisted.";
          LOGGER.logWarning ( msg );
            throw new IllegalStateException ( msg );
        }

        if ( flag == XAResource.TMSUCCESS || flag == XAResource.TMFAIL ) {

            try {
                active.suspend ();
            } catch ( ResourceException re ) {
                errors.push ( re );
                throw new ExtendedSystemException ( "Error in delisting the given XAResource", errors );
            }
            removeXAResourceTransaction ( xares );
            if ( flag == XAResource.TMFAIL ) setRollbackOnly ();

        } else if ( flag == XAResource.TMSUSPEND ) {
            try {
                active.xaSuspend ();
            } catch ( XAException xaerr ) {
                errors.push ( xaerr );
                throw new ExtendedSystemException ( "Error in delisting the given XAResource", errors );
            }
View Full Code Here

Examples of com.atomikos.datasource.xa.XAResourceTransaction

  void suspendEnlistedXaResources() throws ExtendedSystemException
  {
    // cf case 61305
    Iterator xaResourceTransactions = xaresToTxMap_.values().iterator();
    while ( xaResourceTransactions.hasNext() ) {
      XAResourceTransaction resTx = (XAResourceTransaction) xaResourceTransactions.next();
      try {
        resTx.xaSuspend();
      } catch (XAException e) {
        Stack errors = new Stack();
        errors.push ( e );
              throw new ExtendedSystemException ( "Error in delisting the given XAResource", errors );
      }
View Full Code Here

Examples of com.atomikos.datasource.xa.XAResourceTransaction

          if ( LOGGER.isDebugEnabled() ) LOGGER.logDebug ("Calling non-transactional method '" + m.getName() + "' on connection proxy, bypassing enlistment");
          return m.invoke ( wrapped_, args );
        }

        Object ret = null;
        XAResourceTransaction restx = null;
        CompositeTransaction ct = null;
        CompositeTransactionManager ctm = null;
        ctm = Configuration.getCompositeTransactionManager ();
        boolean inTx = false;
        // false if resume should be called (first invocation in tx)

        if ( ctm != null )
            ct = ctm.getCompositeTransaction ();

        inTx = pc_.isInResourceTransaction ();
        if ( ct != null && ct.getProperty TransactionManagerImp.JTA_PROPERTY_NAME ) != null && !pc_.isDiscarded () ) {
            // only enlist if there is a NORMAL tx
            // AND if the pc is not yet discarded (i.e. closed event
            // without a new getConnection() event)
            if ( !inTx ) {
                // not yet enlisted
                // IMPORTANT: we should enlist ONLY ONCE,
                // since we don't have wrappers for each
                // type of dependent object (statements,...)
                // where the real action is
                // Also, for the same reason we can only
                // delist at close time, since that is the
                // earliest detectable moment in time
                // when all these dependent objects are no
                // longer accessible.
                // VITAL ASSERTION FOR THIS TO WORK:
                // after close, the ResourceTransaction association
                // of the pooled connection MUST be null, or the
                // same restx will be reused in different
                // JTA transactions!
                restx = (XAResourceTransaction) resource_
                        .getResourceTransaction ( ct );
                pc_.setResourceTransaction ( restx );
                restx.resume ();
                LOGGER
                        .logDebug ( "JDBC ConnectionProxy: using resource transaction: "
                                + restx.getXid () );

            }

        }
View Full Code Here

Examples of com.atomikos.datasource.xa.XAResourceTransaction

        ConnectionEventListener
{

  protected static void suspendResourceTransaction (
      ResourceTransaction restx ) {
    XAResourceTransaction xarestx = ( XAResourceTransaction ) restx;
    if ( xarestx != null &&
      !xarestx.getState().equals( TxState.TERMINATED )) {
      //check terminated to resolve ISSUE 10102
      xarestx.suspend();
    }
  }
View Full Code Here

Examples of com.atomikos.datasource.xa.XAResourceTransaction

    // MM patch: synchronized to allow threaded access
    private synchronized XAResourceTransaction findXAResourceTransaction (
            XAResource xares )
    {
        XAResourceTransaction ret = null;
        ret = (XAResourceTransaction) xaresToTxMap_.get ( new XAResourceKey (
                xares ) );

        return ret;
    }
View Full Code Here

Examples of com.atomikos.datasource.xa.XAResourceTransaction

            throws javax.transaction.RollbackException,
            javax.transaction.SystemException, IllegalStateException
    {
        TransactionalResource res = null;
        XATransactionalResource xatxres = null;
        XAResourceTransaction restx = null;
        Stack errors = new Stack ();

        if ( getStatus () == Status.STATUS_MARKED_ROLLBACK ) {
          String msg =  "Transaction is already marked for rollback - enlisting more resources is useless.";
          Configuration.logWarning ( msg );
            throw new javax.transaction.RollbackException ( msg );
        }

        Enumeration enumm = Configuration.getResources ();

        while ( enumm.hasMoreElements () ) {
            RecoverableResource rres = (RecoverableResource) enumm
                    .nextElement ();
            if ( rres instanceof XATransactionalResource ) {
                xatxres = (XATransactionalResource) rres;

                if ( xatxres.usesXAResource ( xares ) )
                    res = xatxres;

            }

        }

        printMsg ( "enlistResource ( " + xares + " ) with transaction "
                + toString (), Console.INFO );

        if ( res == null ) {

            if ( autoRegistration_ ) {

                synchronized ( Configuration.class ) {
                  // synchronized to avoid case 61740
                                  
          // ADDED with new recovery: unknown resources can be tolerated
          // by adding a new TemporaryXATransactionalResource
                  res = new TemporaryXATransactionalResource(xares);
                 
                  // cf case 61740: check for concurrent additions before this synch block was entered
                  if ( Configuration.getResource ( res.getName() ) == null ) {
                    printMsg("constructing new temporary resource "
              + "for unknown XAResource: " + xares, Console.DEBUG);
                    Configuration.addResource ( res );
                  }
        }

            } else {
              String msg = "There is no registered resource that can recover the given XAResource instance. " + "\n" +
                "Either enable automatic resource registration, or register a corresponding resource.";
              Configuration.logWarning ( msg );
                throw new javax.transaction.SystemException ( msg );
            }
        }

       
        // if this xares was suspended then it will still be in the map
        XAResourceTransaction active = findXAResourceTransaction ( xares );

        if ( active != null ) {

            // following violates XA state tables
            // and the invariant of the xaresToTxMap table
            if ( !active.isXaSuspended () ) {
              String msg = "The given XAResource instance is being enlisted a second time without delist in between?";
              Configuration.logWarning ( msg );
                throw new IllegalStateException ( msg );
            }

            // note: for suspended XAResources, the lookup MUST SUCCEED
            // since the TMRESUME must be called on the SAME XAResource
            // INSTANCE, and lookup also works on the instance level
            try {
                // ADDED: resume should also refresh the xaresource
                active.setXAResource ( xares );
                active.xaResume ();
            } catch ( XAException xaerr ) {
                if ( (XAException.XA_RBBASE <= xaerr.errorCode)
                        && (xaerr.errorCode <= XAException.XA_RBEND) )
                  rethrowAsJtaRollbackException (
                            "Transaction was already rolled back inside the back-end resource. Further enlists are useless." , xaerr );
View Full Code Here

Examples of com.atomikos.datasource.xa.XAResourceTransaction

          Configuration.logWarning ( msg );
            throw new javax.transaction.SystemException ( msg );
        }

   
        XAResourceTransaction active = findXAResourceTransaction ( xares );

        // NOTE: the lookup MUST have succeeded since the delist must be
        // done by the same XAResource INSTANCE as the enlist before,
        // and lookup also uses instance comparison.
        if ( active == null ) {
          String msg = "Illegal attempt to delist an XAResource instance that was not previously enlisted.";
          Configuration.logWarning ( msg );
            throw new IllegalStateException ( msg );
        }

        if ( flag == XAResource.TMSUCCESS || flag == XAResource.TMFAIL ) {

            try {
                active.suspend ();
            } catch ( ResourceException re ) {
                errors.push ( re );
                throw new ExtendedSystemException ( "Error in delisting the given XAResource", errors );
            }
            removeXAResourceTransaction ( xares );

            // NOTE: if failure, then make sure no rollback can happen
            if ( flag == XAResource.TMFAIL )
                setRollbackOnly ();
        } else if ( flag == XAResource.TMSUSPEND ) {
            // call suspend on active xaresource.

            try {
                active.xaSuspend ();
            } catch ( XAException xaerr ) {
                errors.push ( xaerr );
                throw new ExtendedSystemException ( "Error in delisting the given XAResource", errors );
            }
View Full Code Here

Examples of com.atomikos.datasource.xa.XAResourceTransaction

  void suspendEnlistedXaResources() throws ExtendedSystemException
  {
    // cf case 61305
    Iterator xaResourceTransactions = xaresToTxMap_.values().iterator();
    while ( xaResourceTransactions.hasNext() ) {
      XAResourceTransaction resTx = (XAResourceTransaction) xaResourceTransactions.next();     
      try {
        resTx.xaSuspend();
      } catch (XAException e) {
        Stack errors = new Stack();
        errors.push ( e );
              throw new ExtendedSystemException ( "Error in delisting the given XAResource", errors );
      }
View Full Code Here

Examples of com.atomikos.datasource.xa.XAResourceTransaction

          Configuration.logDebug ("Calling non-transactional method '" + m.getName() + "' on connection proxy, bypassing enlistment");
          return m.invoke ( wrapped_, args );
        }

        Object ret = null;
        XAResourceTransaction restx = null;
        CompositeTransaction ct = null;
        CompositeTransactionManager ctm = null;
        ctm = Configuration.getCompositeTransactionManager ();
        boolean inTx = false;
        // false if resume should be called (first invocation in tx)

        if ( ctm != null )
            ct = ctm.getCompositeTransaction ();

        inTx = pc_.isInResourceTransaction ();
        if ( ct != null && ct.getProperty TransactionManagerImp.JTA_PROPERTY_NAME ) != null && !pc_.isDiscarded () ) {
            // only enlist if there is a NORMAL tx
            // AND if the pc is not yet discarded (i.e. closed event
            // without a new getConnection() event)
            if ( !inTx ) {
                // not yet enlisted
                // IMPORTANT: we should enlist ONLY ONCE,
                // since we don't have wrappers for each
                // type of dependent object (statements,...)
                // where the real action is
                // Also, for the same reason we can only
                // delist at close time, since that is the
                // earliest detectable moment in time
                // when all these dependent objects are no
                // longer accessible.
                // VITAL ASSERTION FOR THIS TO WORK:
                // after close, the ResourceTransaction association
                // of the pooled connection MUST be null, or the
                // same restx will be reused in different
                // JTA transactions!
                restx = (XAResourceTransaction) resource_
                        .getResourceTransaction ( ct );
                pc_.setResourceTransaction ( restx );
                restx.resume ();
                Configuration
                        .logDebug ( "JDBC ConnectionProxy: using resource transaction: "
                                + restx.getXid () );

            }

        }
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.