Top Description Inners Methods
com.google.inject.spi

public Interface ProvisionListener

Imports
com.google.inject.Binding, .Provider, .Scope

Listens for provisioning of objects. Useful for gathering timing information about provisioning, post-provision initialization, and more.
Author
[email protected] (Sam Berlin)
Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
ProvisionListener.ProvisionInvocation<T>

Encapsulates a single act of provisioning.

Method Summary

Modifier and TypeMethod and Description
public <T> void
onProvision(ProvisionListener.ProvisionInvocation<T> provision)

Invoked by Guice when an object requires provisioning.

Method Detail

onProvisionback to summary
public <T> void onProvision(ProvisionListener.ProvisionInvocation<T> provision)

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 the Provider#get method. For toInstance or constant bindings, provisioning encapsulates the injecting of @Injected fields or methods. For other types, provisioning encapsulates the construction of the object. If a type is bound within a Scope, 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 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.

com.google.inject.spi back to summary

public abstract Class ProvisionListener.ProvisionInvocation<T>

extends Object
Class Inheritance
Known Direct Subclasses
com.google.inject.internal.ProvisionListenerStackCallback.Provision

Encapsulates a single act of provisioning.
Since
4.0

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract Binding<T>
getBinding()

Returns the Binding this is provisioning.

public abstract T
provision()

Performs the provision, returning the object provisioned.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ProvisionInvocationback to summary
public ProvisionInvocation()

Method Detail

getBindingback to summary
public abstract Binding<T> getBinding()

Returns the Binding this is provisioning.

You must not call Provider#get() on the provider returned by Binding#getProvider, otherwise you will get confusing error messages.

provisionback to summary
public abstract T provision()

Performs the provision, returning the object provisioned.