I'm trying to get Weld to work inside my JavaFX 2 (SE) application (or should I say that JavaFX is inside Weld?). I have controllers that respond to user interaction. Now I would like to introduce my services, for example, the database service, for example, into these controllers.
Using Weld should be as simple as:
@Inject
private MyService service;
Now, to initialize Weld, there are three options.
Option 1)
public void main(@Observes ContainerInitialized event) {
launch();
}
Option 2)
public static void main(final String[] args) {
new StartMain(args).go();
launch(args);
}
Option 3)
public static void main(final String[] args) {
final WeldContainer weld = new Weld().initialize();
service = weld.instance().select(MyService.class).get();
launch(args);
}
1 2 NullPointerExceptions , . 3 , , , , , JavaFX. 3 - , Weld. , beans JavaFX? , .
, - Weld JavaFX .
Weld, . , Weld JavaFX. , , (. ).
2
Weld JavaFX 2. , , .