]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ProcessThread.java
ExcecutionScopeDecorator: change default to proxy interfaces
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / ProcessThread.java
index 678e6f679ae809322e81125b79fece1074489a50..1987f259e9ef8c84d997f6ada6a0a0f0283cc638 100644 (file)
@@ -16,9 +16,11 @@ public class ProcessThread extends Thread {
 
        private final AbstractExecutionModulesManager executionModulesManager;
        private final SlcExecution slcProcess;
-       private final ThreadGroup processThreadGroup;
+       private final ProcessThreadGroup processThreadGroup;
        private final List<RealizedFlow> flowsToProcess = new ArrayList<RealizedFlow>();
 
+       private Boolean hadAnError = false;
+
        public ProcessThread(
                        AbstractExecutionModulesManager executionModulesManager,
                        SlcExecution slcExecution) {
@@ -26,8 +28,7 @@ public class ProcessThread extends Thread {
                                "SLC Process #" + slcExecution.getUuid());
                this.executionModulesManager = executionModulesManager;
                this.slcProcess = slcExecution;
-               processThreadGroup = new ThreadGroup("SLC Process #"
-                               + slcExecution.getUuid() + " thread group");
+               processThreadGroup = new ProcessThreadGroup(this);
        }
 
        public void run() {
@@ -53,9 +54,12 @@ public class ProcessThread extends Thread {
                        }
                }
 
-               slcProcess.setStatus(SlcExecution.STATUS_FINISHED);
+               if (hadAnError)
+                       slcProcess.setStatus(SlcExecution.STATUS_ERROR);
+               else
+                       slcProcess.setStatus(SlcExecution.STATUS_FINISHED);
                dispatchUpdateStatus(slcProcess, SlcExecution.STATUS_RUNNING,
-                               SlcExecution.STATUS_FINISHED);
+                               slcProcess.getStatus());
        }
 
        protected void dispatchUpdateStatus(SlcExecution slcExecution,
@@ -66,6 +70,10 @@ public class ProcessThread extends Thread {
                }
        }
 
+       public void notifyError() {
+               hadAnError = true;
+       }
+
        public synchronized void flowCompleted() {
                notifyAll();
        }
@@ -74,7 +82,7 @@ public class ProcessThread extends Thread {
                return slcProcess;
        }
 
-       public ThreadGroup getProcessThreadGroup() {
+       public ProcessThreadGroup getProcessThreadGroup() {
                return processThreadGroup;
        }