Package com.google.inject.spi
Interface ProvisionListener
public interface ProvisionListener
Listens for provisioning of objects. Useful for gathering timing information about provisioning,
post-provision initialization, and more.
- Since:
- 4.0
- Author:
- sameb@google.com (Sam Berlin)
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Encapsulates a single act of provisioning. -
Method Summary
Modifier and TypeMethodDescription<T> void
onProvision
(ProvisionListener.ProvisionInvocation<T> provision) Invoked by Guice when an object requires provisioning.
-
Method Details
-
onProvision
Invoked by Guice when an object requires provisioning. Provisioning occurs when Guice locates and injects the dependencies for a binding. For types bound to a Provider, provisioning encapsulates theProvider.get()
method. For toInstance or constant bindings, provisioning encapsulates the injecting of @Inject
ed fields or methods. For other types, provisioning encapsulates the construction of the object. If a type is bound within aScope
, provisioning depends on the scope. Types bound in Singleton scope will only be provisioned once. Types bound in no scope will be provisioned every time they are injected. Other scopes define their own behavior for provisioning.To perform the provision, call
ProvisionListener.ProvisionInvocation.provision()
. If you do not explicitly call provision, it will be automatically done after this method returns. It is an error to call provision more than once.
-