How properly initialize JBoss Weld in Java SE without using org.jboss.weld.environment.se.StartMain#main?
-
29-10-2019 - |
Вопрос
I'm working on a JavaFX 2 project and the application must be launched using another main method (com.javafx.main.Main according to the generated JAR manifest). According to the official Weld reference the bootstrapping involves launching the application via org.jboss.weld.environment.se.StartMain
which is impossible to do in my (edge) case... However, looking at the source, the org.jboss.weld.environment.se.StartMain#main
method only has one line of code in it:
new StartMain(args).go();
So, I figured I'll just use that particular line of code in my application at the "right time" (alternatively, I could've just called StartMain.main(args) from within my app). But I'm not confident if there are any repercussions to doing this. Does anyone know of a better way of accomplishing this?
Versions:
JavaFX 2.0.2
Weld 2.0.0.Alpha1
Решение
Grab at least 1.1.3 Final version of Weld and initialize your container via the main Weld class, as versus using StartMain:
WeldContainer weld = new Weld().initialize();