package org.argeo.slc.core.execution;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.slc.execution.ExecutionFlowDescriptor;
import org.argeo.slc.process.RealizedFlow;
-import org.argeo.slc.process.SlcExecutionNotifier;
import org.argeo.slc.process.SlcExecutionStep;
/** Thread of a single execution */
}
}
- public void dispatchAddStep(SlcExecutionStep step) {
- processThread.getSlcProcess().getSteps().add(step);
- List<SlcExecutionStep> steps = new ArrayList<SlcExecutionStep>();
- steps.add(step);
- for (Iterator<SlcExecutionNotifier> it = processThread
- .getExecutionModulesManager().getSlcExecutionNotifiers()
- .iterator(); it.hasNext();) {
- it.next().addSteps(processThread.getSlcProcess(), steps);
- }
+ private void dispatchAddStep(SlcExecutionStep step) {
+ processThread.getProcessThreadGroup().dispatchAddStep(step);
}
}
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;
"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() {
return slcProcess;
}
- public ThreadGroup getProcessThreadGroup() {
+ public ProcessThreadGroup getProcessThreadGroup() {
return processThreadGroup;
}
--- /dev/null
+package org.argeo.slc.core.execution;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.argeo.slc.process.SlcExecution;
+import org.argeo.slc.process.SlcExecutionNotifier;
+import org.argeo.slc.process.SlcExecutionStep;
+
+public class ProcessThreadGroup extends ThreadGroup {
+ private final ProcessThread processThread;
+
+ public ProcessThreadGroup(ProcessThread processThread) {
+ super("SLC Process #" + processThread.getSlcProcess().getUuid()
+ + " thread group");
+ this.processThread = processThread;
+ }
+
+ public SlcExecution getSlcProcess() {
+ return processThread.getSlcProcess();
+ }
+
+ public void dispatchAddStep(SlcExecutionStep step) {
+ processThread.getSlcProcess().getSteps().add(step);
+ List<SlcExecutionStep> steps = new ArrayList<SlcExecutionStep>();
+ steps.add(step);
+ for (Iterator<SlcExecutionNotifier> it = processThread
+ .getExecutionModulesManager().getSlcExecutionNotifiers()
+ .iterator(); it.hasNext();) {
+ it.next().addSteps(processThread.getSlcProcess(), steps);
+ }
+ }
+
+}
import org.apache.log4j.PatternLayout;
import org.apache.log4j.spi.LoggingEvent;
import org.argeo.slc.core.execution.ExecutionThread;
+import org.argeo.slc.core.execution.ProcessThreadGroup;
import org.argeo.slc.process.SlcExecutionStep;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
private Layout layout = null;
private String pattern = "%m - %c%n";
+ private Boolean onlyExecutionThread = true;
public void afterPropertiesSet() {
if (layout != null)
@Override
protected void append(LoggingEvent event) {
- if (!(Thread.currentThread() instanceof ExecutionThread))
- return;
-
- ExecutionThread executionThread = (ExecutionThread) Thread
- .currentThread();
- executionThread.dispatchAddStep(new SlcExecutionStep(layout
- .format(event)));
+ Thread currentThread = Thread.currentThread();
+ if (currentThread.getThreadGroup() instanceof ProcessThreadGroup) {
+ if (onlyExecutionThread
+ && !(currentThread instanceof ExecutionThread))
+ return;
+ ((ProcessThreadGroup) currentThread.getThreadGroup())
+ .dispatchAddStep(new SlcExecutionStep(layout.format(event)));
+ }
}
public void destroy() throws Exception {
this.pattern = pattern;
}
+ public void setOnlyExecutionThread(Boolean onlyExecutionThread) {
+ this.onlyExecutionThread = onlyExecutionThread;
+ }
+
}