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 Summary
FieldsModifier and TypeFieldDescriptionstatic final BindingGraphContributorNo-op implementation used until Track 2 installs a real contributor. -
Method Summary
Modifier and TypeMethodDescriptiondefault Optional<BindingGraphTrait> Builds aBindingGraphTraitfrom the events accumulated so far.voidcontributeBinding(BindingNode node) Called each time aBindingis registered in anInjectionContext(including override registrations viatoOverriding).voidcontributeDependency(BindingNode from, BindingNode to, DependencyEdge edge) Called each time aDependencyis resolved during injection.
-
Field Details
-
NOOP
No-op implementation used until Track 2 installs a real contributor.
-
-
Method Details
-
buildTrait
Builds aBindingGraphTraitfrom the events accumulated so far. ReturnsOptional.empty()for implementations that do not maintain a graph (i.e.NOOP).InjectionContextcalls this fromContext.snapshot(Path)and no-ops immediately if the result is empty.- Returns:
- an
Optionalcontaining the built trait, or empty if not supported
-
contributeBinding
Called each time aBindingis registered in anInjectionContext(including override registrations viatoOverriding).- Parameters:
node- a description of the registered binding
-
contributeDependency
Called each time aDependencyis resolved during injection. Thefromnode is the binding whose injection point required the dependency;tois the binding that satisfied it.In Track 1,
DependencyEdge.injectionPoint()isnulland thefrom/tonodes may benullfor auto-resolved or multibinding dependencies that are not registered as explicit class bindings.- Parameters:
from- the binding that required the dependency, ornullif not determinableto- the binding that satisfied the dependency, ornullif not determinableedge- the edge, carrying the originating injection point and the resolved dependency
-