Class Application<T extends Module>

java.lang.Object
io.inverno.core.v1.Application<T>
Type Parameters:
T - the module type

public class Application<T extends Module> extends Object

A module wrapper which starts a module as an application and stops it when the application is gracefully shutdown. An application basically provides boiler plate code to properly run a module as an application.

An application can display a Banner when it starts. By default, the StandardBanner is displayed.

An application also registers a virtual-machine shutdown hook that gracefully stops the module when the virtual machine shuts down.

A pidfile can also be created after the application has started and removed after the application has shutdown gracefully. by specifying the path to the pidfile in the "inverno.application.pid_file" system property. By default no pidfile is created. An application will fail to start if a pidfile designating a valid process already exists.

Since:
1.0
Author:
Jeremy Kuhn
  • Constructor Details

    • Application

      protected Application(Module.ModuleBuilder<T> moduleBuilder)

      Creates a new Application for the module created with the specified builder.

      Parameters:
      moduleBuilder - the module builder.
  • Method Details

    • with

      public static <E extends Module> Application<E> with(Module.ModuleBuilder<E> moduleBuilder)

      Creates a new application for the module created with the specified builder.

      Type Parameters:
      E - the module type.
      Parameters:
      moduleBuilder - the module builder.
      Returns:
      an application.
    • run

      public static <E extends Module> E run(Module.ModuleBuilder<E> moduleBuilder)

      Creates and run a new application for the module created with the specified builder.

      Type Parameters:
      E - the module type.
      Parameters:
      moduleBuilder - the module builder.
      Returns:
      a running module instance.
    • banner

      public Application<T> banner(Banner banner)

      Sets the application banner.

      If null is specified no banner will be displayed

      Parameters:
      banner - the banner to set or null to display no banner.
      Returns:
      this application.
    • run

      public T run() throws IllegalStateException

      Runs the application.

      Returns:
      the resulting module.
      Throws:
      IllegalStateException - if the application is already running.