1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package com.ebay.carad.os.vitalsigns.dataretrievers;
22
23 import com.ebay.carad.os.vitalsigns.IDashboardAgent;
24 import com.ebay.carad.os.vitalsigns.IDataRetriever;
25 import com.ebay.carad.os.vitalsigns.ReportingException;
26 import com.ebay.carad.os.vitalsigns.templates.ITemplatizable;
27
28 /***
29 * <p>Wraps an instance of ITester, and logs its output.</p>
30 *
31 * @author Jeremy Kraybill
32 * @author Jeremy Thomerson
33 * @version $Id$
34 */
35 public class TesterLogger implements IDataRetriever, ITemplatizable, Cloneable {
36
37
38
39 private ITester mTester;
40
41 /***
42 * Basic constructor.
43 */
44 public TesterLogger() {
45 super();
46 }
47
48 /***
49 * IoC method, sets the tester we are wrapping.
50 *
51 * @param tester the tester to run
52 */
53 public void setTester(ITester tester) {
54 mTester = tester;
55 }
56
57 /***
58 * Returns the tester we are running.
59 *
60 * @return the tester to run
61 */
62 public ITester getTester() {
63 return mTester;
64 }
65
66 public Float getData() {
67 Float value = null;
68 try {
69 value = new Float(mTester.test());
70 } catch (Exception ex) {
71
72 throw new ReportingException("exception running tester: " + mTester, ex);
73 }
74 return value;
75 }
76
77 public void templatize(Object[] params) {
78 if (mTester instanceof ITemplatizable) {
79 ((ITemplatizable) mTester).templatize(params);
80 }
81 }
82
83 public Object clone() throws CloneNotSupportedException {
84 TesterLogger newObj = (TesterLogger) super.clone();
85 newObj.setTester((ITester) mTester.clone());
86 return newObj;
87 }
88
89 public Float getData(IDashboardAgent agent) {
90 return getData();
91 }
92
93 }