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
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?
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
That would be great. Thanks
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