Build your own Dependency Injection framework!
summary
Builds a tiny DI framework called the Injectinator using Java reflection and Maven on Java 8/11/15, proving the magic is just code. It defines a @InjectMe annotation with runtime retention and targets for constructor field and method use, a Syringe that maps interfaces to implementation classes, and recursive resolution for nested dependencies. It implements constructor field and setter injection and toggles InjectionType enum between singleton and new instances; the demo logger injection works as expected.
AI-written summary · about
chapters (11)
- 0:00Dependency Injection intro
- 3:04Reflection in Java
- 4:51InjectMe annotation
- 6:15Syringe configuration
- 10:51Injectinator core
- 13:21Field injection
- 16:51Constructor injection
- 20:00Setter injection
- 24:55Singleton vs new instance
- 27:01Adding singleton support
- 30:14Conclusion & Q&A
related talks
32mLet's Build a Dependency Injection Framework
37mAdvanced multi-platform dependency injection
11mBuild your own @MiniService
34mJava Modules meet Dependency Injection
40mFundamentals of Dependency Injection
21mMinimalist Dependency Injection in Kotlin
56mDI Frameworks – some hidden pearls
49mReaders vs Constructors: Dependency Injection showdown
