Injector

An Injector interface creates and maintains object graphs, tracks dependencies of each type, and uses bindings to inject them. Injectors keep a set of default bindings, from which they take configuration details for making and maintaining relationships between objects. Consider the following code, which will return an implementation of the AppConsumer class:

AppConsumer app = injector.getInstance(AppConsumer.class);

We can also get all the associated bindings with the injector by calling the Injector.getBindings() method, which returns a map containing binding objects:

Map<Key, Binding> bindings = injector.getBindings()

From this, we can say that each binding has a matching key object, which is internally made and kept by the Google Guice class.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.203.96