Trace:
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
jvx:reference [2020/06/10 13:02] cduncan [Launchers and Applications] |
jvx:reference [2020/06/10 13:05] cduncan [Entry point] |
||
---|---|---|---|
Line 426: | Line 426: | ||
Then, and only then, the [[https://sourceforge.net/projects/jvx/|JVx]] application can run. Depending on the implementation that is used, that can be as easily as instancing the factory (Swing, JavaFX), but can also mean that a servlet server has to start (Vaadin). Because we do not wish to encumber our applications with technology specific code, we have to entrust all this to an encapsulated entity, meaning the implementations of ''%%ILauncher%%'' and ''%%IApplication%%''. | Then, and only then, the [[https://sourceforge.net/projects/jvx/|JVx]] application can run. Depending on the implementation that is used, that can be as easily as instancing the factory (Swing, JavaFX), but can also mean that a servlet server has to start (Vaadin). Because we do not wish to encumber our applications with technology specific code, we have to entrust all this to an encapsulated entity, meaning the implementations of ''%%ILauncher%%'' and ''%%IApplication%%''. | ||
- | ===== Following the chain ===== | + | ===== Following the Chain ===== |
The steps for getting an application to start are as follows: | The steps for getting an application to start are as follows: | ||
- | * The first thing that must run is obviously the JVM, without it we won’t have much luck starting anything. | + | * The first thing that must run is, obviously, the JVM. Without it, we won’t have much luck starting anything! |
- | * The launcher must be created and it must start the Technology. | + | * The launcher must be created, and it must start the technology. |
- | * The launcher than creates the application which the user is seeing. | + | * The launcher then creates the application, which the user is seeing. |
{{:jvx:reference:launcher.png?nolink|First the JVM starts, then the ILauncher (the window) and finally the IApplication (the content).}} | {{:jvx:reference:launcher.png?nolink|First the JVM starts, then the ILauncher (the window) and finally the IApplication (the content).}} | ||
- | So we need two classes, the ''%%ILauncher%%'' implementation which knows how to start the Technology and the ''%%IApplication%%'' implementation. That we already knew, so let’s try to put this into code. For simplicity reasons (and because I don’t want to write a complete factory from scratch for this example) we will reuse the Swing implementation and write a new launcher and application for it. | + | So we need two classes, the ''%%ILauncher%%'' implementation that knows how to start the technology and the ''%%IApplication%%'' implementation. That we already knew, so let’s try to put this into code. For simplicity reasons (and because I don’t want to write a complete factory from scratch for this example), we will reuse the Swing implementation and write a new launcher and application for it. |
- | ===== Entry point ===== | + | ===== Entry Point ===== |
- | The ''%%Main%%'' class that we will use as example is very straightforward: | + | The ''%%main%%'' class that we will use as example is very straightforward: |
<code java> | <code java> | ||
Line 457: | Line 457: | ||
} | } | ||
</code> | </code> | ||
- | All we have to do there is start the launcher itself. As the comment suggests, there might be work required for a “real” application startup. For this example, it is all we need to do. Of course we could also directly embed this little function into the launcher implementation itself, to save us one class. | + | All we have to do there is start the launcher itself. As the comment suggests, there might be work required for a “real” application startup. For this example, it is all we need to do. Of course, we could also directly embed this little function into the launcher implementation itself to save us one class. |
===== The launcher ===== | ===== The launcher ===== |