public void processFile ( String fileName , boolean failOnFileNotFound ) throws Exception { boolean fileFound = false ; InputStream f = null ; try { String furl = null ; File file = new File ( fileName ) ; // files in filesystem if ( ! file . exists ( ) ) { URL url = classLoadHelper . getResource ( fileName ) ; if ( url != null ) { try { furl = URLDecoder . decode ( url . getPath ( ) , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { furl = url . getPath ( ) ; } file = new File ( furl ) ; try { f = url . openStream ( ) ; } catch ( IOException ignor ) { // Swallow the exception } } } else { try { f = new java . io . FileInputStream ( file ) ; } catch ( FileNotFoundException e ) { // ignore } } if ( f == null ) { fileFound = false ; } else { fileFound = true ; } } finally { try { if ( f != null ) { f . close ( ) ; } } catch ( IOException ioe ) { logger . warn ( "Error closing jobs file " + fileName , ioe ) ; } } if ( ! fileFound ) { if ( failOnFileNotFound ) { throw new SchedulerException ( "File named '" + fileName + "' does not exist." ) ; } else { logger . warn ( "File named '" + fileName + "' does not exist. This is OK if you don't want to use an XML job config file." ) ; } } else { processFile ( fileName ) ; } }
Process the xml file in the given location and schedule all of the jobs defined within it .