• 首页

  • 分类
    JAVA Linux

  • 文章归档

  • 关于

  • 友情链接
T e r l y 的 秘 密 基 地
T e r l y 的 秘 密 基 地

Terly

CV程序员,面向百度编程

08月
09
JAVA

camunda的el表达式解析与srping bean结合

发表于 2021-08-09 • 字数统计 1652 • 被 901 人看爆

camunda的el表达式解析是基于juel表达式魔改的,基本重写了javax.el这个包,而不是使用java sdk提供的,具体跟javasdk提供的有什么不一样,我没有深入了解

初始化表达式管理器

流程引擎会在初始化流程引擎的时候,通过ProcessEngineFactoryBean对表达式管理器进行初始化,将spring bean和processEngine 的api接口bean放入表达式管理器中,以便表达式进行访问

  protected void initializeExpressionManager() {
    if (processEngineConfiguration.getExpressionManager() == null && applicationContext != null) {
      processEngineConfiguration.setExpressionManager(
          new SpringExpressionManager(applicationContext, processEngineConfiguration.getBeans()));
    }
  }

SpringExpressionManager 继承 ExpressionManager,重写了创建解析器

public class SpringExpressionManager extends ExpressionManager {

  protected ApplicationContext applicationContext;

  /**
   * @param applicationContext
   *          the applicationContext to use. Ignored when 'beans' parameter is
   *          not null.
   * @param beans
   *          a map of custom beans to expose. If null, all beans in the
   *          application-context will be exposed.
   */
  public SpringExpressionManager(ApplicationContext applicationContext, Map<Object, Object> beans) {
    super(beans);
    this.applicationContext = applicationContext;
  }

  @Override
  protected ELResolver createElResolver() {
    CompositeELResolver compositeElResolver = new CompositeELResolver();
    compositeElResolver.add(new VariableScopeElResolver());
    compositeElResolver.add(new VariableContextElResolver());

    if(beans != null) {
      // Only expose limited set of beans in expressions
      compositeElResolver.add(new ReadOnlyMapELResolver(beans));
    } else {
      // Expose full application-context in expressions
      compositeElResolver.add(new ApplicationContextElResolver(applicationContext));
    }

    compositeElResolver.add(new ArrayELResolver());
    compositeElResolver.add(new ListELResolver());
    compositeElResolver.add(new MapELResolver());
    compositeElResolver.add(new BeanELResolver());

    return compositeElResolver;
  }
分享到:
如何使用 CIFS 在 Linux 上挂载 Windows 共享
centos7安装libreOffice7.1
  • 文章目录
  • 站点概览
Terly

程序员 Terly

面向百度编程!

Email RSS
看爆 Top5
  • camunda表达式语言 5,396次看爆
  • camunda多实例任务会签配置说明 3,646次看爆
  • nginx代理项目 项目内部跳转导致丢失端口 1,235次看爆
  • Windows安装Mysql解压版 1,184次看爆
  • 密码校验正则表达式 1,142次看爆
桂ICP备14005919号 桂公网安备 45080302000114号

站点已萌萌哒运行 00 天 00 小时 00 分 00 秒(●'◡'●)ノ♥

Copyright © 2023 Terly

由 Halo 强力驱动 · Theme by Sagiri · 站点地图