Common use case for a DI container. Rather than annotating fields, a single constructor would carry the annotation, and all of its arguments would be injected during construction for an @Autowired field of that type. This is an alternative to directly annotating fields that often allows for less type-fu when unit testing, as well as the ability to turn off Iroh altogether and just pass in the correct instances manually.
public class Example {
@Component
public static class Dependency { ... }
@Autowired
public Example(Dependency a) {
Assert.assertNotNull(a);
}
@Test
public void testAutowiredConstructor() { ... }
}
Common use case for a DI container. Rather than annotating fields, a single constructor would carry the annotation, and all of its arguments would be injected during construction for an
@Autowired
field of that type. This is an alternative to directly annotating fields that often allows for less type-fu when unit testing, as well as the ability to turn off Iroh altogether and just pass in the correct instances manually.