/// <summary> Initializes the Velocity parser pool. /// This still needs to be implemented. /// </summary> private void initializeParserPool() { int numParsers = GetInt(RuntimeConstants.PARSER_POOL_SIZE, RuntimeConstants.NUMBER_OF_PARSERS); parserPool = new SimplePool <Parser.Parser>(numParsers); for (int i = 0; i < numParsers; i++) { parserPool.put(CreateNewParser()); } }
/// <summary> /// Parse the input and return the root of the AST node structure. /// </summary> /// <param name="reader">inputstream retrieved by a resource loader</param> /// <param name="templateName">name of the template being parsed</param> /// <param name="dumpNamespace">flag to dump the Velocimacro namespace for this template</param> public SimpleNode Parse(TextReader reader, String templateName, bool dumpNamespace) { SimpleNode ast = null; Parser.Parser parser = (Parser.Parser)parserPool.get(); bool madeNew = false; if (parser == null) { // if we couldn't get a parser from the pool // make one and log it. Error( "Runtime : ran out of parsers. Creating new. Please increment the parser.pool.size property. The current value is too small."); parser = CreateNewParser(); if (parser != null) { madeNew = true; } } // now, if we have a parser if (parser == null) { Error("Runtime : ran out of parsers and unable to create more."); } else { try { // dump namespace if we are told to. Generally, you want to // do this - you don't in special circumstances, such as // when a VM is getting init()-ed & parsed if (dumpNamespace) { DumpVMNamespace(templateName); } ast = parser.Parse(reader, templateName); } finally { // if this came from the pool, then put back if (!madeNew) { parserPool.put(parser); } } } return(ast); }
/// <summary> Initializes the Velocity parser pool. /// This still needs to be implemented. /// </summary> private void initializeParserPool() { int numParsers = getInt(RuntimeConstants_Fields.PARSER_POOL_SIZE, RuntimeConstants_Fields.NUMBER_OF_PARSERS); parserPool = new SimplePool(numParsers); for (int i = 0; i < numParsers; i++) { parserPool.put(createNewParser()); } info("Created: " + numParsers + " parsers."); }
/// <summary> Initializes the Velocity parser pool. /// This still needs to be implemented. /// </summary> private void initializeParserPool() { int numParsers = GetInt(RuntimeConstants.PARSER_POOL_SIZE, RuntimeConstants.NUMBER_OF_PARSERS); parserPool = new SimplePool<Parser.Parser>(numParsers); for(int i = 0; i < numParsers; i++) { parserPool.put(CreateNewParser()); } }