本文整理汇总了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();
}
}
示例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();
}
示例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();
}
}
示例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();
}