Search in sources :

Example 1 with CompiledTemplate

use of org.mvel2.templates.CompiledTemplate 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 2 with CompiledTemplate

use of org.mvel2.templates.CompiledTemplate 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 3 with CompiledTemplate

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

the class PMML4Helper method applyTemplate.

public void applyTemplate(String templateName, Object context, TemplateRegistry registry, Map vars, StringBuilder builder) {
    CompiledTemplate template = registry.getNamedTemplate(templateName);
    String result = (String) TemplateRuntime.execute(template, context, vars, registry);
    builder.append(result);
}
Also used : CompiledTemplate(org.mvel2.templates.CompiledTemplate)

Example 4 with CompiledTemplate

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

the class PMML4Helper method applyTemplate.

public void applyTemplate(String templateName, Object context, TemplateRegistry registry, Map vars, StringBuilder builder) {
    CompiledTemplate template = registry.getNamedTemplate(templateName);
    String result = (String) TemplateRuntime.execute(template, context, vars, registry);
    builder.append(result);
}
Also used : CompiledTemplate(org.mvel2.templates.CompiledTemplate)

Example 5 with CompiledTemplate

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

the class Miningmodel method addMiningTemplateToRegistry.

@Override
protected void addMiningTemplateToRegistry(TemplateRegistry registry) {
    InputStream inputStream = Scorecard.class.getResourceAsStream(MINING_POJO_TEMPLATE);
    if (inputStream != null) {
        CompiledTemplate ct = TemplateCompiler.compileTemplate(inputStream);
        registry.addNamedTemplate(getMiningPojoTemplateName(), ct);
    }
}
Also used : InputStream(java.io.InputStream) CompiledTemplate(org.mvel2.templates.CompiledTemplate)

Aggregations

CompiledTemplate (org.mvel2.templates.CompiledTemplate)32 HashMap (java.util.HashMap)8 MapVariableResolverFactory (org.mvel2.integration.impl.MapVariableResolverFactory)6 Node (org.mvel2.templates.res.Node)5 InputStream (java.io.InputStream)4 SimpleTemplateRegistry (org.mvel2.templates.SimpleTemplateRegistry)4 TemplateRegistry (org.mvel2.templates.TemplateRegistry)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ParserContext (org.mvel2.ParserContext)3 TemplateCompiler (org.mvel2.templates.TemplateCompiler)3 OutputStream (java.io.OutputStream)2 Date (java.util.Date)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 JavaRuleBuilderHelper (org.drools.mvel.java.JavaRuleBuilderHelper)2 ImmutableDefaultFactory (org.mvel2.integration.impl.ImmutableDefaultFactory)2 TemplateError (org.mvel2.templates.TemplateError)2 TemplateRuntime (org.mvel2.templates.TemplateRuntime)2 TestPluginNode (org.mvel2.tests.templates.tests.res.TestPluginNode)2 StringAppender (org.mvel2.util.StringAppender)2 VertxInternal (io.vertx.core.impl.VertxInternal)1