public class ApplicationLifecycleManager extends Object
Application
class is responsible for starting and stopping the application,
but nothing else. This class can be used to run both persistent applications that will run
till they receive a signal, and command mode applications that will run until the main method
returns. This class registers a shutdown hook to properly shut down the application, and handles
exiting with the supplied exit code.
This class should be used to run production and dev mode applications, while test use cases will
likely want to just use Application
directly.
This class is static, there can only ever be a single application instance running at any time.Modifier and Type | Class and Description |
---|---|
(package private) static class |
ApplicationLifecycleManager.ShutdownHookThread |
Modifier and Type | Method and Description |
---|---|
static void |
exit()
Exits without supplying an exit code.
|
static void |
exit(int code)
Signals that the application should exit with the given code.
|
static Consumer<Integer> |
getDefaultExitCodeHandler() |
static int |
getExitCode() |
static boolean |
isVmShuttingDown() |
static void |
run(Application application,
Class<? extends QuarkusApplication> quarkusApplication,
Consumer<Integer> exitCodeHandler,
String... args) |
static void |
run(Application application,
String... args) |
static void |
setDefaultExitCodeHandler(Consumer<Integer> defaultExitCodeHandler)
Sets the default exit code handler for application run through the run method
that does not take an exit handler.
|
static void |
waitForExit()
Waits for the shutdown process to be initiated.
|
public static void run(Application application, String... args)
public static void run(Application application, Class<? extends QuarkusApplication> quarkusApplication, Consumer<Integer> exitCodeHandler, String... args)
public static int getExitCode()
public static void exit()
public static boolean isVmShuttingDown()
true
if the VM is shutting downpublic static void setDefaultExitCodeHandler(Consumer<Integer> defaultExitCodeHandler)
defaultExitCodeHandler
- the new default exit handlerpublic static void exit(int code)
code
- The exit codepublic static void waitForExit()
Copyright © 2020 JBoss by Red Hat. All rights reserved.