org.mvel2.templates.TemplateRuntime Java Examples

The following examples show how to use org.mvel2.templates.TemplateRuntime. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpdateSpringBootAutoConfigurationReadmeMojo.java    From camel-spring-boot with Apache License 2.0 7 votes vote down vote up
private String templateAutoConfigurationOptions(List<SpringBootAutoConfigureOptionModel> options, String componentName) throws MojoExecutionException {
    SpringBootModel model = new SpringBootModel();
    model.setGroupId(project.getGroupId());
    model.setArtifactId("camel-" + componentName + "-starter");
    model.setVersion(project.getVersion());
    model.setOptions(options);
    model.setTitle(componentName);

    try {
        String template = loadText(UpdateSpringBootAutoConfigurationReadmeMojo.class.getClassLoader().getResourceAsStream("spring-boot-auto-configure-options.mvel"));
        String out = (String) TemplateRuntime.eval(template, model, Collections.singletonMap("util", MvelHelper.INSTANCE));
        return out;
    } catch (Exception e) {
        throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
    }
}
 
Example #2
Source File: JavaRuleBuilderHelper.java    From kogito-runtimes with Apache License 2.0 7 votes vote down vote up
public static synchronized TemplateRegistry getInvokerTemplateRegistry(ClassLoader cl) {
    if ( !INVOKER_REGISTRY.contains( "invokers" ) ) {
        InputStream javaInvokersMvelStream = JavaRuleBuilderHelper.class.getResourceAsStream( JAVA_INVOKERS_MVEL );
        INVOKER_REGISTRY.addNamedTemplate( "invokers",
                                           TemplateCompiler.compileTemplate( javaInvokersMvelStream ) );
        try {
            javaInvokersMvelStream.close();
        } catch ( IOException ex ) {
            logger.debug( "Failed to close stream!", ex );
        }
        TemplateRuntime.execute( INVOKER_REGISTRY.getNamedTemplate( "invokers" ),
                                 null,
                                 INVOKER_REGISTRY );            
    }        
    return INVOKER_REGISTRY;
}
 
Example #3
Source File: UpdateDocComponentsListMojo.java    From camel-spring-boot with Apache License 2.0 6 votes vote down vote up
private String templateComponents(List<ComponentModel> models, int artifacts, long deprecated)
        throws MojoExecutionException {
    try {
        String template = loadText(
                UpdateDocComponentsListMojo.class.getClassLoader().getResourceAsStream("readme-components.mvel"));
        Map<String, Object> map = new HashMap<>();
        map.put("components", models);
        map.put("numberOfArtifacts", artifacts);
        map.put("numberOfDeprecated", deprecated);
        String out = (String) TemplateRuntime.eval(template, map,
                Collections.singletonMap("util", new ExtMvelHelper(getComponentsStarterDocPath())));
        return out;
    } catch (Exception e) {
        throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
    }
}
 
Example #4
Source File: UpdateDocComponentsListMojo.java    From camel-spring-boot with Apache License 2.0 6 votes vote down vote up
private String templateDataFormats(List<DataFormatModel> models, int artifacts, long deprecated)
        throws MojoExecutionException {
    try {
        String template = loadText(
                UpdateDocComponentsListMojo.class.getClassLoader().getResourceAsStream("readme-dataformats.mvel"));
        Map<String, Object> map = new HashMap<>();
        map.put("dataformats", models);
        map.put("numberOfArtifacts", artifacts);
        map.put("numberOfDeprecated", deprecated);
        String out = (String) TemplateRuntime.eval(template, map,
                Collections.singletonMap("util", new ExtMvelHelper(getComponentsStarterDocPath())));
        return out;
    } catch (Exception e) {
        throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
    }
}
 
