クラス ApplicationPidFileWriter

java.lang.ObjectSE
org.springframework.boot.context.ApplicationPidFileWriter
実装されたすべてのインターフェース:
EventListenerSEApplicationListener<SpringApplicationEvent>Ordered

public class ApplicationPidFileWriter extends ObjectSE implements ApplicationListener<SpringApplicationEvent>, Ordered
アプリケーションの PID をファイルに保存する ApplicationListener。このアプリケーションリスナーは、JVM ごとに 1 回だけトリガーされ、ファイル名は、実行時に "PIDFILE" (または "pidfile" )という名前のシステムプロパティまたは環境変数で、または Spring Environment の spring.pid.file プロパティを使用してオーバーライドできます。

PID ファイルを作成できない場合、例外は報告されません。この動作は、true を PID_FAIL_ON_WRITE_ERROR という名前のシステムプロパティまたは環境変数(または "pid_fail_on_write_error" )、または Spring Environment の spring.pid.fail-on-write-error プロパティに割り当てることによって変更できます。

メモ: Spring Environment へのアクセスは、triggerEventTypeApplicationEnvironmentPreparedEventApplicationReadyEventApplicationPreparedEvent に設定されている場合にのみ可能です。

導入:
2.0.0
作成者:
Jakub Kubrynski, Dave Syer, Phillip Webb, Tomasz Przybyla, Madhura Bhave
  • コンストラクターの詳細

    • ApplicationPidFileWriter

      public ApplicationPidFileWriter()
      ファイル名 "application.pid" を使用して、新しい ApplicationPidFileWriter インスタンスを作成します。
    • ApplicationPidFileWriter

      public ApplicationPidFileWriter(StringSE filename)
      指定したファイル名で新しい ApplicationPidFileWriter インスタンスを作成します。
      パラメーター:
      filename - pid を含むファイルの名前
    • ApplicationPidFileWriter

      public ApplicationPidFileWriter(FileSE file)
      指定されたファイルで新しい ApplicationPidFileWriter インスタンスを作成します。
      パラメーター:
      file - pid を含むファイル
  • メソッドの詳細

    • setTriggerEventType

      public void setTriggerEventType(ClassSE<? extends SpringApplicationEvent> triggerEventType)
      PID ファイルの書き込みをトリガーするアプリケーションイベントの型を設定します。デフォルトは ApplicationPreparedEvent です。注: ApplicationStartingEvent を使用して書き込みをトリガーする場合、Spring Environment で PID ファイル名を指定することはできません。
      パラメーター:
      triggerEventType - トリガーイベント型
    • onApplicationEvent

      public void onApplicationEvent(SpringApplicationEvent event)
      次で指定:
      インターフェース ApplicationListener<SpringApplicationEvent>onApplicationEvent 
    • setOrder

      public void setOrder(int order)
    • getOrder

      public int getOrder()
      次で指定:
      インターフェース OrderedgetOrder 
    • reset

      protected static void reset()
      作成したフラグをテスト用にリセットします。