Short answer: No.
Personally, I would refactor whatever it is so that the web service
interaction is outside of the provider.
Having said that, yes, you want to create a Provider instance for this
"thing". Implement its get() to wrap the web service contact within a
Callable object, use the ExecutorService to submit that and return a
Future, then use the future.wait(...) in a loop: while(retries <
someLimit && !successful) { future.wait(5, TimeUnit.SECONDS); ... }
for instance.
As long as your code using this Provider implementation utilizes this
Provider's get() method, this retry loop sequence will get called.
This still, however, leaves the issue of a failure at some point an a
null or old instance returned from the get(), hence my earlier comment
about the refactor. Inject this custom Provider, rather than the
instance contacting the web service, and allow those classes using
what get() provides to deal with any errors.
On Mar 1, 12:26 pm, Agustín Bartó <[email protected]> wrote:
> I have a request scoped injection that is fulfilled by a provider
> method. The thing is that, this method might or might not return the
> object depending if it was able to contact a web service or not (I'm
> injecting the client).
>
> Is there a way to Guice to "retry" the injection? Right now the webapp
> fails altogether when the provider fails.
>
> Agustin
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.