Example #5
Source File: AbstractJavaProcessBuilder.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
public void generateTemplates(final String ruleTemplate,
                             final String invokerTemplate,
                             final ProcessBuildContext context,
                             final String className,
                             final Map vars,
                             final Object invokerLookup,
                             final BaseDescr descrLookup) {
    TemplateRegistry registry = getRuleTemplateRegistry();

    context.getMethods().add((String)
            TemplateRuntime.execute(registry.getNamedTemplate(ruleTemplate), null, new MapVariableResolverFactory(vars), registry)
    );

    registry = getInvokerTemplateRegistry();
    final String invokerClassName = context.getPkg().getName() + "." + context.getProcessDescr().getClassName() + StringUtils.ucFirst(className) + "Invoker";

    context.getInvokers().put(invokerClassName,
            (String)TemplateRuntime.execute(registry.getNamedTemplate(invokerTemplate), null, new MapVariableResolverFactory(vars), registry)
    );

    context.addInvokerLookup(invokerClassName, invokerLookup);
    context.addDescrLookups(invokerClassName, descrLookup);
}
 
Example #6
Source File: JavaRuleBuilderHelper.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
public static synchronized TemplateRegistry getRuleTemplateRegistry(ClassLoader cl) {
    if ( !RULE_REGISTRY.contains( "rules" ) ) {
        InputStream javaRuleMvelStream = JavaRuleBuilderHelper.class.getResourceAsStream( JAVA_RULE_MVEL );
        RULE_REGISTRY.addNamedTemplate( "rules",
                                        TemplateCompiler.compileTemplate( javaRuleMvelStream ) );
        try {
            javaRuleMvelStream.close();
        } catch ( IOException ex ) {
            logger.debug( "Failed to close stream!", ex );
        }
        TemplateRuntime.execute( RULE_REGISTRY.getNamedTemplate( "rules" ),
                                 null,
                                 RULE_REGISTRY );            
    }
    
    return RULE_REGISTRY;
}
 
Example #7
Source File: JavaRuleBuilderHelper.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
private static void generateInvokerTemplate(final String invokerTemplate,
                                            final RuleBuildContext context,
                                            final String className,
                                            final Map vars,
                                            final Object invokerLookup,
                                            final BaseDescr descrLookup) {
    TemplateRegistry registry = getInvokerTemplateRegistry(context.getKnowledgeBuilder().getRootClassLoader());
    final String invokerClassName = context.getPkg().getName() + "." + context.getRuleDescr().getClassName() + StringUtils.ucFirst( className ) + "Invoker";

    context.addInvoker( invokerClassName,
                        (String) TemplateRuntime.execute( registry.getNamedTemplate( invokerTemplate ),
                                                          null,
                                                          new MapVariableResolverFactory( vars ),
                                                          registry ) );

    context.addInvokerLookup( invokerClassName, invokerLookup );
    context.addDescrLookups( invokerClassName, descrLookup );
}
 
Example #8
Source File: DrlDumper.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public String dump( final PackageDescr pkg ) {
    Map<String, Object> context = new HashMap<String, Object>();
    context.put( "pkg",
                 pkg );
    context.put( "mvel",
                 mvel );

    return (String) TemplateRuntime.execute( REPORT_REGISTRY.getNamedTemplate( "drl" ),
                                             null,
                                             new MapVariableResolverFactory( context ),
                                             REPORT_REGISTRY );
}
 
Example #9
Source File: PolicyTemplateUtil.java    From apiman with Apache License 2.0 5 votes vote down vote up
/**
 * Generates a dynamic description for the given policy and stores the
 * result on the policy bean instance.  This should be done prior
 * to returning the policybean back to the user for a REST call to the
 * management API.
 * @param policy the policy
 * @throws Exception any exception
 */
