mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
使用ContextAwareHolder.loadContextAware改造获取线程构建者
This commit is contained in:
@@ -398,6 +398,15 @@ public class FlowExecutor {
|
||||
}
|
||||
slot.setException(e);
|
||||
} finally {
|
||||
try{
|
||||
if (ObjectUtil.isNotNull(chain)){
|
||||
chain.executeFinally(slotIndex);
|
||||
}
|
||||
}catch (Exception e){
|
||||
String errMsg = StrUtil.format("[{}]:an exception occurred during the finally Component execution in chain[{}]", slot.getRequestId(), chain.getChainName());
|
||||
LOG.error(errMsg, e);
|
||||
}
|
||||
|
||||
if (!isInnerChain) {
|
||||
slot.printStep();
|
||||
DataBus.releaseSlot(slotIndex);
|
||||
|
||||
@@ -79,17 +79,6 @@ public class Chain implements Executable {
|
||||
if (CollUtil.isEmpty(conditionList)) {
|
||||
throw new FlowSystemException("no conditionList in this chain[" + chainName + "]");
|
||||
}
|
||||
try {
|
||||
executeBody(slotIndex);
|
||||
} finally {
|
||||
executeFinally(slotIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// 执行主体的逻辑
|
||||
private void executeBody(Integer slotIndex) throws Exception {
|
||||
//循环chain里包含的condition,每一个condition分四种类型:pre,then,when,finally
|
||||
//这里conditionList其实已经是有序的,pre一定在最前面,finally一定在最后面
|
||||
for (Condition condition : conditionList) {
|
||||
if (condition instanceof PreCondition){
|
||||
for (Executable executableItem : condition.getNodeList()) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.google.common.collect.Maps;
|
||||
import com.yomahub.liteflow.exception.ThreadExecutorServiceCreateException;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.ContextAwareHolder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -123,7 +124,8 @@ public class ExecutorHelper {
|
||||
*/
|
||||
private ExecutorBuilder getExecutorBuilder(String threadExecutorClass) {
|
||||
try {
|
||||
return (ExecutorBuilder) Class.forName(threadExecutorClass).newInstance();
|
||||
Class<ExecutorBuilder> executorClass = (Class<ExecutorBuilder>) Class.forName(threadExecutorClass);
|
||||
return ContextAwareHolder.loadContextAware().registerBean(executorClass);
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
throw new ThreadExecutorServiceCreateException(e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user