I would like to call REST API using Spring & would like to know if there is any such implementation similar to what Jersey provides as shown below:
import javax.ws.rs.client.InvocationCallback;
public class FacebookService {
private final WebTarget target = ClientBuilder.newClient()
.target("http://ift.tt/rrPc6B");
public Future<FacebookUser> userAsync(String user) {
return target
.path("/{user}")
.resolveTemplate("user", user)
.request()
.async()
.get(new InvocationCallback<FacebookUser>() {
@Override
public void completed(FacebookUser facebookUser) {
// on complete
}
@Override
public void failed(Throwable throwable) {
// on fail
}
});
}
}
For eg, here Jersey provides completed & failed method that can be used to find if API call has failed or successful.
how do we do it with spring?
Thanks!
Aucun commentaire:
Enregistrer un commentaire