public static void generatePolicyDescription(PolicyBean policy) throws Exception {
    PolicyDefinitionBean def = policy.getDefinition();
    PolicyDefinitionTemplateBean templateBean = getTemplateBean(def);
    if (templateBean == null) {
        return;
    }
    String cacheKey = def.getId() + "::" + templateBean.getLanguage(); //$NON-NLS-1$
    CompiledTemplate template = templateCache.get(cacheKey);
    if (template == null) {
        template = TemplateCompiler.compileTemplate(templateBean.getTemplate());
        templateCache.put(cacheKey, template);
    }
    try {
        // TODO hack to fix broken descriptions - this util should probably not know about encrypted data
        String jsonConfig = policy.getConfiguration();
        if (CurrentDataEncrypter.instance != null) {
            EntityType entityType = EntityType.Api;
            if (policy.getType() == PolicyType.Client) {
                entityType = EntityType.ClientApp;
            } else if (policy.getType() == PolicyType.Plan) {
                entityType = EntityType.Plan;
            }
            DataEncryptionContext ctx = new DataEncryptionContext(policy.getOrganizationId(),
                    policy.getEntityId(), policy.getEntityVersion(), entityType);
            jsonConfig = CurrentDataEncrypter.instance.decrypt(jsonConfig, ctx);
        }
        Map<String, Object> configMap = mapper.readValue(jsonConfig, Map.class);
        configMap = new PolicyConfigMap(configMap);
        String desc = (String) TemplateRuntime.execute(template, configMap);
        policy.setDescription(desc);
    } catch (Exception e) {
        e.printStackTrace();
        // TODO properly log the error
        policy.setDescription(templateBean.getTemplate());
    }
}
 
Example #10
Source File: ParseHelper.java    From zealot with Apache License 2.0 5 votes vote down vote up
/**
 * 通过MVEL来解析模板的值.
 * @param template 待解析表达式
 * @param paramObj 参数对象
 * @return 返回解析后的结果
 */
public static String parseTemplate(String template, Object paramObj) {
    String output;
    try {
        output = (String) TemplateRuntime.eval(template, paramObj);
    } catch (Exception e) {
        throw new ParseExpressionException("解析Mvel模板异常,解析出错的模板为:" + template, e);
    }
    return output;
}
 
Example #11
Source File: SessionReporter.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public static void addNamedTemplate(String name,
                                    InputStream template) {
    REPORT_REGISTRY.addNamedTemplate( name,
                                      TemplateCompiler.compileTemplate( template,
                                                                        (Map<String, Class<? extends Node>>) null ) );
    /*
     * Process these templates
     */
    TemplateRuntime.execute( REPORT_REGISTRY.getNamedTemplate( name ),
                             null,
                             REPORT_REGISTRY );
}
 
Example #12
Source File: SessionReporter.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public static String generateReport(final String ruleTemplate,
                                    final StatefulKnowledgeSessionInfo session,
                                    final Map<String, Object> vars) {
    Map<String, Object> context = new HashMap<String, Object>();
    if ( vars != null ) {
        context.putAll( vars );
    }
    context.put( "session",
                 session );

    return (String) TemplateRuntime.execute( REPORT_REGISTRY.getNamedTemplate( ruleTemplate ),
                                             null,
                                             new MapVariableResolverFactory( context ),
                                             REPORT_REGISTRY );
}
 
Example #13
Source File: AccumulateTemplateTest.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #14
Source File: AccumulateTemplateTest.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #15
Source File: CamelKafkaConnectorUpdateMojo.java    From camel-kafka-connector with Apache License 2.0 5 votes vote down vote up
private String templateAutoConfigurationOptions(List<CamelKafkaConnectorOptionModel> options, String componentName, File connectorDir, ConnectorType ct)
    throws MojoExecutionException {

    CamelKafkaConnectorModel model = new CamelKafkaConnectorModel();
    model.setOptions(options);
    model.setArtifactId(getMainDepArtifactId());
    model.setGroupId(getMainDepGroupId());
    model.setVersion(getMainDepVersion());
    if (getMainDepArtifactId().equalsIgnoreCase("camel-coap+tcp")) {
        model.setTitle("camel-coap-tcp");
    } else if (getMainDepArtifactId().equalsIgnoreCase("camel-coaps+tcp")) {
        model.setTitle("camel-coaps-tcp");
    } else {
        model.setTitle(getMainDepArtifactId());
    }

    try {
        String template = null;
        if (ct.name().equals(ConnectorType.SINK.name())) {
            template = loadText(CamelKafkaConnectorUpdateMojo.class.getClassLoader().getResourceAsStream("camel-kafka-connector-sink-options.mvel"));
        } else if (ct.name().equals(ConnectorType.SOURCE.name())) {
            template = loadText(CamelKafkaConnectorUpdateMojo.class.getClassLoader().getResourceAsStream("camel-kafka-connector-source-options.mvel"));
        }
        String out = (String)TemplateRuntime.eval(template, model, Collections.singletonMap("util", MvelHelper.INSTANCE));
        return out;
    } catch (Exception e) {
        throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
    }
}
 
