Let’s say I have a class
public class Foo{
@Inject
public Foo(MessageBus messageBus, SomeServiceAsync service){
...
}
...
I have some doubt on how I would construct such a class, given that the constructor parameters are to be injected. Or must I somehow also get an instance of the Foo class through Gin (is that the case anyway for injection to take place)?
Thanks in advance
Your assumption is correct. You must get all
Foos from Gin if you want them to have their constuctors injected. To get aFoofrom Gin, you need to either have it injected into something else, or use aGinjector. Usually you’ll get only one class’ instances (or a small number of classes’ instances) from aGinjector, and rely on Gin to inject all of their dependencies, and their dependencies’ dependencies, and so on.The Gin Tutorial is a great place to start.