Example #1
0
  /**
   * Builds the.
   *
   * @return the injector
   */
  Injector build() {
    if (shellBuilder == null) {
      throw new AssertionError("Already built, builders are not reusable.");
    }

    synchronized (shellBuilder.lock()) {
      shells = shellBuilder.build(initializer, bindingProcesor, stopwatch, errors);
      stopwatch.resetAndLog("Injector construction");

      initializeStatically();
    }

    if (stage == Stage.TOOL) {
      return new ToolStageInjector(primaryInjector());
    }

    injectDynamically();

    return primaryInjector();
  }
Example #2
0
 /**
  * Parent injector.
  *
  * @param parent the parent
  * @return the injector builder
  */
 InjectorBuilder parentInjector(InjectorImpl parent) {
   shellBuilder.parent(parent);
   return stage(parent.getInstance(Stage.class));
 }
Example #3
0
 /**
  * Adds the modules.
  *
  * @param modules the modules
  * @return the injector builder
  */
 InjectorBuilder addModules(Iterable<? extends Module> modules) {
   shellBuilder.addModules(modules);
   return this;
 }
Example #4
0
 /**
  * Stage.
  *
  * @param stage the stage
  * @return the injector builder
  */
 InjectorBuilder stage(Stage stage) {
   shellBuilder.stage(stage);
   this.stage = stage;
   return this;
 }