FileDocCategorySizeDatePackage
XAResourceWrapper.javaAPI DocGlassfish v2 API6447Fri May 04 22:35:16 BST 2007com.sun.enterprise.resource

XAResourceWrapper

public class XAResourceWrapper extends Object implements XAResource
This is class is used for debugging. It prints out trace information on TM calls to XAResource before directing the call to the actual XAResource object
author
Tony Ng

Fields Summary
private XAResource
res
private static Logger
_logger
Constructors Summary
public XAResourceWrapper(XAResource res)

        this.res = res;
    
Methods Summary
public voidcommit(javax.transaction.xa.Xid xid, boolean onePhase)

           _logger = LogDomains.getLogger(LogDomains.RSR_LOGGER);
          
        print("XAResource.commit: " + xidToString(xid) + "," + onePhase);
        res.commit(xid, onePhase);
    
public voidend(javax.transaction.xa.Xid xid, int flags)

        print("XAResource.end: " + xidToString(xid) + "," +
              flagToString(flags));
        res.end(xid, flags);
    
public booleanequals(java.lang.Object obj)

        if (this == obj) return true;
        if (obj == null) return false;
        if (obj instanceof XAResourceWrapper) {
            XAResource other = ((XAResourceWrapper) obj).res;
            return res.equals(other);
        }
        if (obj instanceof XAResource) {
            XAResource other = (XAResource) obj;
            return res.equals(other);
        }
        return false;
    
private static java.lang.StringflagToString(int flag)

        switch (flag) {
        case TMFAIL:
            return "TMFAIL";
        case TMJOIN:
            return "TMJOIN";
        case TMNOFLAGS:
            return "TMNOFLAGS";
        case TMONEPHASE:
            return "TMONEPHASE";
        case TMRESUME:
            return "TMRESUME";
        case TMSTARTRSCAN:
            return "TMSTARTRSCAN";
        case TMENDRSCAN:
            return "TMENDRSCAN";
        case TMSUCCESS:
            return "TMSUCCESS";
        case TMSUSPEND:
            return "TMSUSPEND";
        case XA_RDONLY:
            return "XA_RDONLY";
        default:
            return "" + Integer.toHexString(flag);
        }
    
public voidforget(javax.transaction.xa.Xid xid)

        print("XAResource.forget: " + xidToString(xid));
        res.forget(xid);
    
public intgetTransactionTimeout()

        return res.getTransactionTimeout();
    
public inthashCode()

        return res.hashCode();
    
public booleanisSameRM(javax.transaction.xa.XAResource xares)

        if (xares instanceof XAResourceWrapper) {
            XAResourceWrapper other = (XAResourceWrapper) xares;
            boolean result = res.isSameRM(other.res);
            print("XAResource.isSameRM: " + res + "," + other.res + "," +
                  result);
            return result;
        } else {
            boolean result = res.isSameRM(xares);
            print("XAResource.isSameRM: " + res + "," + xares + "," +
                  result);
            return result;
            //throw new IllegalArgumentException("Has to use XAResourceWrapper for all XAResource objects: " + xares);
        }
    
public intprepare(javax.transaction.xa.Xid xid)

        print("XAResource.prepare: " + xidToString(xid));
        int result = res.prepare(xid);
        print("prepare result = " + flagToString(result));
        return result;
    
private voidprint(java.lang.String s)

        _logger.log(Level.FINE,s);
    
public javax.transaction.xa.Xid[]recover(int flag)

        print("XAResource.recover: " + flagToString(flag));
        return res.recover(flag);
    
public voidrollback(javax.transaction.xa.Xid xid)

        print("XAResource.rollback: " + xidToString(xid));
        res.rollback(xid);
    
public booleansetTransactionTimeout(int seconds)

        return res.setTransactionTimeout(seconds);
    
public voidstart(javax.transaction.xa.Xid xid, int flags)

        print("XAResource.start: " + xidToString(xid) + "," +
              flagToString(flags));
        res.start(xid, flags);
    
private static java.lang.StringxidToString(javax.transaction.xa.Xid xid)

        return String.valueOf((new String(xid.getGlobalTransactionId()) +
                               new String(xid.getBranchQualifier())).hashCode());