Class PhaseStatusProvider

java.lang.Object
com.github.jpmsilva.jsystemd.PhaseStatusProvider
All Implemented Interfaces:
StatusProvider

public class PhaseStatusProvider extends Object implements StatusProvider
Implementation of StatusProvider whose status is set by the application, to report what it is doing, such as Reindexing 40% or Migrating the schema.

The status is shown as set, until it is set again or cleared. While there is no phase, nothing is reported.

When created with immediate updates, every change of phase is sent to systemd right away, rather than with the next status update.

Author:
Joao Silva
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new PhaseStatusProvider, whose changes of phase are sent to systemd with the next status update.
    PhaseStatusProvider(boolean immediateUpdates)
    Create a new PhaseStatusProvider, whose changes of phase are sent to systemd either right away or with the next status update.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the current phase, so that nothing is reported.
    @Nullable String
    Returns the current phase.
    void
    setPhase(@Nullable String phase)
    Sets the current phase, which is shown as is in the status.
    Exposes status information to send to systemd.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PhaseStatusProvider

      public PhaseStatusProvider()
      Create a new PhaseStatusProvider, whose changes of phase are sent to systemd with the next status update.
    • PhaseStatusProvider

      public PhaseStatusProvider(boolean immediateUpdates)
      Create a new PhaseStatusProvider, whose changes of phase are sent to systemd either right away or with the next status update.

      The created instance is not registered as a status provider of Systemd.instance(): that is up to the caller.

      Parameters:
      immediateUpdates - true to send the status to systemd on every change of phase, or false to wait for the next status update
  • Method Details

    • getPhase

      public @Nullable String getPhase()
      Returns the current phase.
      Returns:
      the current phase, or null if there is none
    • setPhase

      public void setPhase(@Nullable String phase)
      Sets the current phase, which is shown as is in the status.
      Parameters:
      phase - the current phase, or null (or an empty string) to clear it
    • clearPhase

      public void clearPhase()
      Clears the current phase, so that nothing is reported.
    • status

      public String status()
      Description copied from interface: StatusProvider
      Exposes status information to send to systemd.
      Specified by:
      status in interface StatusProvider
      Returns:
      the string message to add to the service status