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=6440fd2d1b765f6eadf8e36a5914749a9040d67a;hpb=a29c28266fef35c1620f6582ec182bad7f7f85ae;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 6440fd2d1..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,18 +8,25 @@ 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(); } /** Finish the remaining and destroy */ - public void close() { + public void close(TestResult testResult) { synchronized (partStructs) { // TODO: put a timeout while (partStructs.size() != 0) { @@ -32,6 +39,7 @@ public abstract class AsynchronousTreeTestResultListener implements thread = null; partStructs.notifyAll(); } + postClose((TreeTestResult)testResult); } public final void resultPartAdded(TestResult testResult, @@ -45,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) { @@ -67,12 +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();