Class FxLauncherAbstract

java.lang.Object
app.supernaut.fx.FxLauncherAbstract
All Implemented Interfaces:
FxLauncher
Direct Known Subclasses:
MicronautFxLauncher, SimpleFxLauncher

public abstract class FxLauncherAbstract extends Object implements FxLauncher
Base JavaFX implementation of FxLauncher. This implementation provides the following functionality:
  1. Starts OpenJFX applications.
  2. Constructor provides an option to start BackgroundApp on a new thread (this allows the BackgroundApp and the OpenJFX ApplicationDelegate to initialize in parallel.)
  3. Implements FxLauncher.launchAsync(java.lang.String[], java.lang.Class<? extends app.supernaut.fx.ApplicationDelegate>, java.lang.Class<? extends app.supernaut.BackgroundApp>) which initializes the OpenJFX ApplicationDelegate on a new thread. This is not needed for a typical, packaged OpenJFX application which can just call FxLauncher.launch(java.lang.String[], java.lang.Class<? extends app.supernaut.fx.ApplicationDelegate>, java.lang.Class<? extends app.supernaut.BackgroundApp>) from its static main(), but is useful in various testing scenarios.
  4. Defines the FxLauncherAbstract.AppFactory interface for constructing the BackgroundApp and ApplicationDelegate. This allows subclasses (or callers) to provide their own implementation of the application creation logic. The AppFactory interface was designed to allow usage of Dependency Injection frameworks like Micronaut to create dependency-injected implementations of ApplicationDelegate and BackgroundApp. The AppFactory interface was also designed to be lazily-instantiated so the AppFactory (dependency-injection framework) can initialize in parallel to OpenJFX.
  5. Uses the same AppFactory (dependency-injection context) to initialize the ApplicationDelegate and Background application. A CountDownLatch is used to make sure the AppFactory (which may be initialized on another thread along with the BackgroundApp) is ready when OpenJfxProxyApplication calls createAppDelegate(Application proxyApplication).