Search in sources :

Example 6 with Stage

use of com.google.inject.Stage in project SpongeCommon by SpongePowered.

the class VanillaBootstrap method perform.

public static void perform(final String engineName, final Runnable engineStart) {
    final Stage stage = SpongeGuice.getInjectorStage(Launch.instance().injectionStage());
    SpongeCommon.logger().debug("Creating injector in stage '{}'", stage);
    final Injector bootstrapInjector = Launch.instance().createInjector();
    final SpongeLifecycle lifecycle = bootstrapInjector.getInstance(SpongeLifecycle.class);
    Launch.instance().setLifecycle(lifecycle);
    lifecycle.establishFactories();
    lifecycle.establishBuilders();
    lifecycle.initTimings();
    ((VanillaPluginManager) Launch.instance().pluginManager()).loadPlugins((VanillaPluginPlatform) Launch.instance().pluginPlatform());
    lifecycle.callConstructEvent();
    lifecycle.callRegisterFactoryEvent();
    lifecycle.callRegisterBuilderEvent();
    lifecycle.callRegisterChannelEvent();
    lifecycle.establishGameServices();
    lifecycle.establishDataKeyListeners();
    SpongePacketHandler.init((SpongeChannelManager) Sponge.channelManager());
    Launch.instance().logger().info("Loading Minecraft {}, please wait...", engineName);
    engineStart.run();
}
Also used : Injector(com.google.inject.Injector) Stage(com.google.inject.Stage) VanillaPluginManager(org.spongepowered.vanilla.launch.plugin.VanillaPluginManager) SpongeLifecycle(org.spongepowered.common.SpongeLifecycle)

Example 7 with Stage

use of com.google.inject.Stage in project guice by google.

the class OverrideModuleTest method testCorrectStage.

public void testCorrectStage() {
    final Stage stage = Stage.PRODUCTION;
    Module module = Modules.override(new AbstractModule() {

        @Override
        protected void configure() {
            if (currentStage() != Stage.PRODUCTION) {
                addError("Wronge stage in overridden module:" + currentStage());
            }
        }
    }).with(new AbstractModule() {

        @Override
        protected void configure() {
            if (currentStage() != Stage.PRODUCTION) {
                addError("Wronge stage in overriding module:" + currentStage());
            }
        }
    });
    Guice.createInjector(stage, module);
}
Also used : Stage(com.google.inject.Stage) Module(com.google.inject.Module) PrivateModule(com.google.inject.PrivateModule) AbstractModule(com.google.inject.AbstractModule) AbstractModule(com.google.inject.AbstractModule)

Aggregations

Stage (com.google.inject.Stage)7 Injector (com.google.inject.Injector)4 Module (com.google.inject.Module)4 AbstractModule (com.google.inject.AbstractModule)2 PrivateModule (com.google.inject.PrivateModule)2 SpongeLifecycle (org.spongepowered.common.SpongeLifecycle)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 GameProfileRepository (com.mojang.authlib.GameProfileRepository)1 MinecraftSessionService (com.mojang.authlib.minecraft.MinecraftSessionService)1 YggdrasilAuthenticationService (com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService)1 GuiceRole (com.peterphi.std.guice.apploader.GuiceRole)1 ClassScanner (com.peterphi.std.guice.common.ClassScanner)1 ServiceManagerClientGuiceModule (com.peterphi.std.guice.common.logging.ServiceManagerClientGuiceModule)1 CoreMetricsModule (com.peterphi.std.guice.common.metrics.CoreMetricsModule)1 NetworkConfigGuiceRole (com.peterphi.std.guice.common.serviceprops.net.NetworkConfigGuiceRole)1 ShutdownModule (com.peterphi.std.guice.common.shutdown.ShutdownModule)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 ServletContext (javax.servlet.ServletContext)1