Jagger
 All Classes Namespaces Files Functions Variables 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 
18 @SuppressWarnings("unused")
19 public class DefaultHttpInvoker extends AbstractHttpInvoker {
20 
21  public DefaultHttpInvoker() {
22  super(new SpringBasedHttpClient());
23  }
24 
25  public DefaultHttpInvoker(JHttpClient httpClient) {
26  super(httpClient);
27  }
28 
29  @Override
30  public JHttpResponse invoke(JHttpQuery query, JHttpEndpoint endpoint) throws InvocationException {
31  Preconditions.checkNotNull(endpoint, "JHttpEndpoint is null!");
32  try {
33  return httpClient.execute(endpoint, query);
34  } catch (Exception e) {
35  throw new InvocationException(format("Exception occurred during execution of query %s to endpoint %s.", query, endpoint), e);
36  }
37  }
38 }