简体   繁体   English

截取一个MVEL表达式中每个函数的输入和输出

[英]Intercept input and output of each function in an MVEL expression

I am quite new to MVEL.我对 MVEL 很陌生。 What I am trying to achieve is to log input and outputs of every function in an expression.我想要实现的是记录表达式中每个函数的输入和输出。

For example, having the following expression例如,具有以下表达式

h.function1('value1') != h.function2('value2') 

what I am trying to log is the input and output values of function1 and function2 .我想要记录的是function1function2的输入和输出值。 I read about Interceptors .我读过拦截器 If I do undestand right, to add and interceptor I need to rewrite the above expression as the following.如果我没有理解正确,要添加和拦截器,我需要将上面的表达式重写为以下内容。

@Intercept h.function1('value1') != @Intercept h.function2('value2')

However, I cannot force my users to add the @Intercept annotation.但是,我不能强迫我的用户添加@Intercept注释。

Which is the best way to accomplish this task?完成此任务的最佳方法是什么? Have I to resume Spring AOP?我必须恢复 Spring AOP 吗? :( :(

It's not @Intercept but the name of intercept you put in map.这不是@Intercept,而是您放入地图的拦截名称。 Bellow is @test annotation.波纹管是@test 注释。 Please check detail here https://github.com/mvel/mvel/blob/master/src/test/java/org/mvel2/tests/core/CoreConfidenceTests.java请在此处查看详细信息https://github.com/mvel/mvel/blob/master/src/test/java/org/mvel2/tests/core/CoreConfidenceTests.java

interceptors.put("test",
        testInterceptor);

 executeExpression(compileExpression("@test System.out.println('MIDDLE');",
        null,
        interceptors));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM