Interface ExitHandler

All Known Implementing Classes:
SystemExitHandler

public interface ExitHandler
Interface for handling program exits. Used to define a dynamic behavior when handling events where System.exit() is called.

Tools/commands should use this interface instead of calling System.exit() directly, in order to allow proper management.

Usage example:
Usual code: public static void main(String[] args) { if (error) { System.exit(1); } System.exit(0); } Adapted code: private static ExitHandler exitHandler = new SystemExitHandler(); public static void setExitHandler(ExitHandler handler) { exitHandler = handler; } public static void main(String[] args) { if (error) { exitHandler.exit(1); } exitHandler.exit(0); }
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    exit(int status)
    Handle program exit with the given status code.
  • Method Details

    • exit

      void exit(int status)
      Handle program exit with the given status code.
      Parameters:
      status - Exit status code (0 for success, non-zero for error)