Differences

This shows you the differences between two versions of the page.

Link to this comparison view

lazy_binding_with_guice [2021/04/05 11:23] (current)
Line 1: Line 1:
 +====== Lazy Binding with Guice ======
 +Everything in Guice is bound immediately. You cannot specify something like //lazy binding//. But what you can do is not binding to the desired object itself but to the provider of the object:
  
 +<sxh>
 +@Inject
 +private Provider<Client> clientProvider;
 +</sxh>
 +
 +By this way you can choose when to retrieve the desired object when need at not at object instantiation.
 +
 +{{tag>devel java guice}}