Java Code Examples for com.google.inject.Stage#PRODUCTION

The following examples show how to use com.google.inject.Stage#PRODUCTION . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParaServer.java    From para with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the Para core modules and allows the user to override them. Call this method first.
 *	This method calls {@code Para.initialize()}.
 * @param modules a list of modules that override the main modules
 */
public static void initialize(Module... modules) {
	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);
	}

	Para.addInitListener(HealthUtils.getInstance());
	Para.addInitListener(MetricsUtils.getInstance());

	Para.getInitListeners().forEach((initListener) -> {
		injectInto(initListener);
	});

	if (Config.WEBHOOKS_ENABLED) {
		Para.addIOListener(new WebhookIOListener());
	}

	Para.initialize();

	// this enables the "river" feature - polls the default queue for objects and imports them into Para
	// additionally, the polling feature is used for implementing a webhooks worker node
	if ((Config.getConfigBoolean("queue_link_enabled", false) || Config.WEBHOOKS_ENABLED) &&
			HealthUtils.getInstance().isHealthy()) {
		Para.getQueue().startPolling();
	}
}
 
Example 2
Source File: SingularityService.java    From Singularity with Apache License 2.0 4 votes vote down vote up
public Stage getGuiceStage() {
  return Stage.PRODUCTION;
}
 
Example 3
Source File: BaragonService.java    From Baragon with Apache License 2.0 4 votes vote down vote up
public Stage getGuiceStage() {
  return Stage.PRODUCTION;
}