avaje / avaje-inject

Dependency injection via APT (source code generation) ala "Server-Side Dagger DI"
https://avaje.io/inject
Apache License 2.0
240 stars 24 forks source link

Refactor simplify lazy to use existing OnceProvider #542

Closed rbygrave closed 6 months ago

rbygrave commented 6 months ago

Extracted this refactoring from #540

The existing .registerProvider() without a leading .asPrototype() is already a "lazy only once" style provider. This change uses that and then removes the LazyProvider and registerLazy() as they are no longer needed or used.

This also changes the synchronized block to use a ReentrantLock in OnceProvider just in case the provider invocation does something interesting and using Java 21+ Virtual Threads.