Interface DependencyInjector
- All Known Implementing Classes:
DefaultDependencyInjector
public interface DependencyInjector
Central registry for dependencies and producing methods. Registered dependencies will be injected with the
corresponding values if present, else null.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Scans the whole classpath for methods annotated withProduces
.void
Injects all registered dependencies with the corresponding value.void
registerDependencies
(@NotNull Class<?> clazz, @NotNull List<Field> fields) Registers fields inside a class as dependencies.void
registerProvider
(@NotNull Object provider) Takes an instance of a class and scans it for methods annotated withProduces
.
-
Method Details
-
index
Scans the whole classpath for methods annotated withProduces
. If found, creates a new instance of the declaring class and will call the method to retrieve the object and register it as a dependency. If the method is declared as static, no instance will be created. UseregisterProvider(Object)
if no new instance of the declaring class should be created.- Parameters:
clazz
- a class of the classpath to scanpackages
- package(s) to exclusively scan
-
registerProvider
-
registerDependencies
-
inject
Injects all registered dependencies with the corresponding value. If no value is presentnull
gets injected.
-