@ Override public final void run ( ) { LOGGER . debug ( "Executing " + getClass ( ) . getSimpleName ( ) ) ; markAsInProgress ( ) ; if ( ! Lists . isNullOrEmpty ( listeners ) ) { Runnable startUseCaseRunnable = new Runnable ( ) { @ Override public void run ( ) { for ( UseCaseListener listener : listeners ) { notifyUseCaseStart ( listener ) ; } } } ; if ( handler != null ) { handler . post ( startUseCaseRunnable ) ; } else { startUseCaseRunnable . run ( ) ; } } Trace trace = null ; if ( timingTrackingEnabled ( ) ) { trace = TraceHelper . startTrace ( getClass ( ) ) ; } try { LOGGER . debug ( "Started " + getClass ( ) . getSimpleName ( ) ) ; executionTime = null ; startTime = DateUtils . nowMillis ( ) ; doExecute ( ) ; executionTime = DateUtils . nowMillis ( ) - startTime ; LOGGER . debug ( "Finished " + getClass ( ) . getSimpleName ( ) + ". Execution time: " + DateUtils . formatDuration ( executionTime ) ) ; if ( trace != null ) { trace . putAttribute ( "result" , "success" ) ; trace . incrementMetric ( "successes" , 1 ) ; } markAsSuccessful ( ) ; if ( ! Lists . isNullOrEmpty ( listeners ) ) { Runnable finishedUseCaseRunnable = new Runnable ( ) { @ Override public void run ( ) { for ( UseCaseListener listener : listeners ) { notifyFinishedUseCase ( listener ) ; } markAsNotified ( ) ; } } ; if ( handler != null ) { handler . post ( finishedUseCaseRunnable ) ; } else { finishedUseCaseRunnable . run ( ) ; } } } catch ( RuntimeException e ) { if ( trace != null ) { trace . putAttribute ( "result" , "failure" ) ; trace . incrementMetric ( "failures" , 1 ) ; } final AbstractException abstractException = wrapException ( e ) ; markAsFailed ( abstractException ) ; logHandledException ( abstractException ) ; if ( ! Lists . isNullOrEmpty ( listeners ) ) { Runnable finishedFailedUseCaseRunnable = new Runnable ( ) { @ Override public void run ( ) { for ( UseCaseListener listener : listeners ) { notifyFailedUseCase ( abstractException , listener ) ; } markAsNotified ( ) ; } } ; if ( handler != null ) { handler . post ( finishedFailedUseCaseRunnable ) ; } else { finishedFailedUseCaseRunnable . run ( ) ; } } } finally { if ( trace != null ) { trace . stop ( ) ; } } }
Executes the use case .