Interface BindingContext


public interface BindingContext
The resolution surface of an injection driver: the engine calls it for every Injected field of a claimed instance and does not build it. The annotation stays dumb, the knowledge which local object serves a declaration lives here.

The vocabulary is deliberately Class, String and Object only: both halves of a lookup arrive as data, never as symbols, so an implementation may hand out a service without this interface naming one. The invocation target is opaque for the same reason – testing it against a provider contract belongs to the implementation, which may name such contracts, not to this interface, which may not.

  • Method Summary

    Modifier and Type
    Method
    Description
    getBinding(Class<?> type, List<Class<?>> typeArgs, String name, Class<?> declaringClass, Object target)
    Gets the local object serving the designated declaration or null if the environment does not provide it.
  • Method Details

    • getBinding

      Object getBinding(Class<?> type, List<Class<?>> typeArgs, String name, Class<?> declaringClass, Object target) throws InjectionException
      Gets the local object serving the designated declaration or null if the environment does not provide it. An unavailable binding leaves a tolerant field null and fails the claim of a Injected.required() one, which is the engine's decision, not this method's.
      Parameters:
      type - The effective type of the field, that is Injected.type() if given and the declared field type otherwise. This also selects the binding kind.
      typeArgs - The type arguments of the effective type in pre-order as in Injected.typeArgs(). This is empty if the declaration states none and the generic signature of the field pins none either.
      name - The qualifier of Injected.name() or null if the declaration states none.
      declaringClass - The class declaring the annotated field. This is the tag of a derived binding such as an instance-rooted logger.
      target - The target of the invocation carrying the claimed object or null if the driver resolves none, for instance at the reply of an outgoing call. This allows for serving a derived binding from the target instance where it provides them.
      Returns:
      The local object serving the designated declaration or null if the environment does not provide it.
      Throws:
      InjectionException - If the declaration cannot be honoured at all, for instance type arguments disagreeing with those of the resolved binding, an InjectionException will be thrown.