Interface CustomInjector
Custom injectors allow modules to provide alternative ways of resolving dependencies beyond the standard bean lookup. For example, a configuration module might provide an injector that resolves annotated parameters from configuration values.
Injectors are consulted in order (based on getOrder()) before falling back
to the default resolution. An injector should return InjectionResult.notHandled()
if it doesn't want to handle a particular injection point, allowing the next injector
or default resolution to proceed.
-
Method Summary
Modifier and TypeMethodDescriptiondefault intgetOrder()Returns the order of this injector.@NotNull InjectionResultresolve(@NotNull InjectionPoint injectionPoint) Attempts to resolve a dependency for the given injection point.booleansupports(@NotNull InjectionPoint injectionPoint) Determines whether this injector can handle the given injection point.
-
Method Details
-
supports
Determines whether this injector can handle the given injection point.This method should be fast as it's called for every injection point. Complex logic should be deferred to
resolve(InjectionPoint).- Parameters:
injectionPoint- the injection point to check, not null- Returns:
- true if this injector should attempt to resolve this injection point
-
resolve
Attempts to resolve a dependency for the given injection point.This method is only called if
supports(InjectionPoint)returned true. The injector should return:InjectionResult.handled(Object)if it successfully resolved the dependencyInjectionResult.notHandled()if it cannot resolve this particular injection and wants the framework to try other injectors or default resolution
- Parameters:
injectionPoint- the injection point to resolve, not null- Returns:
- the resolution result, never null
-
getOrder
default int getOrder()Returns the order of this injector.Injectors with lower order values are consulted first. The default order is 0. Use negative values for high-priority injectors, positive values for low-priority ones.
- Returns:
- the order value for this injector
-