Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
LoadScenarioListener.java
Go to the documentation of this file.
1 package com.griddynamics.jagger.engine.e1.collector.loadscenario;
2 
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 
19 public abstract class LoadScenarioListener {
20 
23  public void onStart(LoadScenarioInfo loadScenarioInfo){
24  }
25 
28  public void onStop(LoadScenarioInfo loadScenarioInfo){
29  }
30 
33  public static class Composer extends LoadScenarioListener {
34  private static Logger log = LoggerFactory.getLogger(Composer.class);
35 
36  private Iterable<LoadScenarioListener> listeners;
37 
38  public Composer(Iterable<LoadScenarioListener> listeners) {
39  this.listeners = listeners;
40  }
41 
42  public static LoadScenarioListener compose(Iterable<LoadScenarioListener> collectors){
43  return new Composer(collectors);
44  }
45 
46  @Override
47  public void onStart(LoadScenarioInfo loadScenarioInfo) {
48  for (LoadScenarioListener listener : listeners){
49  try{
50  listener.onStart(loadScenarioInfo);
51  }catch (RuntimeException ex){
52  log.error("Failed to call on start in {} test-suite-listener", listener.toString(), ex);
53  }
54  }
55  }
56 
57  @Override
58  public void onStop(LoadScenarioInfo loadScenarioInfo) {
59  for (LoadScenarioListener listener : listeners){
60  try{
61  listener.onStop(loadScenarioInfo);
62  }catch (RuntimeException ex){
63  log.error("Failed to call on stop in {} test-suite-listener", listener.toString(), ex);
64  }
65  }
66  }
67  }
68 }