protected boolean canWeForgetXid ( XidImpl ourXid , Xid [ ] knownXids ) { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "canWeForgetXid" , new Object [ ] { ourXid , knownXids } ) ; if ( tc . isDebugEnabled ( ) ) { // We are only called if knownXids != null for ( int i = 0 ; i < knownXids . length ; i ++ ) { Tr . debug ( tc , "tx xid[" + i + "] " + knownXids [ i ] ) ; } } boolean forgetMe = true ; /*----------------------------------------------------------------*/ /* Yank the parts of the JTA xid. The branch qualifier will be */ /* the full JTA branch qualifier, and will need to be shortened */ /* to the same length of the transaction bqual so that the array */ /* compare has a chance to complete successfully. */ /*----------------------------------------------------------------*/ final int jtaFormatId = ourXid . getFormatId ( ) ; final byte [ ] jtaGtrid = ourXid . getGlobalTransactionId ( ) ; final byte [ ] fullJtaBqual = ourXid . getBranchQualifier ( ) ; byte [ ] jtaBqual = null ; /*----------------------------------------------------------------*/ /* We have to separate the transaction gtrid and bqual for the */ /* array compares. These are places to store these items. */ /*----------------------------------------------------------------*/ int txnFormatId ; byte [ ] txnGtrid ; byte [ ] txnBqual ; /*----------------------------------------------------------------*/ /* Iterate over all the known XIDs (if there are none, we won't */ /* iterate over anything). */ /*----------------------------------------------------------------*/ int x = 0 ; while ( ( x < knownXids . length ) && ( forgetMe == true ) ) { /*------------------------------------------------------------*/ /* If this is the first XID, shorten the JTA bqual to the */ /* length of the transaction bqual. We are assuming here */ /* that all the transaction bquals are the same length. If */ /* they arent, for some reason, we will need to revisit this. */ /*------------------------------------------------------------*/ if ( x == 0 ) { final int bqualLength = ( knownXids [ x ] . getBranchQualifier ( ) ) . length ; jtaBqual = new byte [ bqualLength ] ; System . arraycopy ( fullJtaBqual , 0 , jtaBqual , 0 , bqualLength ) ; } /*------------------------------------------------------------*/ /* Separate the transaction XID into comparable units. */ /*------------------------------------------------------------*/ txnFormatId = knownXids [ x ] . getFormatId ( ) ; txnGtrid = knownXids [ x ] . getGlobalTransactionId ( ) ; txnBqual = knownXids [ x ] . getBranchQualifier ( ) ; /*------------------------------------------------------------*/ /* Compare the individual parts of the XID for equality. If */ /* they are equal, set a boolean value and we can stop */ /* checking. */ /*------------------------------------------------------------*/ if ( ( jtaFormatId == txnFormatId ) && ( java . util . Arrays . equals ( jtaGtrid , txnGtrid ) ) && ( java . util . Arrays . equals ( jtaBqual , txnBqual ) ) ) { if ( tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Xid has been matched to a transaction:" , ourXid ) ; } auditTransactionXid ( ourXid , knownXids [ x ] , getXAResourceInfo ( ) ) ; forgetMe = false ; } x ++ ; } if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "canWeForgetXid" , forgetMe ) ; return forgetMe ; }
Iterates over the list of known Xids retrieved from transaction service and tries to match the given javax . transaction . xa . Xid with one of them .