I have a simple hierarchy like follows:
public abstract class AbsFoo {
protected AbsBoo boo;
}
public class Foo extends AbsFoo {
public Foo() {
boo = new Boo(); // Boo extends AbsBoo
}
}
EDIT: Instances of AbsFoo should be created on the fly and may not be fields
Can I replace boo = new Boo() with injection?
Yes:
Make sure you construct your Foo instance with @Inject or injector.getInstance()
Edit
You can also use a provider to create instances on demand: