Instance bindings

Instance bindings help to bind a type to a particular instance of that typeThis is normally helpful only for objects that don't have dependencies in their possession; for example, value objects:

Public class SearchModule extends AbstractModule{
@Override
protected void configure() {
bind(SearchParameters.class).toInstance(new SearchParameters());
}
}

Avoid utilizing .toInstance with objects that are complicated to make, since it can slow down application start-up. You can utilize the @Provides technique.

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

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