public void call ( final T request , final Functor < String , RemoteService . Response > process , final Functor < Void , RemoteService . Response > confirm ) { try { String message = process . invoke ( RemoteService . call ( location , endpoint , true , request ) ) ; if ( message != null ) { // clean failure throw new RuntimeException ( message ) ; } } catch ( RuntimeException x ) { if ( confirm == null ) { executor . execute ( new VitalTask < Reporting , Void > ( reporting ) { protected Void execute ( ) throws Exception { if ( getAge ( ) > DEFAULT_RETRY_LIMIT ) { try { process . invoke ( null ) ; } catch ( Exception x ) { } } else { process . invoke ( RemoteService . call ( location , recovery , repacker . invoke ( request ) ) ) ; } return null ; } } ) ; // positive! } else { executor . execute ( new VitalTask < Reporting , Void > ( reporting ) { protected Void execute ( ) throws Exception { if ( getAge ( ) > DEFAULT_RETRY_LIMIT ) { return null ; } else { confirm . invoke ( RemoteService . call ( location , recovery , repacker . invoke ( request ) ) ) ; } return null ; } } ) ; // negative! throw x ; } } }
Starts a critical call and automatically manages uncertain outcomes .