Skip to content

Commit f89650b

Browse files
committed
Apply very minor cleanup on ApplicationLifecycleManager
Just some minor things I saw when looking at the code
1 parent aa4edf1 commit f89650b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

core/runtime/src/main/java/io/quarkus/runtime/ApplicationLifecycleManager.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import javax.enterprise.context.spi.CreationalContext;
1010
import javax.enterprise.inject.Any;
1111
import javax.enterprise.inject.spi.Bean;
12+
import javax.enterprise.inject.spi.BeanManager;
1213
import javax.enterprise.inject.spi.CDI;
1314

1415
import org.graalvm.nativeimage.ImageInfo;
@@ -62,11 +63,11 @@ private ApplicationLifecycleManager() {
6263
private static boolean hooksRegistered;
6364
private static boolean vmShuttingDown;
6465

65-
public static final void run(Application application, String... args) {
66+
public static void run(Application application, String... args) {
6667
run(application, null, null, args);
6768
}
6869

69-
public static final void run(Application application, Class<? extends QuarkusApplication> quarkusApplication,
70+
public static void run(Application application, Class<? extends QuarkusApplication> quarkusApplication,
7071
Consumer<Integer> exitCodeHandler, String... args) {
7172
stateLock.lock();
7273
//in tests we might pass this method an already started application
@@ -90,7 +91,8 @@ public static final void run(Application application, Class<? extends QuarkusApp
9091
application.start(args);
9192
//now we are started, we either run the main application or just wait to exit
9293
if (quarkusApplication != null) {
93-
Set<Bean<?>> beans = CDI.current().getBeanManager().getBeans(quarkusApplication, new Any.Literal());
94+
BeanManager beanManager = CDI.current().getBeanManager();
95+
Set<Bean<?>> beans = beanManager.getBeans(quarkusApplication, Any.Literal.INSTANCE);
9496
Bean<?> bean = null;
9597
for (Bean<?> i : beans) {
9698
if (i.getBeanClass() == quarkusApplication) {
@@ -102,9 +104,8 @@ public static final void run(Application application, Class<? extends QuarkusApp
102104
if (bean == null) {
103105
instance = quarkusApplication.newInstance();
104106
} else {
105-
CreationalContext<?> ctx = CDI.current().getBeanManager().createCreationalContext(bean);
106-
instance = (QuarkusApplication) CDI.current().getBeanManager().getReference(bean,
107-
quarkusApplication, ctx);
107+
CreationalContext<?> ctx = beanManager.createCreationalContext(bean);
108+
instance = (QuarkusApplication) beanManager.getReference(bean, quarkusApplication, ctx);
108109
}
109110
int result = -1;
110111
try {
@@ -222,7 +223,7 @@ public static boolean isVmShuttingDown() {
222223
* By default this will just call System.exit, however this is not always
223224
* what is wanted.
224225
*
225-
* @param defaultExitCodeHandler
226+
* @param defaultExitCodeHandler the new default exit handler
226227
*/
227228
public static void setDefaultExitCodeHandler(Consumer<Integer> defaultExitCodeHandler) {
228229
Objects.requireNonNull(defaultExitCodeHandler);

0 commit comments

Comments
 (0)