Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
TestGroupListener.java
Go to the documentation of this file.
1 package com.griddynamics.jagger.engine.e1.collector.testgroup;
2 
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 
6 import java.util.List;
7 
17 public abstract class TestGroupListener {
18 
21  public void onStart(TestGroupInfo infoStart){
22  }
23 
26  public void onStop(TestGroupInfo infoStop){
27  }
28 
31  public static class Composer extends TestGroupListener{
32  private static Logger log = LoggerFactory.getLogger(Composer.class);
33 
34  private List<TestGroupListener> listenerList;
35 
36  private Composer(List<TestGroupListener> listenerList){
37  this.listenerList = listenerList;
38  }
39 
40  @Override
41  public void onStart(TestGroupInfo testGroupInfo) {
42  for (TestGroupListener listener : listenerList){
43  try{
44  listener.onStart(testGroupInfo);
45  }catch (RuntimeException ex){
46  log.error("Failed to call on start in {} test-group-listener", listener.toString(), ex);
47  }
48  }
49  }
50 
51  @Override
52  public void onStop(TestGroupInfo testGroupInfo) {
53  for (TestGroupListener listener : listenerList){
54  try{
55  listener.onStop(testGroupInfo);
56  }catch (RuntimeException ex){
57  log.error("Failed to call on stop in {} test-group-listener", listener.toString(), ex);
58  }
59  }
60  }
61 
62  public static TestGroupListener compose(List<TestGroupListener> listeners){
63  return new Composer(listeners);
64  }
65  }
66 }