01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tcsimulator.listener;
05:
06: import com.tc.object.config.ConfigVisitor;
07: import com.tc.object.config.DSOClientConfigHelper;
08: import com.tc.object.config.TransparencyClassSpec;
09: import com.tc.simulator.app.ErrorContext;
10: import com.tc.simulator.listener.ResultsListener;
11:
12: import java.util.ArrayList;
13: import java.util.List;
14:
15: public final class ResultsListenerObject implements ResultsListener {
16:
17: boolean startTimeout = false;
18: boolean executionTimeout = false;
19: private Object result;
20: private List errors;
21:
22: public static void visitL1DSOConfig(ConfigVisitor visitor,
23: DSOClientConfigHelper cfg) {
24: String classname = ResultsListenerObject.class.getName();
25: TransparencyClassSpec spec = cfg.getOrCreateSpec(classname);
26:
27: spec.addTransient("startTimeout");
28: spec.addTransient("results");
29: spec.addTransient("errors");
30: }
31:
32: public synchronized void notifyStartTimeout() {
33: startTimeout = true;
34: }
35:
36: public synchronized void notifyExecutionTimeout() {
37: executionTimeout = true;
38: }
39:
40: public synchronized void notifyError(ErrorContext ectxt) {
41: if (this .errors == null)
42: this .errors = new ArrayList();
43: this .errors.add(ectxt);
44: }
45:
46: public synchronized void notifyResult(Object theResult) {
47: this .result = theResult;
48: }
49:
50: public synchronized void addErrorsTo(List addTo) {
51: addTo.addAll(this .errors);
52: }
53:
54: Object getResult() {
55: return this.result;
56: }
57: }
|