Package org.elasticsearch.injection


package org.elasticsearch.injection
Our dependency injection technologies: our bespoke injector, plus our legacy vendored version of Google Guice.

Usage

The new injector is Injector. You create an instance using Injector.create(), call various methods like Injector.addClass(java.lang.Class<?>) to configure it, then call Injector.inject(java.util.Collection<? extends java.lang.Class<?>>) to cause the constructors to be called.

Operation

Injection proceeds in three phases:
  1. Configuration: the Injector captures the user's intent in the form of InjectionSpec objects, one for each class.
  2. Planning: the Planner analyzes the InjectionSpec objects, validates them, and generates a plan in the form of a list of InjectionStep objects.
  3. Execution: the PlanInterpreter runs the steps in the plan, in sequence, to actually instantiate the objects and pass them to each others' constructors.

Google Guice

The older injector, based on Google Guice, is in the guice package. The new injector is unrelated to Guice, and is intended to replace Guice eventually.