当前位置: 首页>>代码示例>>Java>>正文


Java Stage.TOOL属性代码示例

本文整理汇总了Java中com.google.inject.Stage.TOOL属性的典型用法代码示例。如果您正苦于以下问题:Java Stage.TOOL属性的具体用法?Java Stage.TOOL怎么用?Java Stage.TOOL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.inject.Stage的用法示例。


在下文中一共展示了Stage.TOOL属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: build

public Injector build() {
  if (shellBuilder == null) {
    throw new AssertionError("Already built, builders are not reusable.");
  }

  // Synchronize while we're building up the bindings and other injector state. This ensures that
  // the JIT bindings in the parent injector don't change while we're being built
  synchronized (shellBuilder.lock()) {
    shells = shellBuilder.build(initializer, bindingData, stopwatch, errors);
    stopwatch.resetAndLog("Injector construction");

    initializeStatically();
  }

  injectDynamically();

  if (shellBuilder.getStage() == Stage.TOOL) {
    // wrap the primaryInjector in a ToolStageInjector
    // to prevent non-tool-friendy methods from being called.
    return new ToolStageInjector(primaryInjector());
  } else {
    return primaryInjector();
  }
}
 
开发者ID:google,项目名称:guice,代码行数:24,代码来源:InternalInjectorCreator.java

示例2: injectDynamically

/**
 * Inject everything that can be injected. This method is intentionally not synchronized. If we
 * locked while injecting members (ie. running user code), things would deadlock should the user
 * code build a just-in-time binding from another thread.
 */
private void injectDynamically() {
  injectionRequestProcessor.injectMembers();
  stopwatch.resetAndLog("Static member injection");

  initializer.injectAll(errors);
  stopwatch.resetAndLog("Instance injection");
  errors.throwCreationExceptionIfErrorsExist();

  if (shellBuilder.getStage() != Stage.TOOL) {
    for (InjectorShell shell : shells) {
      loadEagerSingletons(shell.getInjector(), shellBuilder.getStage(), errors);
    }
    stopwatch.resetAndLog("Preloading singletons");
  }
  errors.throwCreationExceptionIfErrorsExist();
}
 
开发者ID:google,项目名称:guice,代码行数:21,代码来源:InternalInjectorCreator.java

示例3: injectMembers

void injectMembers() {
  InternalContext context = injector.enterContext();
  try {
    boolean isStageTool = injector.options.stage == Stage.TOOL;
    for (SingleMemberInjector memberInjector : memberInjectors) {
      // Run injections if we're not in tool stage (ie, PRODUCTION or DEV),
      // or if we are in tool stage and the injection point is toolable.
      if (!isStageTool || memberInjector.getInjectionPoint().isToolable()) {
        try {
          memberInjector.inject(context, null);
        } catch (InternalProvisionException e) {
          errors.merge(e);
        }
      }
    }
  } finally {
    context.close();
  }
}
 
开发者ID:google,项目名称:guice,代码行数:19,代码来源:InjectionRequestProcessor.java

示例4: injectDynamically

/**
 * Inject everything that can be injected. This method is intentionally not synchronized. If we
 * locked while injecting members (ie. running user code), things would deadlock should the user
 * code build a just-in-time binding from another thread.
 */
private void injectDynamically() {
  injectionRequestProcessor.injectMembers();
  stopwatch.resetAndLog("Static member injection");

  initializer.injectAll(errors);
  stopwatch.resetAndLog("Instance injection");
  errors.throwCreationExceptionIfErrorsExist();

  if(shellBuilder.getStage() != Stage.TOOL) {
    for (InjectorShell shell : shells) {
      loadEagerSingletons(shell.getInjector(), shellBuilder.getStage(), errors);
    }
    stopwatch.resetAndLog("Preloading singletons");
  }
  errors.throwCreationExceptionIfErrorsExist();
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:21,代码来源:InternalInjectorCreator.java


注:本文中的com.google.inject.Stage.TOOL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。