當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。