Chapter 1. Dependency injection: what’s all the hype?
Listing 1.1. An email service that checks spelling in English
Listing 1.2. An email service whose spellchecker is set via constructor
Listing 1.3. A “French” email service Factory pattern
Listing 1.4. A Factory that constructs a Japanese emailer
Listing 1.5. A client uses Emailer to send messages typed by a user
Listing 1.6. Test sets up a mock instance for EmailClient using Emailer’s Factory
Listing 1.7. A client uses Emailer to send messages typed by a user
Listing 1.8. Factories that create either French or Japanese email services
Listing 1.9. An Emailer and a client
Chapter 2. Time for injection
Listing 2.1. An emailer with a spellchecker
Listing 2.2. Spring’s injector configuration, email.xml
Listing 2.3. The emailer, stripped of annotations
Listing 2.4. A typical Guice module
Listing 2.5. Guice module registering emailers
Listing 2.6. Slightly neater module registering emailers
Listing 2.7. The emailer, now with two dependencies
Listing 2.8. Injector bootstrap and using the emailer with its engine
Listing 2.9. An email service with French or English spellcheckers
Listing 2.10. Variants of an email service using namespaces
Listing 2.11. A compact form of listing 2.10
Listing 2.12. Poorly chosen keys for services (in pseudocode configuration)
Listing 2.13. Good-practice version of listing 2.12
Listing 2.14. The fixed version of games.xml
Listing 2.15. The class com.nintendo.Wii bound to key nintendo.wii