X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Ftest%2Ftree%2FAsynchronousTreeTestResultListener.java;h=c3bc793ef5f357d03a16b821c1dd067f5163f83b;hb=875f97b054c6e996fa2d03c299c83cc80d336b54;hp=4a86aa2b4e657d6216963bc0822a0327d94fd062;hpb=9eb5d8493deed66f11248550fe5ec2202151846f;p=gpl%2Fargeo-slc.git
diff --git a/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/AsynchronousTreeTestResultListener.java b/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/AsynchronousTreeTestResultListener.java
index 4a86aa2b4..c3bc793ef 100644
--- a/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/AsynchronousTreeTestResultListener.java
+++ b/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/AsynchronousTreeTestResultListener.java
@@ -8,36 +8,38 @@ import org.argeo.slc.core.test.TestResult;
import org.argeo.slc.core.test.TestResultListener;
import org.argeo.slc.core.test.TestResultPart;
+/**
+ * Abstract asynchronous implementation of a listener listening to a
+ * TreeTestResult
.
+ *
+ * @see TreeTestResult
+ */
public abstract class AsynchronousTreeTestResultListener implements
TestResultListener, Runnable {
private Vector partStructs = new Vector();
private Thread thread;
+ /** Starts the underlying thread. */
public void init() {
thread = new Thread(this);
thread.start();
}
- public void destroy() {
- thread = null;
- synchronized (partStructs) {
- partStructs.notifyAll();
- }
- }
-
- /** Finish the remaining and destroy*/
- public void close(){
+ /** Finish the remaining and destroy */
+ public void close(TestResult testResult) {
synchronized (partStructs) {
// TODO: put a timeout
while (partStructs.size() != 0) {
try {
- partStructs.wait();
+ partStructs.wait(500);
} catch (InterruptedException e) {
// silent
}
}
- destroy();
+ thread = null;
+ partStructs.notifyAll();
}
+ postClose((TreeTestResult)testResult);
}
public final void resultPartAdded(TestResult testResult,
@@ -51,8 +53,17 @@ public abstract class AsynchronousTreeTestResultListener implements
}
}
+ /** Called when a result part has been added. */
protected abstract void resultPartAdded(PartStruct partStruct);
+ /**
+ * Called at the end of close. Default implementation is empty. To be
+ * overridden.
+ */
+ protected void postClose(TreeTestResult testResult) {
+
+ }
+
public void run() {
while (thread != null) {
synchronized (partStructs) {
@@ -73,13 +84,18 @@ public abstract class AsynchronousTreeTestResultListener implements
}
}
-
+ /** Structure used to pass tree specific information to subclasses. */
protected static class PartStruct {
+ /** The tree path of this part. */
public final TreeSPath path;
+ /** The test result id of the related test result */
public final NumericTRId resultId;
+ /** The part itself */
public final TestResultPart part;
+ /** The tree test result itself. */
public final TreeTestResult result;
+ /** Constructor */
public PartStruct(TreeSPath path, NumericTRId resultId,
TestResultPart part, TreeTestResult result) {
super();