]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ProcessThreadGroup.java
Remove unnecessary check causing failures
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / ProcessThreadGroup.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.core.execution;
17
18 import java.util.concurrent.ArrayBlockingQueue;
19 import java.util.concurrent.BlockingQueue;
20
21 import org.argeo.slc.execution.ExecutionProcess;
22 import org.argeo.slc.execution.ExecutionStep;
23 import org.springframework.security.Authentication;
24 import org.springframework.security.context.SecurityContextHolder;
25
26 /** The thread group attached to a given {@link SlcExecution}. */
27 public class ProcessThreadGroup extends ThreadGroup {
28 // private final ExecutionModulesManager executionModulesManager;
29 // private final ProcessThread processThread;
30 private final Authentication authentication;
31 private final static Integer STEPS_BUFFER_CAPACITY = 5000;
32
33 private BlockingQueue<ExecutionStep> steps = new ArrayBlockingQueue<ExecutionStep>(
34 STEPS_BUFFER_CAPACITY);
35
36 private Boolean hadAnError = false;
37
38 public ProcessThreadGroup(ExecutionProcess executionProcess) {
39 super("SLC Process #" + executionProcess.getUuid() + " thread group");
40 // this.executionModulesManager = executionModulesManager;
41 // this.processThread = processThread;
42 this.authentication = SecurityContextHolder.getContext()
43 .getAuthentication();
44 }
45
46 public Authentication getAuthentication() {
47 return authentication;
48 }
49
50 public void dispatchAddStep(ExecutionStep step) {
51 // ExecutionProcess slcProcess = processThread.getProcess();
52 // List<ExecutionStep> steps = new ArrayList<ExecutionStep>();
53 // steps.add(step);
54 // TODO clarify why we don't dispatch steps, must be a reason
55 // dispatchAddSteps(steps);
56 // slcProcess.addSteps(steps);
57 if (step.getType().equals(ExecutionStep.ERROR))
58 hadAnError = true;
59 this.steps.add(step);
60 }
61
62 // public void dispatchAddSteps(List<ExecutionStep> steps) {
63 // ExecutionProcess slcProcess = processThread.getProcess();
64 // executionModulesManager.dispatchAddSteps(slcProcess, steps);
65 // }
66
67 public BlockingQueue<ExecutionStep> getSteps() {
68 return steps;
69 }
70
71 public Boolean hadAnError() {
72 return hadAnError;
73 }
74 }