-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quarkus: starts but beanManager is not accessible, something is missing
- Loading branch information
Showing
7 changed files
with
107 additions
and
15 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
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
10 changes: 10 additions & 0 deletions
10
...recipes/quarkus-recipe/src/main/java/com/trendyol/stove/recipes/quarkus/HelloService.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,10 @@ | ||
package com.trendyol.stove.recipes.quarkus; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
@ApplicationScoped | ||
public class HelloService { | ||
public String hello() { | ||
return "Hello from Quarkus Service"; | ||
} | ||
} |
68 changes: 64 additions & 4 deletions
68
...pes/quarkus-recipe/src/main/java/com/trendyol/stove/recipes/quarkus/QuarkusRecipeApp.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 |
---|---|---|
@@ -1,11 +1,71 @@ | ||
package com.trendyol.stove.recipes.quarkus; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.dev.appstate.ApplicationStateNotification; | ||
import io.quarkus.runtime.ApplicationLifecycleManager; | ||
import io.quarkus.runtime.Quarkus; | ||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import io.quarkus.runtime.QuarkusApplication; | ||
import jakarta.enterprise.inject.spi.BeanManager; | ||
|
||
@QuarkusMain | ||
public class QuarkusRecipeApp { | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.logging.Logger; | ||
|
||
import static io.quarkus.dev.appstate.ApplicationStateNotification.State.STARTED; | ||
|
||
class QuarkusApp implements QuarkusApplication { | ||
public static void main(String[] args) { | ||
Quarkus.run(args); | ||
var app = new QuarkusApp(); | ||
try { | ||
app.run(args); | ||
} catch (Exception e) { | ||
Logger.getLogger(QuarkusApp.class.getName()).severe("Failed to start Quarkus: " + e.getMessage()); | ||
System.exit(-1); | ||
} | ||
} | ||
|
||
@Override | ||
public int run(String... args) { | ||
QuarkusRecipeApp.run(args, "main"); | ||
return 0; | ||
} | ||
} | ||
|
||
|
||
public class QuarkusRecipeApp { | ||
public static BeanManager run(String[] args, String whereDoesItComeFrom) { | ||
System.out.println("Where does it come from? " + whereDoesItComeFrom); | ||
|
||
CompletableFuture<Boolean> startupComplete = new CompletableFuture<>(); | ||
ApplicationLifecycleManager.setAlreadyStartedCallback(started -> | ||
startupComplete.complete(true) | ||
); | ||
Thread quarkusThread = new Thread(() -> { | ||
Quarkus.run(args); | ||
}, "quarkus-main"); | ||
quarkusThread.setDaemon(true); | ||
quarkusThread.start(); | ||
|
||
try { | ||
while (ApplicationStateNotification.getState() != STARTED) { | ||
Thread.sleep(100); | ||
} | ||
|
||
while (ApplicationLifecycleManager.getCurrentApplication() == null) { | ||
Thread.sleep(1000); | ||
} | ||
|
||
return Arc.container().beanManager(); | ||
|
||
} catch (Exception e) { | ||
throw new RuntimeException("Failed to start Quarkus", e); | ||
} | ||
} | ||
|
||
public static void stop() { | ||
try { | ||
Arc.shutdown(); | ||
} finally { | ||
Quarkus.asyncExit(); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
recipes/java-recipes/quarkus-recipe/src/main/resources/application.properties
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,5 @@ | ||
quarkus.profile=prod | ||
quarkus.config.profile.parent=prod | ||
quarkus.live-reload.enabled=false | ||
quarkus.virtual-threads.enabled=true | ||
quarkus.banner.enabled=false |
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
6 changes: 6 additions & 0 deletions
6
...kus-recipe/src/test-e2e/kotlin/com/trendyol/stove/recipes/quarkus/e2e/tests/IndexTests.kt
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