void commit ( boolean onePhase ) throws XAException { if ( this . getProgressState ( ) == XAResourceProgressState . COMMITTED ) { return ; } if ( this . hasHeuristicOutcome ( ) ) { throw new XAException ( this . heuristicState ) ; } if ( ! checkTXRequirements ( ) ) { throw new SampleTransactionalException ( "State not transactional " + this ) ; } this . checkRollback ( ) ; if ( this . getProgressState ( ) != XAResourceProgressState . ACTIVE && onePhase ) { throw new XAException ( XAException . XAER_RMFAIL ) ; } else if ( this . getProgressState ( ) != XAResourceProgressState . PREPARED && ! onePhase ) { throw new XAException ( XAException . XAER_RMFAIL ) ; } else if ( this . getProgressState ( ) != XAResourceProgressState . PREPARED && this . getProgressState ( ) != XAResourceProgressState . ACTIVE ) { throw new XAException ( XAException . XAER_RMFAIL ) ; } this . setProgressState ( XAResourceProgressState . COMMITTING ) ; try { this . getManagedConnection ( ) . commit ( onePhase ) ; } catch ( Exception e ) { throwXAException ( XAException . XAER_PROTO , e ) ; } this . setProgressState ( XAResourceProgressState . COMMITTED ) ; }
maintains the state of the transactional branch if a commit is executed .