What it does is pretty simple:

@Inject
private Provider<ProductService> productService;

The Product service is available through productService.get() and .get() will resolve the instance from the Spring context on each call.

But when should I use it? And where?

My main use case is pretty simple: When I get circular dependencies, the provider helps to resolve the dependency at runtime. But it looks a bit random if you throw it in just when you can't create your context caused by a circular dependency.

Are there any known patterns about the usage of Providers?

Edit
Report