I have the following GWT module:
public class FizzModule implements EntryPoint {
private Buzz buzz;
public FizzModule() {
this(null);
}
public FizzModule(Buzz bz) {
super();
setBuzz(bz);
}
@Override
public void onModuleLoad() {
// ...etc.
}
}
I would like to "inject" FizzModule
with a Buzz
instance. However, all of the code examples I see for GWT modules do not use constructors. Instead, they bootstrap the DI mechanism (typically either ClientFactory or GIN) from inside the onModuleLoad()
method. Is this something that GWT forces, or can I somehow inject my module before it loads to the client-side? Thanks in advance!
GWT instantiates your module using its zero-arg constructor, always.
(technically, I think it uses GWT.create()
so you could use deferred binding rules, but that wouldn't change anything re. how its instantiated)
BTW, where would the Buzz
instance come from?