activiti运行分析

activiti运行分析
1.初始化配置分析
1.1核心组件-命令执行器CommandExecutor
activiti整体设计使用命令模式,每一步操作都是一个命令,每一个命令都通过CommandExecutor执行.
看一下它的初始化过程:

protected CommandInterceptor initInterceptorChain(List<CommandInterceptor> chain) {
	if (chain==null || chain.isEmpty()) {
	  throw new ActivitiException("invalid command interceptor chain configuration: "+chain);
	}
	for (int i = 0; i < chain.size()-1; i++) {
	  chain.get(i).setNext( chain.get(i+1) );
	}
	return chain.get(0);
}

//初始化
CommandInterceptor first = initInterceptorChain(commandInterceptors);
commandExecutor = new CommandExecutorImpl(getDefaultCommandConfig(), first);

其中,最后一个拦截器是CommandInvoker是执行命令的拦截器
内容如下:

public <T> T execute(CommandConfig config, Command<T> command) {
	return command.execute(Context.getCommandContext());
}

1.2 JobExecutor-驱动异步job执行
服务程序,扫描数据库job表,执行job任务
1.3 AsyncExecutor-异步执行
服务程序,扫描数据库job表,执行job任务

简要说一下命令的触发执行人:1.客户端线程 2.JobExecutor 3.AsyncExecutor

1.4 IdGenerator 唯一id生成器,默认是DbIdGenerator

2.执行分析
2.1 操作分析

//流程启动
AtomicOperation PROCESS_START = new AtomicOperationProcessStart();
//流程初始化
AtomicOperation PROCESS_START_INITIAL = new AtomicOperationProcessStartInitial();
//流程结束
AtomicOperation PROCESS_END = new AtomicOperationProcessEnd();
//活动启动
AtomicOperation ACTIVITY_START = new AtomicOperationActivityStart();
//活动执行
AtomicOperation ACTIVITY_EXECUTE = new AtomicOperationActivityExecute();
//活动结束
AtomicOperation ACTIVITY_END = new AtomicOperationActivityEnd();
//过渡通知监听器过渡结束
AtomicOperation TRANSITION_NOTIFY_LISTENER_END = new AtomicOperationTransitionNotifyListenerEnd();
//过渡关闭scope
AtomicOperation TRANSITION_DESTROY_SCOPE = new AtomicOperationTransitionDestroyScope();
//过渡通知take
AtomicOperation TRANSITION_NOTIFY_LISTENER_TAKE = new AtomicOperationTransitionNotifyListenerTake();
//过渡创建域
AtomicOperation TRANSITION_CREATE_SCOPE = new AtomicOperationTransitionCreateScope();
//过渡通知监听器过渡开始
AtomicOperation TRANSITION_NOTIFY_LISTENER_START = new AtomicOperationTransitionNotifyListenerStart();
//关联删除
AtomicOperation DELETE_CASCADE = new AtomicOperationDeleteCascade();
//关联删除触发活动结束
AtomicOperation DELETE_CASCADE_FIRE_ACTIVITY_END = new AtomicOperationDeleteCascadeFireActivityEnd();

简要说一下:工作流中这部分采用责任链设计
流程启动操作后触发流程初始化然后活动,过渡,销毁等操作

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值