Class CommandLineJobRunner

    • Field Detail

      • logger

        protected static final org.apache.commons.logging.Log logger
    • Constructor Detail

      • CommandLineJobRunner

        public CommandLineJobRunner()
    • Method Detail

      • setLauncher

        public void setLauncher(JobLauncher launcher)
        Injection setter for the JobLauncher.
        launcher - the launcher to set
      • setJobRepository

        public void setJobRepository(JobRepository jobRepository)
        jobRepository - the jobRepository to set
      • setExitCodeMapper

        public void setExitCodeMapper(ExitCodeMapper exitCodeMapper)
        Injection setter for the ExitCodeMapper.
        exitCodeMapper - the exitCodeMapper to set
      • getErrorMessage

        public static String getErrorMessage()
        Retrieve the error message set by an instance of CommandLineJobRunner as it exits. Empty if the last job launched was successful.
        the error message
      • setSystemExiter

        public void setSystemExiter(SystemExiter systemExiter)
        Injection setter for the SystemExiter.
        systemExiter -
      • exit

        public void exit(int status)
        Delegate to the exiter to (possibly) exit the VM gracefully.
        status -
      • main

        public static void main(String[] args)
                         throws Exception
        Launch a batch job using a CommandLineJobRunner. Creates a new Spring context for the job execution, and uses a common parent for all such contexts. No exception are thrown from this method, rather exceptions are logged and an integer returned through the exit status in a JvmSystemExiter (which can be overridden by defining one in the Spring context).
        Parameters can be provided in the form key=value, and will be converted using the injected JobParametersConverter.
        args -

        • -restart: (optional) if the job has failed or stopped and the most should be restarted. If specified then the jobIdentifier parameter can be interpreted either as the name of the job or the id of teh job execution that failed.
        • -next: (optional) if the job has a JobParametersIncrementer that can be used to launch the next in a sequence
        • jobPath: the xml application context containing a Job
        • jobIdentifier: the bean id of the job or id of the failed execution in the case of a restart.
        • jobParameters: 0 to many parameters that will be used to launch a job.
        The options (-restart, -next) can occur anywhere in the command line.


Copyright © 2014 Pivotal. All rights reserved.