public static void main ( final String [ ] args ) { SLF4JBridgeHandler . install ( ) ; boolean exitWithError = true ; StopWatch stopWatch = new StopWatch ( ) ; try { RESULT_LOG . info ( "jFunk started" ) ; stopWatch . start ( ) ; int threadCount = 1 ; boolean parallel = false ; Properties scriptProperties = new Properties ( ) ; List < File > scripts = Lists . newArrayList ( ) ; for ( String arg : args ) { if ( arg . startsWith ( "-threadcount" ) ) { String [ ] split = arg . split ( "=" ) ; Preconditions . checkArgument ( split . length == 2 , "The number of threads must be specified as follows: -threadcount=<value>" ) ; threadCount = Integer . parseInt ( split [ 1 ] ) ; RESULT_LOG . info ( "Using " + threadCount + ( threadCount == 1 ? " thread" : " threads" ) ) ; } else if ( arg . startsWith ( "-S" ) ) { arg = arg . substring ( 2 ) ; String [ ] split = arg . split ( "=" ) ; Preconditions . checkArgument ( split . length == 2 , "Script parameters must be given in the form -S<name>=<value>" ) ; scriptProperties . setProperty ( split [ 0 ] , normalizeScriptParameterValue ( split [ 1 ] ) ) ; RESULT_LOG . info ( "Using script parameter " + split [ 0 ] + " with value " + split [ 1 ] ) ; } else if ( arg . equals ( "-parallel" ) ) { parallel = true ; RESULT_LOG . info ( "Using parallel mode" ) ; } else { scripts . add ( new File ( arg ) ) ; } } if ( scripts . isEmpty ( ) ) { scripts . addAll ( requestScriptsViaGui ( ) ) ; if ( scripts . isEmpty ( ) ) { RESULT_LOG . info ( "Execution finished (took " + stopWatch + " H:mm:ss.SSS)" ) ; System . exit ( 0 ) ; } } String propsFileName = System . getProperty ( "jfunk.props.file" , "jfunk.properties" ) ; Module module = ModulesLoader . loadModulesFromProperties ( new JFunkDefaultModule ( ) , propsFileName ) ; Injector injector = Guice . createInjector ( module ) ; JFunkFactory factory = injector . getInstance ( JFunkFactory . class ) ; JFunkBase jFunk = factory . create ( threadCount , parallel , scripts , scriptProperties ) ; jFunk . execute ( ) ; exitWithError = false ; } catch ( JFunkExecutionException ex ) { // no logging necessary } catch ( Exception ex ) { Logger . getLogger ( JFunk . class ) . error ( "jFunk terminated unexpectedly." , ex ) ; } finally { stopWatch . stop ( ) ; RESULT_LOG . info ( "Execution finished (took " + stopWatch + " H:mm:ss.SSS)" ) ; } System . exit ( exitWithError ? - 1 : 0 ) ; }
Starts jFunk .