Bootstrap Code
Hook in the Bootstrap Process
GWTP aims to make the initial configuration of new projects as simple as possible. However, you may need to execute some code in a context usually handled by GWTP. There are a couple options available that should cover most needs.
Bootstrapper: Use a Bootstrapper if you need to execute code after GWTP and GIN are initialized, but before the default place is shown.
Pre-Bootstrapper: Use a Pre-Bootstrapper if you need to execute code before GWTP is initialized.
GIN module registration: You can register GIN modules directly in your .gwt.xml file. A common use case is to split your application into independent modules.
Ginjector Extensions: Register Ginjector extensions if you need to generate code that uses the Ginjector, which is itself generated by GWTP.
Custom Entry Point: If none of the preceding options fit your needs, you can use your own Entry Point the old fashioned way.
Bootstrapper {bootstrapper}
A Bootstrapper is executed code after GWTP and GIN are initialized, but before the default place is shown. You can only execute one Bootstrapper in your application. The Bootstrapper is also responsible for revealing the first place. If you forget to reveal a place in your Bootstrapper, your app will not open at all.. Since the Bootstrapper is loaded after GIN's initialization, you can use dependency injection.
A common use case for Bootstrappers is to check if a user is already logged in. If he is, the home page is displayed and if he is not, the login page is displayed.
To create a Bootstrapper, create a new class and implement Bootstrapper
:
Once you have a custom Bootstrapper, you need to register it in in your GWT module:
Pre-Bootstrapper {pre-bootstrapper}
To create a Pre-Bootstrapper, create a new class and implement PreBootstrapper
:
Once you have a custom Pre-Bootstrapper, you need to register it in in your GWT module:
GIN module registration {gin-modules}
You can register GIN modules directly in your .gwt.xml file. A common use case is to split your application into independent modules. You then have one or many application using all or a subset of the available modules.
Gin Modules are registered in your GWT module by adding the following line:
Ginjector Extensions {ginjector-extensions}
Ginjector extensions are useful if you need to add custom code to the Ginjector generated by GWTP. One of the very rare use-cases is when you write code-generators and their output needs access to code registered through GIN.
Custom Entry Point {custom-entrypoint}
In your GWT module, you need to inherit MVP
(as opposed to MvpWithEntryPoint
) and specify your own Entry Point:
Then, create your custom EntryPoint:
Note: The ApplicationController is what manages GWTP's bootstrap. So even if you have a custom Entry Point, all other options explained in this guide are still usable.
Last updated
Was this helpful?