Constructor injection supplies an object’s dependencies as constructor arguments. Unlike setter injection, it makes the dependencies available when the object is created, avoiding objects that have only some dependencies configured. section 4.4.4
The approach has practical tradeoffs:
- Long lists of dependencies can clutter a constructor, though they may signal a design flaw. section 4.4.4
- Framework code cannot use constructor injection to supply dependencies to an existing object, and production code still needs some mechanism to wire dependencies. section 4.4.4
A servlet constraint
A servlet container instantiates LoginServlet, so its AuthenticationService cannot be supplied through constructor injection without overloading the constructor for testing. The example instead postpones the wiring decision and uses an overridable getter to provide a fake service in tests. section 5.2.1

