Runtime phase

We will now be able to utilize the injector we made during the start-up phase to inject objects and examine our bindings. Guice's runtime phase consists of an injector which contains a few bindings:

The preceding diagram defines the components of each binding. Each key uniquely recognizes each binding. The key consists of a type, which the client depends on, and an annotation, which is optional. An annotation could be used to distinguish a couple of bindings of the same type.

Every single binding has a provider, which gives an instance of the mandatory type. We may offer a class, and Guice will make instances of it for us. We ...

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.