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


Java Stage类代码示例

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


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

示例1: configure

import com.google.inject.Stage; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:27,代码来源:UtilCoreManifest.java

示例2: getGuiceStage

import com.google.inject.Stage; //导入依赖的package包/类
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;
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:19,代码来源:GuiceStageFinder.java

示例3: initialize

import com.google.inject.Stage; //导入依赖的package包/类
@Override
public void initialize(Bootstrap<ServerConfiguration> bootstrap) {
    bootstrap.addBundle(hibernateBundle);

    bootstrap.addBundle(new AssetsBundle("/swagger-spec", "/api-spec", null));

    bootstrap.addBundle(GuiceBundle.<ServerConfiguration>newBuilder()
        .addModule(new AbstractModule(){
            @Override protected void configure() {}
            @Provides SessionFactory sessionFactoryProvider() { return hibernateBundle.getSessionFactory();}
        })
        .setConfigClass(ServerConfiguration.class)
        .enableAutoConfig(getClass().getPackage().getName())
        .build(Stage.DEVELOPMENT)
    );

    bootstrap.addBundle(new Java8Bundle());

    // Enable variable substitution with environment variables
    bootstrap.setConfigurationSourceProvider(
        new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(),
            new EnvironmentVariableSubstitutor(false)
        )
    );
}
 
开发者ID:gov-ithub,项目名称:StopCozi-api,代码行数:26,代码来源:Server.java

示例4: main

