Search in sources :

Example 1 with SimpleTemplateRegistry

use of org.mvel2.templates.SimpleTemplateRegistry in project mvel by mikebrock.

the class TemplateTests method testInclusionOfNamedTemplate.

// public void testTemplateFile2() {
// String s = (String) TemplateRuntime.eval(new File("src/test/java/org/mvel2/tests/templates/templateDeclareTest.mv"),
// base, new MapVariableResolverFactory(map), null);
// 
// System.out.println(s);
// 
// }
public void testInclusionOfNamedTemplate() {
    SimpleTemplateRegistry registry = new SimpleTemplateRegistry();
    registry.addNamedTemplate("footemplate", compileTemplate("@{_foo_}@{_bar_}"));
    registry.addNamedTemplate("bartemplate", compileTemplate("@{_bar_}@{_foo_}"));
    String s = "@includeNamed{'footemplate'}  ::  @includeNamed{'bartemplate'}";
    assertEquals("FooBar  ::  BarFoo", TemplateRuntime.eval(s, map, registry));
}
Also used : SimpleTemplateRegistry(org.mvel2.templates.SimpleTemplateRegistry)

Example 2 with SimpleTemplateRegistry

use of org.mvel2.templates.SimpleTemplateRegistry in project drools by kiegroup.

the class AccumulateTemplateTest method getInvokerTemplateRegistry.

private TemplateRegistry getInvokerTemplateRegistry() {
    TemplateRegistry invokerRegistry = new SimpleTemplateRegistry();
    CompiledTemplate compiled = TemplateCompiler.compileTemplate(JavaRuleBuilderHelper.class.getResourceAsStream("javaInvokers.mvel"), (Map<String, Class<? extends Node>>) null);
    TemplateRuntime.execute(compiled, null, invokerRegistry);
    return invokerRegistry;
}
Also used : TemplateRegistry(org.mvel2.templates.TemplateRegistry) SimpleTemplateRegistry(org.mvel2.templates.SimpleTemplateRegistry) Node(org.mvel2.templates.res.Node) SimpleTemplateRegistry(org.mvel2.templates.SimpleTemplateRegistry) CompiledTemplate(org.mvel2.templates.CompiledTemplate)

Example 3 with SimpleTemplateRegistry

use of org.mvel2.templates.SimpleTemplateRegistry in project drools by kiegroup.

the class AccumulateTemplateTest method getRuleTemplateRegistry.

private TemplateRegistry getRuleTemplateRegistry() {
    TemplateRegistry ruleRegistry = new SimpleTemplateRegistry();
    CompiledTemplate compiled = TemplateCompiler.compileTemplate(JavaRuleBuilderHelper.class.getResourceAsStream("javaRule.mvel"), (Map<String, Class<? extends Node>>) null);
    TemplateRuntime.execute(compiled, null, ruleRegistry);
    return ruleRegistry;
}
Also used : TemplateRegistry(org.mvel2.templates.TemplateRegistry) SimpleTemplateRegistry(org.mvel2.templates.SimpleTemplateRegistry) Node(org.mvel2.templates.res.Node) SimpleTemplateRegistry(org.mvel2.templates.SimpleTemplateRegistry) CompiledTemplate(org.mvel2.templates.CompiledTemplate)

Example 4 with SimpleTemplateRegistry

use of org.mvel2.templates.SimpleTemplateRegistry in project drools by kiegroup.

the class JavaRuleBuilderHelper method setInvokerTemplate.

public static void setInvokerTemplate(String name) {
    JAVA_INVOKERS_MVEL = name;
    INVOKER_REGISTRY = new SimpleTemplateRegistry();
}
Also used : SimpleTemplateRegistry(org.mvel2.templates.SimpleTemplateRegistry)

Example 5 with SimpleTemplateRegistry

use of org.mvel2.templates.SimpleTemplateRegistry in project drools by kiegroup.

the class JavaRuleBuilderHelper method setConsequenceTemplate.

public static void setConsequenceTemplate(String name) {
    JAVA_RULE_MVEL = name;
    RULE_REGISTRY = new SimpleTemplateRegistry();
}
Also used : SimpleTemplateRegistry(org.mvel2.templates.SimpleTemplateRegistry)

Aggregations

SimpleTemplateRegistry (org.mvel2.templates.SimpleTemplateRegistry)8 TemplateRegistry (org.mvel2.templates.TemplateRegistry)3 CompiledTemplate (org.mvel2.templates.CompiledTemplate)2 Node (org.mvel2.templates.res.Node)2 MapVariableResolverFactory (org.mvel2.integration.impl.MapVariableResolverFactory)1 TestPluginNode (org.mvel2.tests.templates.tests.res.TestPluginNode)1