Guice

Guice is a final class, an entry point to the Guice framework. It's used to create injectors by providing a set of modules:

//From NotificationClient.javaInjector injector = Guice.createInjector(new ApplicationModule());//Syntax from actual Guice Class  Injector injector = Guice.createInjector(                    new ModuleA(),                    new ModuleB(),                    . . .                    new ModuleN(args));

In the preceding code snippet, notice that the createInjector() method takes ApplicationModule() as an argument; the same method also takes a varargs, which means we can pass zero or more modules separated by a comma.

Get Java 9 Dependency Injection now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.