Package jakarta.inject
Interface Provider<T>
- 
- All Known Subinterfaces:
- Instance<T>,- SeContainer
 - All Known Implementing Classes:
- CDI
 
 public interface Provider<T>Provides instances ofT. Typically implemented by an injector. For any typeTthat can be injected, you can also injectProvider<T>. Compared to injectingTdirectly, injectingProvider<T>enables:- retrieving multiple instances.
- lazy or optional retrieval of an instance.
- breaking circular dependencies.
- abstracting scope so you can look up an instance in a smaller scope from an instance in a containing scope.
 For example: class Car { @Inject Car(Provider<Seat> seatProvider) { Seat driver = seatProvider.get(); Seat passenger = seatProvider.get(); ... } }
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description Tget()Provides a fully-constructed and injected instance ofT.
 
- 
- 
- 
Method Detail- 
getT get() Provides a fully-constructed and injected instance ofT.- Returns:
- instance of T.
- Throws:
- RuntimeException- if the injector encounters an error while providing an instance. For example, if an injectable member on- Tthrows an exception, the injector may wrap the exception and throw it to the caller of- get(). Callers should not try to handle such exceptions as the behavior may vary across injector implementations and even different configurations of the same injector.
 
 
- 
 
-