クラス TaskLifecycleListener

java.lang.ObjectSE
org.springframework.cloud.task.listener.TaskLifecycleListener
実装されたすべてのインターフェース:
EventListenerSEorg.springframework.beans.factory.DisposableBeanorg.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>org.springframework.context.Lifecycleorg.springframework.context.Phasedorg.springframework.context.SmartLifecycleorg.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
  • コンストラクターの詳細

  • メソッドの詳細

    • 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.SmartLifecycleisAutoStartup 
    • stop

      public void stop(RunnableSE callback)
      次で指定:
      インターフェース org.springframework.context.SmartLifecyclestop 
    • start

      public void start()
      次で指定:
      インターフェース org.springframework.context.Lifecyclestart 
    • stop

      public void stop()
      次で指定:
      インターフェース org.springframework.context.Lifecyclestop 
    • isRunning

      public boolean isRunning()
      次で指定:
      インターフェース org.springframework.context.LifecycleisRunning 
    • getPhase

      public int getPhase()
      次で指定:
      インターフェース org.springframework.context.PhasedgetPhase 
      次で指定:
      インターフェース org.springframework.context.SmartLifecyclegetPhase 
    • destroy

      public void destroy()
      次で指定:
      インターフェース org.springframework.beans.factory.DisposableBeandestroy 
    • getOrder

      public int getOrder()
      次で指定:
      インターフェース org.springframework.core.OrderedgetOrder