Assuming I have something like so
Interface
Interface IsInterface {}
Implementation Classes
public ConcreteClassA implements IsInterface {
InjectorA a, InjectorB c, InjectorC c;
@Inject
ConcreteClassA(InjectorA a, InjectorB b, InjectorC c) {
this.a = a;
this.b = b;
.....
}
}
public ConcreteClassB implements IsInterface {
InjectorA a, InjectorB B, InjectorC C;
@Inject
ConcreteClassB(InjectorA a, InjectorB b, InjectorC c) {
this.a = a;
this.b = b;
.....
}
}
..and then I decide to use GWT deferred binding so in my GWT module.gwt.xml
//Pseudo XML Configuration
if (type is IsInterface)
if toggle == A then use ConcreteClass A else use ConcreteClassB
Now, when I try to run this. It won't work because GWT expected my Concrete Class A and B to have default 0 constructor. So, I tried the following on my concrete class
@Inject
InjectorA a;
@Inject
InjectorB b;
@Inject
InjectorC c;
ConcreteClassA() {
}
which bypass the 0 constructor error but it gives me NullPointerException when I try to use a, b or c. One way to make it to work is to remove @Inject and use GWT.create() like so
InjectorA a, InjectorB b, InjectorC c;
ConcreteClassA() {
this.a = GWT.create(InjectorA.class);
.....
.....
}
This will work but what if my InjectorA, InjectorB and InjectorC have none 0 constructor and depended heavily on @inject. I dont want to go through all the classes to create 0 constructors and replace @inject with GWT.create(). There has to be a better way to do this. Am I missing something here?