Package io.quarkus.runtime
Class Quarkus
- java.lang.Object
-
- io.quarkus.runtime.Quarkus
-
public class Quarkus extends Object
The entry point for applications that use a main method. Quarkus will shut down when the main method returns. If this application has already been generated then it will be run directly, otherwise it will be launched in dev mode and augmentation will be done automatically. If an application does not want to immediately shut down thenwaitForExit()
should be called, which will block until shutdown is initiated, either from an external signal or by a call to one of the exit methods. If no main class is specified then one is generated automatically that will simply wait to exit after Quarkus is booted.
-
-
Constructor Summary
Constructors Constructor Description Quarkus()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
asyncExit()
Exits the application in an async manner.static void
asyncExit(int code)
Exits the application in an async manner.static void
blockingExit()
Starts the shutdown process, then waits for the application to shut down.static void
run(Class<? extends QuarkusApplication> quarkusApplication, String... args)
Runs a quarkus application, that will run until the providedQuarkusApplication
has completed.static void
run(Class<? extends QuarkusApplication> quarkusApplication, BiConsumer<Integer,Throwable> exitHandler, String... args)
Runs a quarkus application, that will run until the providedQuarkusApplication
has completed.static void
run(String... args)
Starts a quarkus application, that will run until it either receives a signal (e.g.static void
waitForExit()
Method that will block until the Quarkus shutdown process is initiated.
-
-
-
Method Detail
-
run
public static void run(Class<? extends QuarkusApplication> quarkusApplication, String... args)
Runs a quarkus application, that will run until the providedQuarkusApplication
has completed. Note that if this is run from the IDE the application will run in a different class loader to the calling class. It is recommended that the calling class do no logic, and instead this logic should go into the QuarkusApplication.- Parameters:
quarkusApplication
- The application to run, or nullargs
- The command line parameters
-
run
public static void run(Class<? extends QuarkusApplication> quarkusApplication, BiConsumer<Integer,Throwable> exitHandler, String... args)
Runs a quarkus application, that will run until the providedQuarkusApplication
has completed. Note that if this is run from the IDE the application will run in a different class loader to the calling class. It is recommended that the calling class do no logic, and instead this logic should go into the QuarkusApplication.- Parameters:
quarkusApplication
- The application to run, or nullexitHandler
- The handler that is called with the exit code and any exception (if any) thrown when the application has finishedargs
- The command line parameters
-
run
public static void run(String... args)
Starts a quarkus application, that will run until it either receives a signal (e.g. user presses ctrl+c) or one of the exit methods is called. This method does not return, as System.exit() is called after the application is finished.- Parameters:
args
- The command line parameters
-
asyncExit
public static void asyncExit(int code)
Exits the application in an async manner. Calling this method will initiate the Quarkus shutdown process, and then immediately return. This method will unblock thewaitForExit()
method. Note that if the main thread is executing a Quarkus application this will only take effect ifwaitForExit()
has been called, otherwise the application will continue to execute (i.e. this does not initiate the shutdown process, it just signals the main thread that the application is done so that shutdown can run when the main thread returns). The error code supplied here will override the value returned from the main application.- Parameters:
code
- The exit code. This may be overridden if an exception occurs on shutdown
-
asyncExit
public static void asyncExit()
Exits the application in an async manner. Calling this method will initiate the Quarkus shutdown process, and then immediately return. This method will unblock thewaitForExit()
method. Note that if the main thread is executing a Quarkus application this will only take effect ifwaitForExit()
has been called, otherwise the application will continue to execute (i.e. this does not initiate the shutdown process, it just signals the main thread that the application is done so that shutdown can run when the main thread returns).
-
waitForExit
public static void waitForExit()
Method that will block until the Quarkus shutdown process is initiated. Note that this unblocks as soon as the shutdown process starts, not after it has finished.QuarkusApplication
implementations that wish to run some logic on startup, and then run should call this method.
-
blockingExit
public static void blockingExit()
Starts the shutdown process, then waits for the application to shut down. Must not be called by the main thread, or a deadlock will result.
-
-