Example #16
Source File: DrlDumper.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public DrlDumper() {
    REPORT_REGISTRY.addNamedTemplate( "drl",
                                      TemplateCompiler.compileTemplate( DrlDumper.class.getResourceAsStream( "drl.mvel" ),
                                                                        (Map<String, Class< ? extends Node>>) null ) );

    /**
     * Process these templates
     */
    TemplateRuntime.execute( REPORT_REGISTRY.getNamedTemplate( "drl" ),
                             null,
                             REPORT_REGISTRY );
}
 
Example #17
Source File: JavaRuleBuilderHelper.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public static void generateMethodTemplate(final String ruleTemplate, final RuleBuildContext context, final Map vars) {
    TemplateRegistry registry = getRuleTemplateRegistry(context.getKnowledgeBuilder().getRootClassLoader());

    context.addMethod((String) TemplateRuntime.execute( registry.getNamedTemplate(ruleTemplate),
                                                        null,
                                                        new MapVariableResolverFactory(vars),
                                                        registry) );
}
 
Example #18
Source File: UpdateDocComponentsListMojo.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
private String templateOthers(List<OtherModel> models, int artifacts, long deprecated) throws MojoExecutionException {
    try {
        String template = loadText(
                UpdateDocComponentsListMojo.class.getClassLoader().getResourceAsStream("readme-others.mvel"));
        Map<String, Object> map = new HashMap<>();
        map.put("others", models);
        map.put("numberOfArtifacts", artifacts);
        map.put("numberOfDeprecated", deprecated);
        String out = (String) TemplateRuntime.eval(template, map,
                Collections.singletonMap("util", new ExtMvelHelper(getComponentsStarterDocPath())));
        return out;
    } catch (Exception e) {
        throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
    }
}
 
Example #19
Source File: UpdateDocComponentsListMojo.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
private String templateLanguages(List<LanguageModel> models, int artifacts, long deprecated) throws MojoExecutionException {
    try {
        String template = loadText(
                UpdateDocComponentsListMojo.class.getClassLoader().getResourceAsStream("readme-languages.mvel"));
        Map<String, Object> map = new HashMap<>();
        map.put("languages", models);
        map.put("numberOfArtifacts", artifacts);
        map.put("numberOfDeprecated", deprecated);
        String out = (String) TemplateRuntime.eval(template, map,
                Collections.singletonMap("util", new ExtMvelHelper(getComponentsStarterDocPath())));
        return out;
    } catch (Exception e) {
        throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
    }
}
 
Example #20
Source File: UpdateDocComponentsListMojo.java    From camel-kafka-connector with Apache License 2.0 5 votes vote down vote up
private String templateConnnectorsTable(CamelKafkaConnectorTableModel model) throws MojoExecutionException {

        try {
            String template = null;
            template = loadText(UpdateDocComponentsListMojo.class.getClassLoader().getResourceAsStream("connectors.mvel"));
            String out = (String)TemplateRuntime.eval(template, model, Collections.singletonMap("util", MvelHelper.INSTANCE));
            return out;
        } catch (Exception e) {
            throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
        }
    }
 
