Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
DefaultHttpInvoker.java
Go to the documentation of this file.
1 package com.griddynamics.jagger.invoker.v2;
2 
3 import com.google.common.base.Preconditions;
4 import com.griddynamics.jagger.invoker.InvocationException;
5 
6 import static java.lang.String.format;
7 
8 
20 @SuppressWarnings("unused")
21 public class DefaultHttpInvoker extends AbstractHttpInvoker {
22 
23  public DefaultHttpInvoker() {
24  super(new SpringBasedHttpClient());
25  }
26 
27  public DefaultHttpInvoker(JHttpClient httpClient) {
28  super(httpClient);
29  }
30 
31  @Override
32  public JHttpResponse invoke(JHttpQuery query, JHttpEndpoint endpoint) throws InvocationException {
33  Preconditions.checkNotNull(endpoint, "JHttpEndpoint is null!");
34  try {
35  return httpClient.execute(endpoint, query);
36  } catch (Exception e) {
37  throw new InvocationException(format("Exception occurred during execution of query %s to endpoint %s.", query, endpoint), e);
38  }
39  }
40 }