用于过滤记录的 Mule 表达式语言和全局函数

Mule Expression Language and Global Functions to filter records

我有一个供多个数据编织转换使用的通用函数,所以我想将其编写为 MEL 全局函数。

我配置了全局函数文件 -

<configuration doc:name="Configuration">
        <expression-language>
            <import class="org.apache.commons.lang3.StringUtils"></import>
            <global-functions file="global_expressions.mvel">
            </global-functions>
        </expression-language>
    </configuration>

然后我有一个 global_expressions.mvel 文件,我想要一个像 -

这样的函数
def filterE1Records(route,type){
                    if(type == 'COR'){
                        return (route >= '${min.route}' and route <= '${max.route}');
                    } else if(type == 'NONCOR'){
                        return ((route >= '${min.route}' and route <= '${max.route}') == false and route != '${ndsin.route}');
                    } else if(type == 'NDS'){
                        return route == '${ndsin.route}';
                    } else {
                        return false;
                    }

                }

带有 属性 占位符的上述函数不起作用,即 none 的记录通过。但是,如果我对值进行硬编码,那么我会看到按预期过滤记录 -

def filterE1Records(route,type){
                    if(type == 'COR'){
                        return (route >= 10000 and route <= 15000);
                    } else if(type == 'NONCOR'){
                        return ((route >= 10000 and route <= 15000) == false and route != 15001);
                    } else if(type == 'NDS'){
                        return route == 15001;
                    } else {
                        return false;
                    }

                }

如果我删除 属性 周围的单引号 ' 使其成为数字,则 DW 代码在运行时会失败。

知道如何进行比较吗?

谢谢。

Based on the discussion in comments, I'm going to assume that property resolution does not work in imported MEL files.

您可以通过 Spring setter 注入将这些不同的属性加载到 bean 中,或者使用 Spring 的实用程序加载到 java.util.Properties 对象中,然后查看它们最多:

app.registry.myConfigBean.minRoute

或:

app.registry.myConfigProperties['min.route']