T- the type of object this provides
public interface Provider<T> extends Provider<T>
T. Providers are used in numerous ways by Guice:
Providerinstead, to control exactly how Guice creates or obtains instances for the binding.
Provider<T>instance injected, rather than having a
Tinjected directly. This may give you access to multiple instances, instances you wish to safely mutate and discard, instances which are out of scope (e.g. using a
@RequestScopedobject from within a
@SessionScopedobject), or instances that will be initialized lazily.
Scopeis implemented as a decorator of
Provider<T>, which decides when to delegate to the backing provider and when to provide the instance some other way.
Injectoroffers access to the
Provider<T>it uses to fulfill requests for a given key, via the
|Modifier and Type||Method and Description|
Provides an instance of
T. Must never return
OutOfScopeException- when an attempt is made to access a scoped object while the scope in question is not currently active
ProvisionException- if an instance cannot be provided. Such exceptions include messages and throwables to describe why provision failed.