I am doing some refactoring and reviewing of the application that we are currently developing. While doing this I found that more beans are injected and I think making they loading in an lazy manner would be better suited for their purpose. I am using Java EE 6 and tend to use more CDI than EJB injection.
So the question is whether it is possible to inject the beans lazily and if so, how can you do it?
What about using
@Inject
private Instance<?> lazyProvider;
?
That allows Getting instance of "?" when actually needed via
lazyProvider.get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With