クラス SystemCommandTasklet
java.lang.ObjectSE
org.springframework.batch.core.step.tasklet.SystemCommandTasklet
- 実装されたすべてのインターフェース:
StoppableTasklet
、Tasklet
、StepExecutionListener
、StepListener
、org.springframework.beans.factory.InitializingBean
public class SystemCommandTasklet
extends ObjectSE
implements StepExecutionListener, StoppableTasklet, org.springframework.beans.factory.InitializingBean
システムコマンドを実行する
Tasklet
。 システムコマンドは、挿入された setTaskExecutor(TaskExecutor)
を使用して非同期的に実行されます。外部プロセスがハングした場合でもバッチジョブが永久にハングしないように、タイムアウト値を設定する必要があります。
タスクレットは終了ステータスを定期的にチェックします (つまり、setCommand(String...)
が実行を終了したか、setTimeout(long)
が期限切れになったか、ジョブが中断されました)。チェック間隔は setTerminationCheckInterval(long)
で指定されます。
ジョブの割り込みが検出されると、タスクレットの実行は JobInterruptedException
をスローして直ちに終了します。
setInterruptOnCancel(boolean)
は、タスクレットが (異常に) 終了したときにシステムコマンドを実行するスレッドがまだ実行中の場合に、タスクレットがそのスレッドの中断を試行するかどうかを指定します。
- 作成者:
- Robert Kasanicky, Will Schipp, Mahmoud Ben Hassine, Injae Kim
フィールドサマリー
フィールドコンストラクターのサマリー
コンストラクターメソッドのサマリー
修飾子と型メソッド説明void
void
beforeStep
(StepExecution stepExecution) システムコマンド実行中の割り込みチェックのためにStepExecution
への参照を取得します。execute
(StepContribution contribution, ChunkContext chunkContext) システムコマンドを実行し、SystemProcessExitCodeMapper
を使用してその終了コードをExitStatus
にマップします。void
setCommand
(StringSE... command) 引数とともに実行するコマンドを設定します。void
setCommandRunner
(CommandRunner commandRunner) CommandRunner
用の setter の注入。void
setEnvironmentParams
(StringSE[] envp) void
setInterruptOnCancel
(boolean interruptOnCancel) setTimeout(long)
を超えた場合、またはユーザーがジョブを中断した場合、true
タスクレットがシステムコマンドを実行しているスレッドを中断しようとします。void
setJobExplorer
(JobExplorer jobExplorer) void
setSystemProcessExitCodeMapper
(SystemProcessExitCodeMapper systemProcessExitCodeMapper) void
setTaskExecutor
(org.springframework.core.task.TaskExecutor taskExecutor) システムコマンド NB の実行に使用されるタスクエグゼキューターを設定します。同期タスクエグゼキューターの使用を避けるvoid
setTerminationCheckInterval
(long checkInterval) タスクレットが終了ステータスをチェックする頻度の間隔。void
setTimeout
(long timeout) ミリ秒単位のタイムアウト。void
void
stop()
setInterruptOnCancel(boolean)
が true に設定されている場合にのみ、システムコマンドを実行するスレッドに割り込みます。クラス java.lang.ObjectSE から継承されたメソッド
clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSE
インターフェース org.springframework.batch.core.StepExecutionListener から継承されたメソッド
afterStep
フィールドの詳細
logger
protected static final org.apache.commons.logging.Log logger
コンストラクターの詳細
SystemCommandTasklet
public SystemCommandTasklet()
メソッドの詳細
execute
@Nullable public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws ExceptionSE システムコマンドを実行し、SystemProcessExitCodeMapper
を使用してその終了コードをExitStatus
にマップします。- 次で指定:
- インターフェース
Tasklet
のexecute
- パラメーター:
contribution
- 現在のステップ実行を更新するために戻される変更可能な状態chunkContext
- 再起動間ではなく、呼び出し間で共有される属性- 戻り値:
- 処理が継続可能かどうかを示す
RepeatStatus
null
を返すと、RepeatStatus.FINISHED
として解釈されます - 例外:
ExceptionSE
- 実行中にエラーが発生した場合にスローされます。
setCommandRunner
CommandRunner
用の setter の注入。- パラメーター:
commandRunner
- SystemCommandTasklet インスタンスによって使用されるCommandRunner
インスタンス。デフォルトはJvmCommandRunner
です。- 導入:
- 5.0
setCommand
引数とともに実行するコマンドを設定します。例:setCommand("myCommand", "myArg1", "myArg2");
- パラメーター:
command
- 別のシステムプロセスで実行されるコマンド。
setEnvironmentParams
- パラメーター:
envp
- 設定されていない(または null に設定されている)ときに親プロセスから継承された環境パラメーター値。
setWorkingDirectory
- パラメーター:
dir
- 生成されたプロセスの作業ディレクトリ。設定されていない(または null に設定されている)場合は親プロセスから継承されます。
afterPropertiesSet
- 次で指定:
- インターフェース
org.springframework.beans.factory.InitializingBean
のafterPropertiesSet
- 例外:
ExceptionSE
setJobExplorer
setSystemProcessExitCodeMapper
- パラメーター:
systemProcessExitCodeMapper
- システムプロセスの戻り値を、タスクレットによって返されるExitStatus
にマップします。SimpleSystemProcessExitCodeMapper
がデフォルトで使用されます。
setTimeout
public void setTimeout(long timeout) ミリ秒単位のタイムアウト。- パラメーター:
timeout
- 外部プログラムの実行を継続できる時間の上限。
setTerminationCheckInterval
public void setTerminationCheckInterval(long checkInterval) タスクレットが終了ステータスをチェックする頻度の間隔。- パラメーター:
checkInterval
- ミリ秒単位の時間間隔(デフォルトでは 1 秒)。
beforeStep
システムコマンド実行中の割り込みチェックのためにStepExecution
への参照を取得します。- 次で指定:
- インターフェース
StepExecutionListener
のbeforeStep
- パラメーター:
stepExecution
-StepExecution
のインスタンス。
setTaskExecutor
public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor) システムコマンド NB の実行に使用されるタスクエグゼキューターを設定します。同期タスクエグゼキューターの使用を避ける- パラメーター:
taskExecutor
-TaskExecutor
のインスタンス。
setInterruptOnCancel
public void setInterruptOnCancel(boolean interruptOnCancel) - パラメーター:
interruptOnCancel
- boolean は、プロセスを中断するかどうかを決定します
stop
public void stop()setInterruptOnCancel(boolean)
が true に設定されている場合にのみ、システムコマンドを実行するスレッドに割り込みます。そうでない場合、基になるコマンドはタスクレットが終了する前に終了することが許可されます。- 次で指定:
- インターフェース
StoppableTasklet
のstop
- 導入:
- 3.0
- 関連事項: