-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29993 from dmlloyd/image-mode
Introduce `ImageMode` API
- Loading branch information
Showing
9 changed files
with
69 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
core/runtime/src/main/java/io/quarkus/runtime/ImageMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.quarkus.runtime; | ||
|
||
import org.graalvm.nativeimage.ImageInfo; | ||
|
||
/** | ||
* The image execution mode of the application. | ||
*/ | ||
public enum ImageMode { | ||
/** | ||
* The image mode which indicates that the application is running in a standard JVM. | ||
*/ | ||
JVM, | ||
/** | ||
* The image mode which indicates that the application is currently executing the build phase of a native static image. | ||
*/ | ||
NATIVE_BUILD, | ||
/** | ||
* The image mode which indicates that the application is a native static image which is currently running on a target | ||
* system. | ||
*/ | ||
NATIVE_RUN, | ||
; | ||
|
||
/** | ||
* Determine whether the application image is a native static image. | ||
* | ||
* @return {@code true} if the application image is a native static image, or {@code false} otherwise | ||
*/ | ||
public boolean isNativeImage() { | ||
return current() != JVM; | ||
} | ||
|
||
/** | ||
* Get the current image mode. Note that it is possible for the image mode to change during the lifetime of | ||
* an application. | ||
* | ||
* @return the image mode (not {@code null}) | ||
*/ | ||
public static ImageMode current() { | ||
if (ImageInfo.inImageBuildtimeCode()) { | ||
return NATIVE_BUILD; | ||
} else if (ImageInfo.inImageRuntimeCode()) { | ||
return NATIVE_RUN; | ||
} else { | ||
return JVM; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters