/** * <p> * This constructor should only be called directly for <strong>testing purposes</strong>. * </p> * * @param configuration the engine configuration */ public TemplateManager(final IEngineConfiguration configuration) { super(); Validate.notNull(configuration, "Configuration cannot be null"); this.configuration = configuration; final ICacheManager cacheManager = this.configuration.getCacheManager(); if (cacheManager == null) { this.templateCache = null; } else { this.templateCache = cacheManager.getTemplateCache(); } final boolean standardDialectPresent = this.configuration.isStandardDialectPresent(); // TODO Make these parser implementations configurable: one parser per template mode, then make default implementations extensible/configurable (e.g. AttoParser config) this.htmlParser = new HTMLTemplateParser(DEFAULT_PARSER_POOL_SIZE,DEFAULT_PARSER_BLOCK_SIZE); this.xmlParser = new XMLTemplateParser(DEFAULT_PARSER_POOL_SIZE, DEFAULT_PARSER_BLOCK_SIZE); this.textParser = new TextTemplateParser(DEFAULT_PARSER_POOL_SIZE, DEFAULT_PARSER_BLOCK_SIZE, standardDialectPresent); this.javascriptParser = new JavaScriptTemplateParser(DEFAULT_PARSER_POOL_SIZE, DEFAULT_PARSER_BLOCK_SIZE, standardDialectPresent); this.cssParser = new CSSTemplateParser(DEFAULT_PARSER_POOL_SIZE, DEFAULT_PARSER_BLOCK_SIZE, standardDialectPresent); this.rawParser = new RawTemplateParser(DEFAULT_PARSER_POOL_SIZE, DEFAULT_PARSER_BLOCK_SIZE); }
/** * <p> * This constructor should only be called directly for <p>testing purposes</p>. * </p> * * @param configuration the configuration being currently used. */ public TemplateRepository(final Configuration configuration) { super(); Validate.notNull(configuration, "Configuration object cannot be null"); final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager == null) { this.templateCache = null; this.fragmentCache = null; } else { this.templateCache = cacheManager.getTemplateCache(); this.fragmentCache = cacheManager.getFragmentCache(); } this.parsersByTemplateMode = new HashMap<String,ITemplateParser>(10, 1.0f); for (final ITemplateModeHandler handler : configuration.getTemplateModeHandlers()) { this.parsersByTemplateMode.put(handler.getTemplateModeName(), handler.getTemplateParser()); } }