Class Initialization


  • public class Initialization
    extends Object
    Initialize Guice for a server. This is a legacy version, kept for compatibility with existing tests. Clients and tests should use the individual builders to create a non-server environment. Clients (and tests) never load extensions, and so do not need (and, in fact, should not use) the ExtensionInjectorBuilder. Instead, simple tests can use StartupInjectorBuilder directly, passing in any needed modules.

    Some tests use modules that rely on the "startup injector" to inject values into a module. In that case, tests should use two builders: the StartupInjectorBuilder followed by the CoreInjectorBuilder class to hold extra modules. Look for references to CoreInjectorBuilder to find examples of this pattern.

    In both cases, the injector builders have options to add the full set of server modules. Tests should not load those modules. Instead, let the injector builders provide just the required set, and then explicitly list the (small subset) of modules needed by any given test.

    The server initialization formerly done here is now done in GuiceRunnable by way of the ServerInjectorBuilder.

    • Constructor Detail

      • Initialization

        public Initialization()
    • Method Detail

      • makeInjectorWithModules

        @Deprecated
        public static com.google.inject.Injector makeInjectorWithModules​(com.google.inject.Injector baseInjector,
                                                                         Iterable<? extends com.google.inject.Module> modules)
        Deprecated.