Example #21
Source File: AccumulateTemplateTest.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
@Test
public void testInvokerGenerationSinglePattern() {
    final String className = "accumulate0";

    final String[] declarationTypes = new String[]{"String", "int"};
    final Declaration[] declarations = new Declaration[]{new Declaration( "name",
                                                                          store.getReader( Person.class,
                                                                                           "name" ),
                                                                          null ), new Declaration( "age",
                                                                                                   store.getReader( Person.class,
                                                                                                                    "age" ),
                                                                                                   null )};
    final Declaration[] inner = new Declaration[]{new Declaration( "cheese",
                                                                   new PatternExtractor( new ClassObjectType( Cheese.class ) ),
                                                                   null ), new Declaration( "price",
                                                                                            store.getReader( Cheese.class,
                                                                                                             "price" ),
                                                                                            null )};
    final String[] globals = new String[]{"aGlobal", "anotherGlobal"};
    final List globalTypes = Arrays.asList( new String[]{"String", "String"} );

    final Map map = new HashMap();

    map.put( "className",
             StringUtils.ucFirst( className ) );

    map.put( "instanceName",
             className );

    map.put( "package",
             "org.drools" );

    map.put( "ruleClassName",
             "Rule0" );

    map.put( "invokerClassName",
             "Rule0" + StringUtils.ucFirst( className ) + "Invoker" );

    map.put( "declarations",
             declarations );

    map.put( "declarationTypes",
             declarationTypes );

    map.put( "globals",
             globals );

    map.put( "globalTypes",
             globalTypes );

    map.put( "innerDeclarations",
             inner );

    map.put( "attributes",
             new Attribute[]{new Attribute( "int",
                                            "x" )} );
    map.put( "initCode",
             "x = 0;" );
    map.put( "actionCode",
             "x += 1;" );
    map.put( "reverseCode",
             "" );
    map.put( "resultCode",
             "x + 10" );

    map.put( "supportsReverse",
             "false" );

    map.put( "resultType",
             Integer.class );

    map.put( "hashCode",
             new Integer( 10 ) );
    map.put( "isMultiPattern",
             Boolean.FALSE );

    TemplateRegistry registry = getInvokerTemplateRegistry();
    Object method = TemplateRuntime.execute( registry.getNamedTemplate( "accumulateInvoker" ),
                                             null,
                                             new MapVariableResolverFactory( map ),
                                             registry );

    //System.out.println( method );
}
 
Example #22
Source File: AccumulateTemplateTest.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
@Test
public void testInvokerGenerationMultiPattern() {
    final String className = "accumulate0";

    final String[] declarationTypes = new String[]{"String", "int"};
    final Declaration[] declarations = new Declaration[]{new Declaration( "name",
                                                                          store.getReader( Person.class,
                                                                                           "name" ),
                                                                          null ), new Declaration( "age",
                                                                                                   store.getReader( Person.class,
                                                                                                                    "age" ),
                                                                                                   null )};
    final Declaration[] inner = new Declaration[]{new Declaration( "$cheese",
                                                                   new PatternExtractor( new ClassObjectType( Cheese.class ) ),
                                                                   null ), new Declaration( "$person",
                                                                                            new PatternExtractor( new ClassObjectType( Person.class ) ),
                                                                                            null )};
    final String[] globals = new String[]{"aGlobal", "anotherGlobal"};
    final List globalTypes = Arrays.asList( new String[]{"String", "String"} );

    final Map map = new HashMap();

    map.put( "className",
             StringUtils.ucFirst( className ) );

    map.put( "instanceName",
             className );

    map.put( "package",
             "org.drools" );

    map.put( "ruleClassName",
             "Rule0" );

    map.put( "invokerClassName",
             "Rule0" + StringUtils.ucFirst( className ) + "Invoker" );

    map.put( "declarations",
             declarations );

    map.put( "declarationTypes",
             declarationTypes );

    map.put( "globals",
             globals );

    map.put( "globalTypes",
             globalTypes );

    map.put( "innerDeclarations",
             inner );

    map.put( "attributes",
             new Attribute[]{new Attribute( "int",
                                            "x" )} );
    map.put( "initCode",
             "x = 0;" );
    map.put( "actionCode",
             "x += 1;" );
    map.put( "reverseCode",
             "" );
    map.put( "resultCode",
             "x + 10" );

    map.put( "supportsReverse",
             "false" );

    map.put( "resultType",
             Integer.class );

    map.put( "hashCode",
             new Integer( 10 ) );
    map.put( "isMultiPattern",
             Boolean.TRUE );

    TemplateRegistry registry = getInvokerTemplateRegistry();
    Object method = TemplateRuntime.execute( registry.getNamedTemplate( "accumulateInvoker" ),
                                             null,
                                             new MapVariableResolverFactory( map ),
                                             registry );

    //System.out.println( method );
}
 
