public < R > R executeTransactionalCommand ( final TransactionalCommand < R > command , final TransactionStyle style ) throws MithraBusinessException { String commandName = command . getClass ( ) . getName ( ) ; MithraTransaction tx = this . getCurrentTransaction ( ) ; if ( tx != null ) { try { return command . executeTransaction ( tx ) ; } catch ( RuntimeException e ) { throw e ; } catch ( Throwable throwable ) { getLogger ( ) . error ( commandName + " rolled back tx, will not retry." , throwable ) ; tx . expectRollbackWithCause ( throwable ) ; throw new MithraBusinessException ( commandName + " transaction failed" , throwable ) ; } } R result = null ; int retryCount = style . getRetries ( ) + 1 ; do { try { tx = this . startOrContinueTransaction ( style ) ; tx . setTransactionName ( "Transactional Command: " + commandName ) ; result = command . executeTransaction ( tx ) ; tx . commit ( ) ; retryCount = 0 ; } catch ( Throwable throwable ) { retryCount = MithraTransaction . handleTransactionException ( tx , throwable , retryCount , style ) ; } } while ( retryCount > 0 ) ; return result ; }
executes the given transactional command with the custom transaction style .