Class Main

java.lang.Object
de.gustavblass.nginx.ipguard4j.Main

public class Main extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Indicates how the program has been deployed on a system.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final @NonNull String
    The name of the terminal command used to invoke the program when it has been installed on a Linux system via a package manager.
    private static final @NonNull Main.InstallationType
    The way the program was actually installed on the system running it.
    private static final @NonNull String
    The file name of the JAR which contains the compiled program currently running.
    private static final org.apache.logging.log4j.Logger
     
    static final @NonNull String
    Human-readable title of the application, as used in the name of the JAR file.
    private static final @NonNull Thread
    Prints a farewell message to the console.
    private static @Nullable org.semver4j.Semver
    The current version of the application.
    private static final @NonNull String
    The path to / name of the Properties file which contains the version of the program, relative to the Main class' resource folder.
    private static final @NonNull ReentrantReadWriteLock
    Ensures mutual exclusion when accessing the VERSION.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NonNull org.semver4j.Semver
     
    (package private) static void
    main(String[] arguments)
    Parses the Configuration passed to the program via the command-line parameters, downloads the IP lists specified, deduplicates the IP-address entries and saves the resulting collection to the configured target files.
    static void
    setLoggingLevel(org.apache.logging.log4j.Level logLevel, File logFile, boolean printToConsole)
    Configures Log4J to log to the console and to the file specified by logFilePath.

    Methods inherited from class Object

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

    • LOG

      private static final org.apache.logging.log4j.Logger LOG
    • NAME

      @NonNull public static final @NonNull String NAME
      Human-readable title of the application, as used in the name of the JAR file.
      See Also:
    • VERSION

      @Nullable private static @Nullable org.semver4j.Semver VERSION

      The current version of the application.

      Access only through getVersion()!

    • VERSION_LOCK

      @NonNull private static final @NonNull ReentrantReadWriteLock VERSION_LOCK
      Ensures mutual exclusion when accessing the VERSION.
    • SHUTDOWN_HOOK

      @NonNull private static final @NonNull Thread SHUTDOWN_HOOK
      Prints a farewell message to the console. Intended to be used as a shutdown hook for when the JVM exits.
    • VERSION_FILE_PATH

      @NonNull private static final @NonNull String VERSION_FILE_PATH
      The path to / name of the Properties file which contains the version of the program, relative to the Main class' resource folder.
      See Also:
    • INSTALLATION_TYPE

      @NonNull private static final @NonNull Main.InstallationType INSTALLATION_TYPE

      The way the program was actually installed on the system running it.

      Can be overridden by setting the system property ipguard.installation.type to a valid Main.InstallationType label.

    • JAR_NAME

      @NonNull private static final @NonNull String JAR_NAME

      The file name of the JAR which contains the compiled program currently running. If the actual file name could not be determined, ipguard4j.jar will be used instead.

      Can be overridden by setting the system property ipguard.jar.name. Must not be blank.

    • COMMAND

      @NonNull private static final @NonNull String COMMAND

      The name of the terminal command used to invoke the program when it has been installed on a Linux system via a package manager.

      Defaults to

      Can be overridden by setting the system property ipguard.installation.command to something else (must not be blank).

  • Constructor Details

    • Main

      public Main()
  • Method Details

    • main

      static void main(String[] arguments)
      Parses the Configuration passed to the program via the command-line parameters, downloads the IP lists specified, deduplicates the IP-address entries and saves the resulting collection to the configured target files.
    • getVersion

      @NonNull public static @NonNull org.semver4j.Semver getVersion()
      Returns:
      The VERSION of the program.
      Implementation Note:
      Acquires the VERSION_LOCK's read lock first, and if the VERSION has not yet been computed, acquires the write lock to compute it.
    • setLoggingLevel

      public static void setLoggingLevel(org.apache.logging.log4j.Level logLevel, File logFile, boolean printToConsole)
      Configures Log4J to log to the console and to the file specified by logFilePath. The log file will be created if it does not exist. Any pre-existing content will not be overwritten, but appended to.
      Parameters:
      logLevel - The new minimum logging level at (or above) which messages will be logged. Lower-level messages will be ignored.
      logFile - The directory and file name of the log file to append the log messages to.
      printToConsole - Whether the logged messages shall be output to the console.
      Implementation Note:
      Partially generated by an LLM due to severe lack of knowledge and patience.