Search in sources :

Example 6 with Program

use of org.beetl.core.statement.Program in project beetl2.0 by javamonkey.

the class GroupTemplate method loadScriptTemplate.

private Template loadScriptTemplate(String key, ResourceLoader loader) {
    Program program = (Program) this.programCache.get(key);
    if (program == null) {
        synchronized (key) {
            if (program == null) {
                Resource resource = loader.getResource(key);
                program = this.loadScript(resource);
                this.programCache.set(key, program);
                return new Template(this, program, this.conf);
            }
        }
    }
    if (resourceLoader.isModified(program.rs)) {
        synchronized (key) {
            Resource resource = loader.getResource(key);
            program = this.loadScript(resource);
            this.programCache.set(key, program);
        }
    }
    return new Template(this, program, this.conf);
}
Also used : Program(org.beetl.core.statement.Program) ErrorGrammarProgram(org.beetl.core.statement.ErrorGrammarProgram)

Example 7 with Program

use of org.beetl.core.statement.Program in project beetl2.0 by javamonkey.

the class GroupTemplate method loadScript.

private Program loadScript(Resource res) {
    try {
        Reader scriptReader = res.openReader();
        Program program = engine.createProgram(res, scriptReader, Collections.EMPTY_MAP, System.getProperty("line.separator"), this);
        return program;
    } catch (BeetlException ex) {
        ErrorGrammarProgram ep = new ErrorGrammarProgram(res, this, System.getProperty("line.separator"));
        ex.pushResource(res);
        ep.setException(ex);
        return ep;
    }
}
Also used : BeetlException(org.beetl.core.exception.BeetlException) Program(org.beetl.core.statement.Program) ErrorGrammarProgram(org.beetl.core.statement.ErrorGrammarProgram) Reader(java.io.Reader) ErrorGrammarProgram(org.beetl.core.statement.ErrorGrammarProgram)

Aggregations

Program (org.beetl.core.statement.Program)7 ErrorGrammarProgram (org.beetl.core.statement.ErrorGrammarProgram)4 ProgramMetaData (org.beetl.core.statement.ProgramMetaData)3 IOException (java.io.IOException)2 Reader (java.io.Reader)2 Configuration (org.beetl.core.Configuration)2 BeetlException (org.beetl.core.exception.BeetlException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)1 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)1 AntlrProgramBuilder (org.beetl.core.AntlrProgramBuilder)1 GroupTemplate (org.beetl.core.GroupTemplate)1 Template (org.beetl.core.Template)1 HTMLTagParserException (org.beetl.core.exception.HTMLTagParserException)1 BeetlLexer (org.beetl.core.parser.BeetlLexer)1 BeetlParser (org.beetl.core.parser.BeetlParser)1 ProgContext (org.beetl.core.parser.BeetlParser.ProgContext)1 FileResourceLoader (org.beetl.core.resource.FileResourceLoader)1