import com.google.inject.Stage; //导入依赖的package包/类
public static void main(String... args) {
  final long start = System.currentTimeMillis();

  try {
    final Injector injector = Guice.createInjector(Stage.PRODUCTION, new SingularityRunnerBaseModule(SingularityExecutorCleanupConfiguration.class, ImmutableSet.of(SingularityS3Configuration.class, SingularityExecutorConfiguration.class)), new SingularityExecutorModule(), new SingularityExecutorCleanupModule(), new SingularityClientModule(), new SingularityMesosClientModule());

    final SingularityExecutorCleanupRunner runner = injector.getInstance(SingularityExecutorCleanupRunner.class);

    LOG.info("Starting cleanup");

    final SingularityExecutorCleanupStatistics statistics = runner.cleanup();

    LOG.info("Finished with {} after {}", statistics, JavaUtils.duration(start));

    System.exit(0);
  } catch (Throwable t) {
    LOG.error("Finished after {} with error", JavaUtils.duration(start), t);
    System.exit(1);
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:21,代码来源:SingularityExecutorCleanupRunner.java

示例5: main

import com.google.inject.Stage; //导入依赖的package包/类
public static void main(String... args) {
  final long start = System.currentTimeMillis();

  try {
    final Injector injector = Guice.createInjector(Stage.PRODUCTION, new SingularityRunnerBaseModule(SingularityExecutorConfiguration.class, ImmutableSet.<Class<? extends BaseRunnerConfiguration>>of(SingularityS3Configuration.class)), new SingularityExecutorModule());
    final SingularityExecutorRunner executorRunner = injector.getInstance(SingularityExecutorRunner.class);

    final Protos.Status driverStatus = executorRunner.run();

    LOG.info("Executor finished after {} with status: {}", JavaUtils.duration(start), driverStatus);

    System.exit(driverStatus == Protos.Status.DRIVER_STOPPED ? 0 : 1);
  } catch (Throwable t) {
    LOG.error("Finished after {} with error", JavaUtils.duration(start), t);
    System.exit(1);
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:SingularityExecutorRunner.java

示例6: initialize

import com.google.inject.Stage; //导入依赖的package包/类
@Override
public void initialize(final Bootstrap<ProductCatalogConfiguration> bootstrap) {
	bootstrap.addBundle(discoveryBundle);
	bootstrap.addBundle(new MigrationsBundle<ProductCatalogConfiguration>() {

		@Override
		public PooledDataSourceFactory getDataSourceFactory(ProductCatalogConfiguration configuration) {
			return configuration.getDataSourceFactory();
		}
	});
	guiceBundle = GuiceBundle.<ProductCatalogConfiguration> newBuilder().addModule(new ProductCatalogModule())
			.enableAutoConfig(getClass().getPackage().getName()).setConfigClass(ProductCatalogConfiguration.class)
			.build(Stage.PRODUCTION);
	bootstrap.addBundle(guiceBundle);
	// Uncomment below to read the yaml file from Jar
	// bootstrap.setConfigurationSourceProvider(new
	// ResourceConfigurationSourceProvider());
}
 
开发者ID:G1GC,项目名称:dropwizard-microservices-example,代码行数:19,代码来源:ProductCatalogApplication.java

示例7: initialize

import com.google.inject.Stage; //导入依赖的package包/类
@Override
public void initialize(final Bootstrap<ProductReviewConfiguration> bootstrap) {
	bootstrap.addBundle(discoveryBundle);
	bootstrap.addBundle(new MigrationsBundle<ProductReviewConfiguration>() {

		@Override
		public PooledDataSourceFactory getDataSourceFactory(ProductReviewConfiguration configuration) {
			return configuration.getDataSourceFactory();
		}
	});
	guiceBundle = GuiceBundle.<ProductReviewConfiguration> newBuilder().addModule(new ProductReviewModule())
			.enableAutoConfig(getClass().getPackage().getName()).setConfigClass(ProductReviewConfiguration.class)
			.build(Stage.PRODUCTION);
	bootstrap.addBundle(guiceBundle);
	// Uncomment below to read the yaml file from Jar
	// bootstrap.setConfigurationSourceProvider(new
	// ResourceConfigurationSourceProvider());
}
 
开发者ID:G1GC,项目名称:dropwizard-microservices-example,代码行数:19,代码来源:ProductReviewApplication.java

示例8: Client

import com.google.inject.Stage; //导入依赖的package包/类
public Client(@NonNull Path filePath, @NonNull Config config, boolean cleanRun, @NonNull List<?> listeners) {
    this.filePath = checkFile(filePath);
    this.cleanRun = cleanRun;

    Injector injector = Guice.createInjector(
            Stage.PRODUCTION,
            new ConfigurationModule(ConfigValidator.checkValid(config.withFallback(ConfigFactory.load()))),
            new JpaRepositoryModule(),
            new ServiceModule()
    );

    persistService = injector.getInstance(PersistService.class);
    persistService.start();

    handlerType = injector.getInstance(MovieHandler.Type.class);
    handlerChain = injector.getInstance(MovieHandler.class);
    importProgressService = injector.getInstance(ImportProgressService.class);

    eventBus = new EventBus();
    listeners.forEach(eventBus::register);
}
 
开发者ID:REDNBLACK,项目名称:J-Kinopoisk2IMDB,代码行数:22,代码来源:Client.java

示例9: getInjector

import com.google.inject.Stage; //导入依赖的package包/类
@Override
protected Injector getInjector() {

    // Create injector
    Injector injector = Guice.createInjector(Stage.PRODUCTION,
        new EnvironmentModule(environment),
        new LogModule(environment),
        new ExtensionModule(environment),
        new RESTServiceModule(sessionMap),
        new TunnelModule()
    );

    // Inject any annotated members of this class
    injector.injectMembers(this);

    return injector;

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:19,代码来源:GuacamoleServletContextListener.java

示例10: initialize

import com.google.inject.Stage; //导入依赖的package包/类
protected void initialize()
{
    EuropaConfiguration europaConfiguration = null;
    if(_configFilePath != null)
        europaConfiguration = EuropaConfiguration.fromFile(new File(_configFilePath));
    else
        europaConfiguration = EuropaConfiguration.fromEnvironment();
    europaConfiguration.setStage(_stage);

    Injector injector = Guice.createInjector(Stage.PRODUCTION,
                                             new PersistenceModule(),
                                             new AjaxHelperModule(),
                                             new ObjectStoreModule(),
                                             new EuropaInjectorModule(europaConfiguration));
    injector.injectMembers(this);
    initializeWebServer(injector);
}
 
开发者ID:puppetlabs,项目名称:europa,代码行数:18,代码来源:Europa.java

示例11: addStageCreationRule

import com.google.inject.Stage; //导入依赖的package包/类
private void addStageCreationRule() {
    // stage rule
    config.creationPipeline.creationRules.add(new CreationRule() {

        @Override
        public Optional<Function<RecipeCreationContext, SupplierRecipe>> apply(
                CoreDependencyKey<?> key, CoreInjector injector) {
            if (Stage.class.equals(key.getType().getType()))
                return Optional.of(ctx -> new SupplierRecipeImpl(
                        () -> guiceConfig.stage));
            else
                return Optional.empty();
        }

    });
}
 
开发者ID:ruediste,项目名称:salta,代码行数:17,代码来源:GuiceModule.java

示例12: testImmediateStarts

import com.google.inject.Stage; //导入依赖的package包/类
@Test
public void testImmediateStarts()
        throws Exception
{
    Injector injector = Guice.createInjector(
            Stage.PRODUCTION,
            new LifeCycleModule(),
            new Module()
            {
                @Override
                public void configure(Binder binder)
                {
                    binder.bind(InstanceThatRequiresStart.class).in(Scopes.SINGLETON);
                    binder.bind(InstanceThatUsesInstanceThatRequiresStart.class).in(Scopes.SINGLETON);
                }
            });

    LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    lifeCycleManager.start();

    Assert.assertEquals(stateLog, ImmutableList.of("InstanceThatUsesInstanceThatRequiresStart:OK"));
}
 
开发者ID:embulk,项目名称:guice-bootstrap,代码行数:23,代码来源:TestLifeCycleManager.java

示例13: testSubClassAnnotated

import com.google.inject.Stage; //导入依赖的package包/类
@Test
public void testSubClassAnnotated()
        throws Exception
{
    Injector injector = Guice.createInjector(
            Stage.PRODUCTION,
            new LifeCycleModule(),
            new Module()
            {
                @Override
                public void configure(Binder binder)
                {
                    binder.bind(SimpleBase.class).to(SimpleBaseImpl.class).in(Scopes.SINGLETON);
                }
            });

    LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    lifeCycleManager.start();
    Assert.assertEquals(stateLog, ImmutableList.of("postSimpleBaseImpl"));

    lifeCycleManager.destroy();

    Assert.assertEquals(stateLog, ImmutableList.of("postSimpleBaseImpl", "preSimpleBaseImpl"));
}
 
开发者ID:embulk,项目名称:guice-bootstrap,代码行数:25,代码来源:TestLifeCycleManager.java

示例14: testIllegalMethods

import com.google.inject.Stage; //导入依赖的package包/类
@Test
public void testIllegalMethods()
        throws Exception
{
    try {
        Guice.createInjector(
                Stage.PRODUCTION,
                new Module()
                {
                    @Override
                    public void configure(Binder binder)
                    {
                        binder.bind(IllegalInstance.class).in(Scopes.SINGLETON);
                    }
                },
                new LifeCycleModule());
        Assert.fail();
    }
    catch (CreationException dummy) {
        // correct behavior
    }
}
 
开发者ID:embulk,项目名称:guice-bootstrap,代码行数:23,代码来源:TestLifeCycleManager.java

示例15: testDuplicateMethodNames

import com.google.inject.Stage; //导入依赖的package包/类
@Test
public void testDuplicateMethodNames()
        throws Exception
{
    Injector injector = Guice.createInjector(
            Stage.PRODUCTION,
            new Module()
            {
                @Override
                public void configure(Binder binder)
                {
                    binder.bind(FooTestInstance.class).in(Scopes.SINGLETON);
                }
            },
            new LifeCycleModule()
    );

    LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    lifeCycleManager.start();
    lifeCycleManager.destroy();

    Assert.assertEquals(stateLog, ImmutableList.of("foo"));
}
 
开发者ID:embulk,项目名称:guice-bootstrap,代码行数:24,代码来源:TestLifeCycleManager.java


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