本文整理汇总了Java中com.google.inject.Stage.DEVELOPMENT属性的典型用法代码示例。如果您正苦于以下问题:Java Stage.DEVELOPMENT属性的具体用法?Java Stage.DEVELOPMENT怎么用?Java Stage.DEVELOPMENT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.inject.Stage
的用法示例。
在下文中一共展示了Stage.DEVELOPMENT属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
@Override
protected void configure() {
// @InjectorScoped annotation
install(new InjectorScopeModule());
// Provide a global, catch-all exception handler
bind(LoggingExceptionHandler.class).in(Singleton.class);
bind(ExceptionHandler.class).to(LoggingExceptionHandler.class);
bind(new TypeLiteral<ExceptionHandler<Throwable>>(){}).to(LoggingExceptionHandler.class);
bind(Thread.UncaughtExceptionHandler.class).to(LoggingExceptionHandler.class);
// Evil decorator thing
// Create it manually so we can use it before the injector is ready
bind(DecoratorFactory.class).toInstance(DecoratorFactory.get());
install(new NumberFactory.Manifest());
install(new ParsersManifest());
requestStaticInjection(SystemFutureCallback.class);
if(currentStage() == Stage.DEVELOPMENT) {
// This is useful, but it makes the LeakDetector unhappy
//install(new RepeatInjectionDetector());
}
}
示例2: getGuiceStage
public Stage getGuiceStage(){
String stageString = System.getProperty(PROPERTY_NAME);
final Stage stage;
boolean development = Stage.DEVELOPMENT.name().equals(stageString);
boolean production = Stage.PRODUCTION.name().equals(stageString);
if(development || production){
stage = development ? Stage.DEVELOPMENT : Stage.PRODUCTION;
logger.warn("using Guice Stage {} from JVM arg -D{}={}", stage, PROPERTY_NAME, stageString);
}else if(stageString != null){
stage = Stage.PRODUCTION;
logger.warn("unrecognized JVM arg value -D{}={}, using Guice Stage {}", PROPERTY_NAME, stageString,
Stage.PRODUCTION);
}else{
stage = Stage.PRODUCTION;
logger.warn("using default Guice Stage={}", Stage.PRODUCTION);
}
return stage;
}
示例3: getInjector
@Override
protected Injector getInjector() {
/**
* This is called by super's contextInitialized.
*
* Must be created here in order for the modules to be initialized
* correctly.
*/
if (this.injectorSupport == null) {
this.injectorSupport = new InjectorSupport(
new Module[]{
new AppTestModule(),
new ServletTestModule()
},
Stage.DEVELOPMENT);
}
return this.injectorSupport.getInjector();
}
示例4: currentStage
@Override
public Stage currentStage() {
switch (delegate.currentStage()) {
case DEVELOPMENT:
return Stage.DEVELOPMENT;
case PRODUCTION:
return Stage.PRODUCTION;
default:
throw new UnsupportedOperationException();
}
}
示例5: stage
protected Stage stage() {
if (System.getenv("TEST") != null || System.getenv("DEV") != null)
return Stage.DEVELOPMENT;
return Stage.PRODUCTION;
}
示例6: initialize
/**
* Initializes the Para core modules and allows the user to override them. Call this method first.
*
* @param modules a list of modules that override the main modules
*/
public static void initialize(Module... modules) {
if (injector == null) {
printLogo();
try {
logger.info("--- Para.initialize() [{}] ---", Config.ENVIRONMENT);
Stage stage = Config.IN_PRODUCTION ? Stage.PRODUCTION : Stage.DEVELOPMENT;
List<Module> coreModules = Arrays.asList(modules);
List<Module> externalModules = getExternalModules();
if (coreModules.isEmpty() && externalModules.isEmpty()) {
logger.warn("No implementing modules found. Aborting...");
destroy();
return;
}
if (!externalModules.isEmpty()) {
injector = Guice.createInjector(stage, Modules.override(coreModules).with(externalModules));
} else {
injector = Guice.createInjector(stage, coreModules);
}
addInitListener(CoreUtils.getInstance());
addInitListener(HealthUtils.getInstance());
addInitListener(MetricsUtils.getInstance());
for (InitializeListener initListener : INIT_LISTENERS) {
if (initListener != null) {
injectInto(initListener);
initListener.onInitialize();
logger.debug("Executed {}.onInitialize().", initListener.getClass().getName());
}
}
// this enables the "River" feature - polls the default queue for objects and imports them into Para
if (Config.getConfigBoolean("queue_link_enabled", false) && HealthUtils.getInstance().isHealthy()) {
injector.getInstance(Queue.class).startPolling();
}
logger.info("Instance #{} initialized.", Config.WORKER_ID);
} catch (Exception e) {
logger.error(null, e);
}
}
}