Results 1 to 8 of 8

Thread: get xml file

  1. #1
    Join Date
    Aug 2011
    Posts
    16

    Default get xml file

    anyone knows how to get the xml file path/name of the ApplicationContext? it's passed as command line argument in Spring Batch and i'd like to retrieve it from an object or maybe a system property?

    Thanks!!

  2. #2
    Join Date
    Aug 2011
    Posts
    16

    Default

    The best I've found so far is:

    Code:
    System.getProperty("exec.args")
    but i was hoping for a more Spring-y solution. Besides, this does not work when the job is started via Spring Batch Admin (I'm not sure what's being used to start the job when using it)

    Any suggestions?

  3. #3
    Join Date
    Aug 2011
    Posts
    16

    Default

    When running my job, the logs on Spring Batch Admin (using Jetty) show the following message:

    ResourceXmlApplicationContext:file:/home/anthony/maven/spring-batch-admin-sample/target/classes/META-INF/spring/batch/jobs/my_job.xml

    It'd be nice if I could access that programmatically..!

  4. #4
    Join Date
    Nov 2007
    Location
    Sun Prairie, WI
    Posts
    50

    Default

    Can you set the property in a properties file and identify a path for various locations that you will need??
    satsranchuser

  5. #5
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    may I ask why you need such information?

  6. #6
    Join Date
    Aug 2011
    Posts
    16

    Default

    satsranchuser: I thought about it, I was just hoping to obtain it from an object instead. based on the logs, it clearly is stored somewhere

    arno: not sure i'll need it yet, but i'm considering creating another xml job file for the next run, based on information gathered on the current run. It may be as simple as changing one parameter, hence I'd like to be able to access the current xml to use as template.

  7. #7
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    I see. Perhaps you should do that outside the application context, not from inside. It would make more sense to me.

  8. #8
    Join Date
    Aug 2011
    Posts
    16

    Default

    ok, well if you guys can't think of an obvious way to obtain it anyway, I suppose I can simply go with satsranchuser's suggestion.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •