public interface CustomInjector
Interface for custom dependency injectors that can participate in the resolution process.

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 Type
    Method
    Description
    default int
    Returns the order of this injector.
    resolve(@NotNull InjectionPoint injectionPoint)
    Attempts to resolve a dependency for the given injection point.
    boolean
    supports(@NotNull InjectionPoint injectionPoint)
    Determines whether this injector can handle the given injection point.
  • Method Details

    • supports

      boolean supports(@NotNull @NotNull InjectionPoint injectionPoint)
      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

      @NotNull @NotNull InjectionResult resolve(@NotNull @NotNull InjectionPoint injectionPoint)
      Attempts to resolve a dependency for the given injection point.

      This method is only called if supports(InjectionPoint) returned true. The injector should return:

      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