Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors 
   * as indicated by the @author tags. 
   * See the copyright.txt in the distribution for a
   * full listing of individual contributors. 
   * This copyrighted material is made available to anyone wishing to use,
   * modify, copy, or redistribute it subject to the terms and conditions
   * of the GNU Lesser General Public License, v. 2.1.
  * This program is distributed in the hope that it will be useful, but WITHOUT A 
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
  * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  * You should have received a copy of the GNU Lesser General Public License,
  * v.2.1 along with this distribution; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
  * MA  02110-1301, USA.
  * 
  * (C) 2005-2006,
  * @author JBoss Inc.
  */
 /*
  * Copyright (C) 2004,
  * 
  * Arjuna Technologies Ltd, Newcastle upon Tyne, Tyne and Wear, UK.
  * 
  * $Id: XAResourceErrorHandler.java 2342 2006-03-30 13:06:17Z  $
  */
 
 package com.arjuna.ats.internal.jta.resources;
 
 
 
 
 public class XAResourceErrorHandler
 {
     private XAException e;
     private XAResource xaResource;
     private Xid xid;
     private boolean committed = false;
 
     public XAResourceErrorHandler(XAException eXAResource xaResourceXid xid) {
         this. = xid;
         this. = xaResource;
         this. = e;
     }

    
Is the XAException a non-error when received in reply to commit or rollback ? It normally is, but may be overridden in recovery.
 
     protected boolean notAProblem(boolean commit)
     {
         return XAResourceErrorHandler.notAProblem(commit);
     }
 
     public int handleCMRRollbackError() {
         if (notAProblem(false))
         {
             // some other thread got there first (probably)
         }
         else
         {
 // TODO			addDeferredThrowable(e);
 
                     .toString(), XAHelper.printXAErrorCode(), );
 
             switch (.)
             {
                 case .:
                     break// just do the finally block
                 case .:
                     return .;
                 case .:
                     return .;
                 case .:
                     return .;
                 case .:
 //                    if (_recovered)
                     // assume it has already rolled back
                     break// rolled back previously and recovery completed
                 case .// forget?
                 case .:
                 case .:
                 case .:
                 case .:
                 case .:
                 case .:
                 case .:
                 case .:
                    break;
                default:
                    return .;
            }
        }
        return .;
    }
    public void forget() {
        // only relevant for two phase aware resources
/*        try {
            xaResource.forget(xid);
        } catch (XAException e) {
            // ignore
        }*/
    }
    public int handleCMRCommitError(boolean onePhase) {
//TODO        addDeferredThrowable(e1);
                .toString(), XAHelper.printXAErrorCode(), );
        if (onePhase) {
            switch (.)
            {
                case .:
                case .:
                    return .;
                case .:
                    forget();
                    break;
                case .:
                    forget();
                    return .;
                case .:
                case .:
                case .:
                case .:
                case .:
                case .:
                case .:
                case .:
                case .:
                    return .;
                case .:
                    return .// something committed or rolled back without asking us!
                case .// resource manager failed, did it rollback?
                    return .;
                case .:  // XA does not allow this to be thrown for 1PC!
                case .:
                    return .// assume rollback
                case .:
                default:
                     = true;
                    return .;  // ? recovery should retry
            }
            return .;
        } else {
            switch (.)
            {
                case .:
                    return .;
                case .// what about forget?
                    // OTS doesn't support
                    // this code here.
                    break;
                case .:
                case .:  // could really do with an ABORTED status in TwoPhaseOutcome to differentiate
                case .:
                case .:
                case .:
                case .:
                case .:
                case .:
                case .:
                case .:
                case .:  // XA spec implies rollback
                    return .;
                case .:
                    return .;
                case .:
//                    if (_recovered)
//                        break; // committed previously and recovery completed
//                    else
                        return .;  // something terminated the transaction!
                case .:
                case .:
                     = true;  // will cause log to be rewritten
	                /*
                     * Could do timeout retry here, but that could cause other resources in the list to go down the
                     * heuristic path (some are far too keen to do this). Fail and let recovery retry. Meanwhile
                     * the coordinator will continue to commit the other resources immediately.
                     */
                    return .;
                case .// resource manager failed, did it rollback?
                default:
                    return .;
            }
            return .;
        }
    }
    public boolean isCommitted() {
        return ;
    }
	public static boolean notAProblem (XAResource resXAException exboolean commit)
	{
		boolean isNotAProblem = false;
		XAResourceMap theMap = .get(res.getClass().getName());
		if (theMap != null)
			isNotAProblem = theMap.notAProblem(excommit);
		return isNotAProblem;
	}
	public static void addXAResourceMap (String typeXAResourceMap map)
	{
		.put(typemap);
	}
	private static HashMap<StringXAResourceMap_maps = new HashMap<StringXAResourceMap> ();

    
Static block puts all XAResourceMap instances defined in JTAEnvironmentBean to the XAResourceErrorHandler's hash map. They are later used to check if the XAException is a non-error when received in reply to commit or rollback.
    static
    {
        for(XAResourceMap xaResourceMap : jtaPropertyManager.getJTAEnvironmentBean().getXaResourceMaps())
        {
            XAResourceErrorHandler.addXAResourceMap(xaResourceMap.getXAResourceName(), xaResourceMap);
        }
    }
New to GrepCode? Check out our FAQ X