Class SystemCommandTasklet

    • Field Detail

      • logger

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

      • SystemCommandTasklet

        public SystemCommandTasklet()
    • Method Detail

      • execute

        public RepeatStatus execute​(StepContribution contribution,
                                    ChunkContext chunkContext)
                             throws java.lang.Exception
        Execute system command and map its exit code to ExitStatus using SystemProcessExitCodeMapper.
        Specified by:
        execute in interface Tasklet
        Parameters:
        contribution - mutable state to be passed back to update the current step execution
        chunkContext - attributes shared between invocations but not between restarts
        Returns:
        an RepeatStatus indicating whether processing is continuable. Returning null is interpreted as RepeatStatus.FINISHED
        Throws:
        java.lang.Exception - thrown if error occurs during execution.
      • setCommand

        public void setCommand​(java.lang.String command)
        Parameters:
        command - command to be executed in a separate system process
      • setEnvironmentParams

        public void setEnvironmentParams​(java.lang.String[] envp)
        Parameters:
        envp - environment parameter values, inherited from parent process when not set (or set to null).
      • setWorkingDirectory

        public void setWorkingDirectory​(java.lang.String dir)
        Parameters:
        dir - working directory of the spawned process, inherited from parent process when not set (or set to null).
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws java.lang.Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        java.lang.Exception
      • setJobExplorer

        public void setJobExplorer​(JobExplorer jobExplorer)
      • setTimeout

        public void setTimeout​(long timeout)
        Timeout in milliseconds.
        Parameters:
        timeout - upper limit for how long the execution of the external program is allowed to last.
      • setTerminationCheckInterval

        public void setTerminationCheckInterval​(long checkInterval)
        The time interval how often the tasklet will check for termination status.
        Parameters:
        checkInterval - time interval in milliseconds (1 second by default).
      • setTaskExecutor

        public void setTaskExecutor​(org.springframework.core.task.TaskExecutor taskExecutor)
        Sets the task executor that will be used to execute the system command NB! Avoid using a synchronous task executor
        Parameters:
        taskExecutor - instance of TaskExecutor.
      • setInterruptOnCancel

        public void setInterruptOnCancel​(boolean interruptOnCancel)
        If true tasklet will attempt to interrupt the thread executing the system command if setTimeout(long) has been exceeded or user interrupts the job. false by default
        Parameters:
        interruptOnCancel - boolean determines if process should be interrupted