Interface BindingGraphContributor


public interface BindingGraphContributor
Observes binding registration and dependency resolution events in an InjectionContext. The Track 1 default is NOOP. Track 2 provides a real implementation that builds and maintains a BindingGraphTrait on the InjectionFramework's JDKCodeModel.

Register a contributor via InjectionFramework.setBindingGraphContributor(BindingGraphContributor). Every context created by that framework will call through to it; switching from the NOOP to a real implementation requires no changes to InjectionContext.

Since:
Apr-2026
Author:
reed.vonredwitz
See Also:
  • Field Details

    • NOOP

      static final BindingGraphContributor NOOP
      No-op implementation used until Track 2 installs a real contributor.
  • Method Details

    • buildTrait

      default Optional<BindingGraphTrait> buildTrait()
      Builds a BindingGraphTrait from the events accumulated so far. Returns Optional.empty() for implementations that do not maintain a graph (i.e. NOOP). InjectionContext calls this from Context.snapshot(Path) and no-ops immediately if the result is empty.
      Returns:
      an Optional containing the built trait, or empty if not supported
    • contributeBinding

      void contributeBinding(BindingNode node)
      Called each time a Binding is registered in an InjectionContext (including override registrations via toOverriding).
      Parameters:
      node - a description of the registered binding
    • contributeDependency

      void contributeDependency(BindingNode from, BindingNode to, DependencyEdge edge)
      Called each time a Dependency is resolved during injection. The from node is the binding whose injection point required the dependency; to is the binding that satisfied it.

      In Track 1, DependencyEdge.injectionPoint() is null and the from / to nodes may be null for auto-resolved or multibinding dependencies that are not registered as explicit class bindings.

      Parameters:
      from - the binding that required the dependency, or null if not determinable
      to - the binding that satisfied the dependency, or null if not determinable
      edge - the edge, carrying the originating injection point and the resolved dependency