KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tcsimulator > listener > ResultsListenerObject


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tcsimulator.listener;
5
6 import com.tc.object.config.ConfigVisitor;
7 import com.tc.object.config.DSOClientConfigHelper;
8 import com.tc.object.config.TransparencyClassSpec;
9 import com.tc.simulator.app.ErrorContext;
10 import com.tc.simulator.listener.ResultsListener;
11
12 import java.util.ArrayList JavaDoc;
13 import java.util.List JavaDoc;
14
15 public final class ResultsListenerObject implements ResultsListener {
16
17   boolean startTimeout = false;
18   boolean executionTimeout = false;
19   private Object JavaDoc result;
20   private List JavaDoc errors;
21
22   public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper cfg) {
23     String JavaDoc classname = ResultsListenerObject.class.getName();
24     TransparencyClassSpec spec = cfg.getOrCreateSpec(classname);
25
26     spec.addTransient("startTimeout");
27     spec.addTransient("results");
28     spec.addTransient("errors");
29   }
30
31   public synchronized void notifyStartTimeout() {
32     startTimeout = true;
33   }
34
35   public synchronized void notifyExecutionTimeout() {
36     executionTimeout = true;
37   }
38
39   public synchronized void notifyError(ErrorContext ectxt) {
40     if (this.errors == null) this.errors = new ArrayList JavaDoc();
41     this.errors.add(ectxt);
42   }
43
44   public synchronized void notifyResult(Object JavaDoc theResult) {
45     this.result = theResult;
46   }
47
48   public synchronized void addErrorsTo(List JavaDoc addTo) {
49     addTo.addAll(this.errors);
50   }
51
52   Object JavaDoc getResult() {
53     return this.result;
54   }
55 }
Popular Tags