Search in sources :

Example 6 with Interceptor

use of org.mvel2.integration.Interceptor in project mvel by mikebrock.

the class CoreConfidenceTests method testInterceptors.

public void testInterceptors() {
    Interceptor testInterceptor = new Interceptor() {

        public int doBefore(ASTNode node, VariableResolverFactory factory) {
            System.out.println("BEFORE Node: " + node.getName());
            return 0;
        }

        public int doAfter(Object val, ASTNode node, VariableResolverFactory factory) {
            System.out.println("AFTER Node: " + node.getName());
            return 0;
        }
    };
    Map<String, Interceptor> interceptors = new HashMap<String, Interceptor>();
    interceptors.put("test", testInterceptor);
    executeExpression(compileExpression("@test System.out.println('MIDDLE');", null, interceptors));
}
Also used : DefaultLocalVariableResolverFactory(org.mvel2.integration.impl.DefaultLocalVariableResolverFactory) VariableResolverFactory(org.mvel2.integration.VariableResolverFactory) MapVariableResolverFactory(org.mvel2.integration.impl.MapVariableResolverFactory) ASTNode(org.mvel2.ast.ASTNode) Interceptor(org.mvel2.integration.Interceptor)

Aggregations

Interceptor (org.mvel2.integration.Interceptor)5 MapVariableResolverFactory (org.mvel2.integration.impl.MapVariableResolverFactory)5 HashMap (java.util.HashMap)4 ASTNode (org.mvel2.ast.ASTNode)4 ExpressionCompiler (org.mvel2.compiler.ExpressionCompiler)4 VariableResolverFactory (org.mvel2.integration.VariableResolverFactory)4 WithNode (org.mvel2.ast.WithNode)3 CompiledExpression (org.mvel2.compiler.CompiledExpression)3 Debugger (org.mvel2.debug.Debugger)3 Frame (org.mvel2.debug.Frame)3 HashSet (java.util.HashSet)2 Macro (org.mvel2.Macro)2 ParserContext (org.mvel2.ParserContext)2 DefaultLocalVariableResolverFactory (org.mvel2.integration.impl.DefaultLocalVariableResolverFactory)2 Foo (org.mvel2.tests.core.res.Foo)2 CompileException (org.mvel2.CompileException)1