Example #23
Source File: AccumulateTemplateTest.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
@Test
public void testMethodGeneration() {
    final String className = "accumulate0";

    final String[] declarationTypes = new String[]{"String", "int"};
    final Declaration[] declarations = new Declaration[]{new Declaration( "name",
                                                                          null,
                                                                          null ), new Declaration( "age",
                                                                                                   null,
                                                                                                   null )};
    final Declaration[] inner = new Declaration[]{new Declaration( "cheese",
                                                                   new PatternExtractor( new ClassObjectType( Cheese.class ) ),
                                                                   null ), new Declaration( "price",
                                                                                            store.getReader( Cheese.class,
                                                                                                             "price" ),
                                                                                            null )};
    final String[] globals = new String[]{"aGlobal", "anotherGlobal"};
    final List globalTypes = Arrays.asList( new String[]{"String", "String"} );

    final Map map = new HashMap();

    map.put( "className",
             StringUtils.ucFirst( className ) );

    map.put( "instanceName",
             className );

    map.put( "package",
             "org.drools" );

    map.put( "ruleClassName",
             "Rule0" );

    map.put( "invokerClassName",
             "Rule0" + StringUtils.ucFirst( className ) + "Invoker" );

    map.put( "declarations",
             declarations );

    map.put( "declarationTypes",
             declarationTypes );

    map.put( "globals",
             globals );

    map.put( "globalTypes",
             globalTypes );

    map.put( "innerDeclarations",
             inner );

    map.put( "attributes",
             new String[]{"x"} );
    map.put( "attributesTypes",
             new String[]{"int"} );
    map.put( "initCode",
             "x = 0;" );
    map.put( "actionCode",
             "x += 1;" );
    map.put( "reverseCode",
             "x -= 1;" );
    map.put( "resultCode",
             "x + 10" );
    map.put( "supportsReverse",
             "true" );

    map.put( "resultType",
             Integer.class );

    map.put( "hashCode",
             new Integer( 10 ) );

    TemplateRegistry registry = getRuleTemplateRegistry();

    Object method = TemplateRuntime.execute( registry.getNamedTemplate( "accumulateInnerClass" ),
                                             null,
                                             new MapVariableResolverFactory( map ),
                                             registry );

    //System.out.println( method );
}
 
Example #24
Source File: MvelTemplateEngine.java    From spark-template-engines with Apache License 2.0 4 votes vote down vote up
@Override
public String render(final ModelAndView modelAndView) {
    final CompiledTemplate compiledTemplate = loadTemplate(modelAndView.getViewName());
    return (String) TemplateRuntime.execute(compiledTemplate, modelAndView.getModel());
}
 
Example #25
Source File: PayloadExpressionEvaluator.java    From chancery with Apache License 2.0 4 votes vote down vote up
public final String evaluateForPayload(@Nonnull CallbackPayload payload) {
    return (String) TemplateRuntime.execute(compiledTemplate, payload);
}