1 package org
.argeo
.slc
.core
.execution
;
3 import java
.util
.ArrayList
;
4 import java
.util
.Iterator
;
7 import org
.apache
.commons
.logging
.Log
;
8 import org
.apache
.commons
.logging
.LogFactory
;
9 import org
.argeo
.slc
.process
.RealizedFlow
;
10 import org
.argeo
.slc
.process
.SlcExecution
;
11 import org
.argeo
.slc
.process
.SlcExecutionNotifier
;
13 /** Thread of the SLC Process, starting the sub executions. */
14 public class ProcessThread
extends Thread
{
15 private final static Log log
= LogFactory
.getLog(ProcessThread
.class);
17 private final AbstractExecutionModulesManager executionModulesManager
;
18 private final SlcExecution slcProcess
;
19 private final ThreadGroup processThreadGroup
;
20 private final List
<RealizedFlow
> flowsToProcess
= new ArrayList
<RealizedFlow
>();
23 AbstractExecutionModulesManager executionModulesManager
,
24 SlcExecution slcExecution
) {
25 super(executionModulesManager
.getProcessesThreadGroup(),
26 "SLC Process #" + slcExecution
.getUuid());
27 this.executionModulesManager
= executionModulesManager
;
28 this.slcProcess
= slcExecution
;
29 processThreadGroup
= new ThreadGroup("SLC Process #"
30 + slcExecution
.getUuid() + " thread group");
34 log
.info("\n##\n## Process SLC Execution " + slcProcess
+ "\n##\n");
36 slcProcess
.setStatus(SlcExecution
.STATUS_RUNNING
);
37 dispatchUpdateStatus(slcProcess
, SlcExecution
.STATUS_SCHEDULED
,
38 SlcExecution
.STATUS_RUNNING
);
40 flowsToProcess
.addAll(slcProcess
.getRealizedFlows());
42 while (flowsToProcess
.size() > 0) {
43 RealizedFlow flow
= flowsToProcess
.remove(0);
44 ExecutionThread thread
= new ExecutionThread(this, flow
);
50 } catch (InterruptedException e
) {
56 slcProcess
.setStatus(SlcExecution
.STATUS_FINISHED
);
57 dispatchUpdateStatus(slcProcess
, SlcExecution
.STATUS_RUNNING
,
58 SlcExecution
.STATUS_FINISHED
);
61 protected void dispatchUpdateStatus(SlcExecution slcExecution
,
62 String oldStatus
, String newStatus
) {
63 for (Iterator
<SlcExecutionNotifier
> it
= executionModulesManager
64 .getSlcExecutionNotifiers().iterator(); it
.hasNext();) {
65 it
.next().updateStatus(slcExecution
, oldStatus
, newStatus
);
69 public synchronized void flowCompleted() {
73 public SlcExecution
getSlcProcess() {
77 public ThreadGroup
getProcessThreadGroup() {
78 return processThreadGroup
;
81 public AbstractExecutionModulesManager
getExecutionModulesManager() {
82 return executionModulesManager
;