クラス TaskLifecycleListener
java.lang.ObjectSE
org.springframework.cloud.task.listener.TaskLifecycleListener
- 実装されたすべてのインターフェース:
EventListenerSE
、org.springframework.beans.factory.DisposableBean
、org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
、org.springframework.context.Lifecycle
、org.springframework.context.Phased
、org.springframework.context.SmartLifecycle
、org.springframework.core.Ordered
public class TaskLifecycleListener
extends ObjectSE
implements org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>, org.springframework.context.SmartLifecycle, org.springframework.beans.factory.DisposableBean, org.springframework.core.Ordered
タスクのライフサイクルを監視します。このリスナーは、登録された
TaskRepository
にタスクの開始と終了の両方を記録します。タスクの開始と終了を識別するために、次のイベントが使用されます。Lifecycle.start()
- タスクの開始を識別するために使用されます。タスクには、単一のアプリケーションコンテキストが含まれている必要があります。ApplicationReadyEvent
- タスクが正常に終了したことを確認するために使用されます。ApplicationFailedEvent
- タスクの失敗を識別するために使用されます。Lifecycle.stop()
-ApplicationReadyEvent
またはApplicationFailedEvent
が発行されない場合に、タスクの終了を識別するために使用されます。これは、BeforeTask の実行中にエラーが発生した場合に発生する可能性があります。
spring.cloud.task.closecontext_enabled
(デフォルトは false) で設定できます。spring.cloud.task.closecontext_enabled
が true に設定されている場合、非デーモンスレッドがまだ実行されているかどうかに関係なく、タスクの補完時にコンテキストは閉じられます。また、コンテキストが起動しなかった場合、FailedTask と TaskEnd の依存関係がすべて満たされない可能性があります。- 作成者:
- Michael Minella, Glenn Renfro
フィールドサマリー
インターフェース org.springframework.core.Ordered から継承されたフィールド
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
インターフェース org.springframework.context.SmartLifecycle から継承されたフィールド
DEFAULT_PHASE
コンストラクターのサマリー
コンストラクター説明TaskLifecycleListener
(TaskRepository taskRepository, TaskNameResolver taskNameResolver, org.springframework.boot.ApplicationArguments applicationArguments, TaskExplorer taskExplorer, TaskProperties taskProperties, TaskListenerExecutorObjectFactory taskListenerExecutorObjectFactory, io.micrometer.observation.ObservationRegistry observationRegistry, TaskObservationCloudKeyValues taskObservationCloudKeyValues) メソッドのサマリー
修飾子と型メソッド説明void
destroy()
int
getOrder()
int
getPhase()
boolean
boolean
void
onApplicationEvent
(org.springframework.context.ApplicationEvent applicationEvent) ApplicationEvent
を使用して、タスクの終了と失敗を判断します。void
start()
void
stop()
void
stop
(RunnableSE callback)
コンストラクターの詳細
TaskLifecycleListener
public TaskLifecycleListener(TaskRepository taskRepository, TaskNameResolver taskNameResolver, org.springframework.boot.ApplicationArguments applicationArguments, TaskExplorer taskExplorer, TaskProperties taskProperties, TaskListenerExecutorObjectFactory taskListenerExecutorObjectFactory, @Autowired(required=false) io.micrometer.observation.ObservationRegistry observationRegistry, TaskObservationCloudKeyValues taskObservationCloudKeyValues) - パラメーター:
taskRepository
- 実行を記録するためのTaskRepository
。taskNameResolver
-TaskNameResolver
はタスク実行のタスク名を決定するために使用されます。applicationArguments
- タスク実行に使用されるApplicationArguments
。taskExplorer
- タスク実行に使用されるTaskExplorer
。taskProperties
- タスク実行に使用されるTaskProperties
。taskListenerExecutorObjectFactory
- タスク用に TaskListenerExecutor を初期化するTaskListenerExecutorObjectFactory
メソッドの詳細
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent applicationEvent) ApplicationEvent
を使用してタスクの終了と失敗を判断します。具体的には、次のようになります。ApplicationReadyEvent
- タスクの正常終了ApplicationFailedEvent
- タスクの失敗
- 次で指定:
- インターフェース
org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
のonApplicationEvent
- パラメーター:
applicationEvent
- リッスンされているアプリケーション。
isAutoStartup
public boolean isAutoStartup()- 次で指定:
- インターフェース
org.springframework.context.SmartLifecycle
のisAutoStartup
stop
- 次で指定:
- インターフェース
org.springframework.context.SmartLifecycle
のstop
start
public void start()- 次で指定:
- インターフェース
org.springframework.context.Lifecycle
のstart
stop
public void stop()- 次で指定:
- インターフェース
org.springframework.context.Lifecycle
のstop
isRunning
public boolean isRunning()- 次で指定:
- インターフェース
org.springframework.context.Lifecycle
のisRunning
getPhase
public int getPhase()- 次で指定:
- インターフェース
org.springframework.context.Phased
のgetPhase
- 次で指定:
- インターフェース
org.springframework.context.SmartLifecycle
のgetPhase
destroy
public void destroy()- 次で指定:
- インターフェース
org.springframework.beans.factory.DisposableBean
のdestroy
getOrder
public int getOrder()- 次で指定:
- インターフェース
org.springframework.core.Ordered
のgetOrder