public abstract class MvvmfxEasyDIApplication extends javafx.application.Application implements de.saxsys.mvvmfx.internal.MvvmfxApplication
Please note: EasyDI only supports constructor injection.
However when JavaFX bootstraps the Application constructors with arguments are not supported
for the application starter class.
This means that you can't inject dependencies into your application starter class directly.
Instead you can use the initEasyDi(EasyDI) method for this purpose.
See the following code example:
public class MyApp extends MvvmfxEasyDIApplication {
private Service service;
@Override
public void initEasyDi(EasyDI context) {
this.service = context.getInstance(Service.class);
}
@Override
public void startMvvmfx(Stage stage) {
service.someAction(); // use the injected service
// load your UI
}
}
Lifecycle notice. The application class goes through this lifecycle:
initEasyDi(EasyDI)MvvmfxApplication.initMvvmfx()MvvmfxApplication.startMvvmfx(Stage)MvvmfxApplication.stopMvvmfx()initEasyDi(EasyDI) method can be used
in the MvvmfxApplication.initMvvmfx() and MvvmfxApplication.startMvvmfx(Stage) methods.| Constructor and Description |
|---|
MvvmfxEasyDIApplication() |
| Modifier and Type | Method and Description |
|---|---|
void |
init() |
protected void |
initEasyDi(eu.lestard.easydi.EasyDI context)
This method is used for initialization of the EasyDI context.
|
void |
start(javafx.stage.Stage primaryStage) |
void |
stop() |
getHostServices, getParameters, getUserAgentStylesheet, launch, launch, notifyPreloader, setUserAgentStylesheetclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinitMvvmfx, startMvvmfx, stopMvvmfxpublic final void start(javafx.stage.Stage primaryStage)
throws Exception
start in class javafx.application.ApplicationExceptionpublic final void stop()
throws Exception
stop in class javafx.application.ApplicationExceptionpublic final void init()
throws Exception
init in class javafx.application.ApplicationExceptionprotected void initEasyDi(eu.lestard.easydi.EasyDI context)
throws Exception
EasyDI.bindInterface(Class, Class) or EasyDI.bindProvider(Class, Provider).
Additionally this method can be used to get instances of dependencies that are needed
for the start process of the application (for example in the MvvmfxApplication.startMvvmfx(Stage) method).
Lifecycle notice:
This method is invoked by the framework before the invokation of MvvmfxApplication.initMvvmfx()
and MvvmfxApplication.startMvvmfx(Stage).
context - The EasyDI instance that is responsible for injecting all needed instances in the current application.Exception - If any error occurs while binding interfaces.Copyright © 2017 Saxonia Systems AG. All rights reserved.