Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
ExampleCustomHttpInvokerProvider.java
Go to the documentation of this file.
1 package ${package};
2 
3 import com.griddynamics.jagger.engine.e1.Provider;
4 import com.griddynamics.jagger.invoker.InvocationException;
5 import com.griddynamics.jagger.invoker.Invoker;
6 import com.griddynamics.jagger.invoker.v2.DefaultHttpInvoker;
7 import com.griddynamics.jagger.invoker.v2.JHttpEndpoint;
8 import com.griddynamics.jagger.invoker.v2.JHttpQuery;
9 import com.griddynamics.jagger.invoker.v2.JHttpResponse;
10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
12 
20 public class ExampleCustomHttpInvokerProvider implements Provider<Invoker> {
21 
22  private static final Logger log = LoggerFactory.getLogger(ExampleCustomHttpInvokerProvider.class);
23 
24  private final boolean verbose;
25 
26  public ExampleCustomHttpInvokerProvider(final boolean verbose) {this.verbose = verbose;}
27 
29  return new ExampleCustomHttpInvokerProvider(true);
30  }
31 
32 
34  return new ExampleCustomHttpInvokerProvider(false);
35  }
36 
37  @Override
38  public Invoker provide() {
39  return new DefaultHttpInvoker() {
40  @Override
41  public JHttpResponse invoke(JHttpQuery query, JHttpEndpoint endpoint) throws InvocationException {
42 
43  if (verbose) {
44  log.info("in invoke method of custom http invoker...");
45  }
46 
47  return super.invoke(query, endpoint);
48  }
49  };
50  }
51 }