private void init ( final ClassLoader classLoader ) { // Load the user defined resolvers for ( JobXmlResolver resolver : ServiceLoader . load ( JobXmlResolver . class , classLoader ) ) { jobXmlResolvers . add ( resolver ) ; for ( String jobXml : resolver . getJobXmlNames ( classLoader ) ) { addJob ( jobXml , resolver . resolveJobName ( jobXml , classLoader ) ) ; } } // Load the default names for ( Map . Entry < String , VirtualFile > entry : jobXmlFiles . entrySet ( ) ) { try { // Parsing the entire job XML seems excessive to just get the job name. There are two reasons for this: // 1) If an error occurs during parsing there's no real need to consider this a valid job // 2) Using the implementation parser seems less error prone for future-proofing final Job job = JobParser . parseJob ( entry . getValue ( ) . openStream ( ) , classLoader , new XMLResolver ( ) { // this is essentially what JBeret does, but it's ugly. JBeret might need an API to handle this @ Override public Object resolveEntity ( final String publicID , final String systemID , final String baseURI , final String namespace ) throws XMLStreamException { try { return ( jobXmlFiles . containsKey ( systemID ) ? jobXmlFiles . get ( systemID ) . openStream ( ) : null ) ; } catch ( IOException e ) { throw new XMLStreamException ( e ) ; } } } ) ; addJob ( entry . getKey ( ) , job . getId ( ) ) ; } catch ( XMLStreamException | IOException e ) { // Report the possible error as we don't want to fail the deployment. The job may never be run. BatchLogger . LOGGER . invalidJobXmlFile ( entry . getKey ( ) ) ; } } }
Initializes the state of an instance