Am I right that method loadView will be called only once (when creating mainView bean)?
@Configuration
public class Config {
@Bean(name = "mainView")
public View getMainView() throws IOException {
return loadView("fxml/main.fxml");
}
@Bean
public MainController getMainController() throws IOException {
return (MainController) getMainView().getController();
}
@Bean
public Step1Controller getStep1Controller() throws IOException {
return getMainController().getStep1Controller();
}
...
}
All spring beans are singleton by default. So if you are not in a @Configuration simply your answer is YES.
CAUTION: In your situation if you call getMainView more than once while creating other beans which happens in @Configuration, it will be called multiple times, but just while creating.
Furthermore, I recommend you to read this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With