-
1. Re: Batch job location
cfang Jan 11, 2017 11:12 AM (in response to richardmoore)The path of the selected job is not exposed. Some jobs may not have a path, if it's loaded from non-file-system sources.
If you are using classpath to load jobs, you can call:
URL url = classLoader.getResource(jobName);
that should give you the path info pointing to the same resource for the selected job xml.
Or you can implement your own job xml resolver, which is essentially the same as org.jberet.se.ClassPathJobXmlResolver, plus logging path info, and configure your job xml resolver impl via
META-INF/services/org.jberet.spi.JobXmlResolver
For example.
-
2. Re: Batch job location
richardmoore Jan 11, 2017 2:03 PM (in response to cfang)Okay. Could you make this an enhancement to the job object to have a variable that is populated with what resource was used to create the job?
-
3. Re: Batch job location
cfang Jan 12, 2017 8:49 PM (in response to richardmoore)source of the job xml (where it is loaded from) is not part of the job object model, strictly speaking; it's more like meta data, so saving it inside Job class doesn't seem a good fit.
Compare the job loader to class loader: class loader does not save the source location of a class in the class object, either.
I think we can augment job xml loader classes to log the location info, if applicable. Will that help?
See JIRA issue:
Log job xml location
-
4. Re: Batch job location
richardmoore Jan 12, 2017 8:35 AM (in response to cfang)That would be great. Thanks
-
5. Re: Batch job location
cfang Jan 13, 2017 2:53 PM (in response to richardmoore)Modified org.jberet.tools.AbstractJobXmlResolver to log the job xml location. Sample output:
INFO: JBERET000030: Resolved job jar:file:/Users/cfang/dev/jsr352/test-apps/throttle/target/throttle-1.3.0.Beta5-SNAPSHOT.jar!/META-INF/batch-jobs/throttle.xml
INFO: JBERET000030: Resolved job file:/Users/cfang/dev/jsr352/jberet-support/target/test-classes/META-INF/batch-jobs/org.jberet.support.io.XmlItemReaderTest.xml