Let's Build a Dependency Injection Framework
summary
Live codes a DI system implemented as an annotation processor that uses JavaPoet to generate a concrete scope implementation at compile time, producing provider methods named from return types, resolving constructor parameters by calling other provider methods, and adding per-type private fields plus null-checked assignments to implement caching so repeated requests return the same instance. The processor writes generated classes to the filer so they compile with the app. Mentions Motif and a claimed 75% reduction in DI boilerplate.
AI-written summary · about
chapters (11)
- 0:00Introduction and goals
- 1:14Setting up the project
- 3:19Defining the DI API
- 7:46Writing the annotation processor
- 12:39Generating the implementation class
- 15:31Overriding access methods
- 18:18Implementing provider methods
- 23:18Resolving dependencies
- 25:48Adding caching logic
- 29:22Testing the generated code
- 30:49Final thoughts and alternatives
related talks
31mBuild your own Dependency Injection framework!
37mAdvanced multi-platform dependency injection
56mDI Frameworks – some hidden pearls
49mReaders vs Constructors: Dependency Injection showdown
05mDependency Injection
40mFundamentals of Dependency Injection
01h 00mFantastic Frameworks and How to Avoid Them
34mJava Modules meet Dependency Injection
