/** * <p> * Returns the cache manager in effect. This manager is in charge of providing * the various caches needed by the system during its process. * </p> * <p> * By default, an instance of {@link org.thymeleaf.cache.StandardCacheManager} * is set. * </p> * * @return the cache manager */ public final ICacheManager getCacheManager() { if (this.initialized) { return this.configuration.getCacheManager(); } return this.cacheManager; }
static <V> void removeFromCache(final IEngineConfiguration configuration, final String input, final String type) { final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { final ICache<ExpressionCacheKey,Object> cache = cacheManager.getExpressionCache(); if (cache != null) { cache.clearKey(new ExpressionCacheKey(type,input)); } } }
static Object getFromCache(final IEngineConfiguration configuration, final String input, final String type) { final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { final ICache<ExpressionCacheKey,Object> cache = cacheManager.getExpressionCache(); if (cache != null) { return cache.get(new ExpressionCacheKey(type,input)); } } return null; }
static <V> void putIntoCache(final IEngineConfiguration configuration, final String input, final V value, final String type) { final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { final ICache<ExpressionCacheKey,Object> cache = cacheManager.getExpressionCache(); if (cache != null) { cache.put(new ExpressionCacheKey(type,input), value); } } }
throws Exception { final ICacheManager cacheManager = configuration.getCacheManager(); final ICache<ExpressionCacheKey, Object> expressionCache = (cacheManager == null? null : cacheManager.getExpressionCache());
final ICacheManager cacheManager = configuration.getCacheManager(); final Set<ITemplateResolver> templateResolvers = configuration.getTemplateResolvers(); final Set<IMessageResolver> messageResolvers = configuration.getMessageResolvers();
/** * <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); }
private static ComputedSpelExpression getExpression(final IEngineConfiguration configuration, final String spelExpression) { ComputedSpelExpression exp = null; ICache<ExpressionCacheKey, Object> cache = null; final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { cache = cacheManager.getExpressionCache(); if (cache != null) { exp = (ComputedSpelExpression) cache.get(new ExpressionCacheKey(EXPRESSION_CACHE_TYPE_SPEL,spelExpression)); } } if (exp == null) { final SpelExpression spelExpressionObject = (SpelExpression) PARSER.parseExpression(spelExpression); final boolean mightNeedExpressionObjects = StandardExpressionUtils.mightNeedExpressionObjects(spelExpression); exp = new ComputedSpelExpression(spelExpressionObject, mightNeedExpressionObjects); if (cache != null && null != exp) { cache.put(new ExpressionCacheKey(EXPRESSION_CACHE_TYPE_SPEL,spelExpression), exp); } } return exp; }
private static ComputedSpelExpression getExpression(final IEngineConfiguration configuration, final String spelExpression) { ComputedSpelExpression exp = null; ICache<ExpressionCacheKey, Object> cache = null; final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { cache = cacheManager.getExpressionCache(); if (cache != null) { exp = (ComputedSpelExpression) cache.get(new ExpressionCacheKey(EXPRESSION_CACHE_TYPE_SPEL,spelExpression)); } } if (exp == null) { final SpelExpression spelExpressionObject = (SpelExpression) PARSER.parseExpression(spelExpression); final boolean mightNeedExpressionObjects = StandardExpressionUtils.mightNeedExpressionObjects(spelExpression); exp = new ComputedSpelExpression(spelExpressionObject, mightNeedExpressionObjects); if (cache != null && null != exp) { cache.put(new ExpressionCacheKey(EXPRESSION_CACHE_TYPE_SPEL,spelExpression), exp); } } return exp; }
private static ComputedSpelExpression getExpression(final IEngineConfiguration configuration, final String spelExpression) { ComputedSpelExpression exp = null; ICache<ExpressionCacheKey, Object> cache = null; final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { cache = cacheManager.getExpressionCache(); if (cache != null) { exp = (ComputedSpelExpression) cache.get(new ExpressionCacheKey(EXPRESSION_CACHE_TYPE_SPEL,spelExpression)); } } if (exp == null) { // SELECT THE ADEQUATE SpEL EXPRESSION PARSER depending on whether SpEL compilation is enabled final SpelExpressionParser spelExpressionParser = PARSER_WITH_COMPILED_SPEL != null && SpringStandardExpressions.isSpringELCompilerEnabled(configuration)? PARSER_WITH_COMPILED_SPEL : PARSER_WITHOUT_COMPILED_SPEL; final SpelExpression spelExpressionObject = (SpelExpression) spelExpressionParser.parseExpression(spelExpression); final boolean mightNeedExpressionObjects = StandardExpressionUtils.mightNeedExpressionObjects(spelExpression); exp = new ComputedSpelExpression(spelExpressionObject, mightNeedExpressionObjects); if (cache != null && null != exp) { cache.put(new ExpressionCacheKey(EXPRESSION_CACHE_TYPE_SPEL,spelExpression), exp); } } return exp; }
private static ComputedSpelExpression getExpression(final IEngineConfiguration configuration, final String spelExpression) { ComputedSpelExpression exp = null; ICache<ExpressionCacheKey, Object> cache = null; final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { cache = cacheManager.getExpressionCache(); if (cache != null) { exp = (ComputedSpelExpression) cache.get(new ExpressionCacheKey(EXPRESSION_CACHE_TYPE_SPEL,spelExpression)); } } if (exp == null) { // SELECT THE ADEQUATE SpEL EXPRESSION PARSER depending on whether SpEL compilation is enabled final SpelExpressionParser spelExpressionParser = PARSER_WITH_COMPILED_SPEL != null && SpringStandardExpressions.isSpringELCompilerEnabled(configuration)? PARSER_WITH_COMPILED_SPEL : PARSER_WITHOUT_COMPILED_SPEL; final SpelExpression spelExpressionObject = (SpelExpression) spelExpressionParser.parseExpression(spelExpression); final boolean mightNeedExpressionObjects = StandardExpressionUtils.mightNeedExpressionObjects(spelExpression); exp = new ComputedSpelExpression(spelExpressionObject, mightNeedExpressionObjects); if (cache != null && null != exp) { cache.put(new ExpressionCacheKey(EXPRESSION_CACHE_TYPE_SPEL,spelExpression), exp); } } return exp; }
private static ComputedSpelExpression getExpression(final IEngineConfiguration configuration, final String spelExpression) { ComputedSpelExpression exp = null; ICache<ExpressionCacheKey, Object> cache = null; final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { cache = cacheManager.getExpressionCache(); if (cache != null) { exp = (ComputedSpelExpression) cache.get(new ExpressionCacheKey(EXPRESSION_CACHE_TYPE_SPEL,spelExpression)); } } if (exp == null) { // SELECT THE ADEQUATE SpEL EXPRESSION PARSER depending on whether SpEL compilation is enabled final SpelExpressionParser spelExpressionParser = PARSER_WITH_COMPILED_SPEL != null && SpringStandardExpressions.isSpringELCompilerEnabled(configuration)? PARSER_WITH_COMPILED_SPEL : PARSER_WITHOUT_COMPILED_SPEL; final SpelExpression spelExpressionObject = (SpelExpression) spelExpressionParser.parseExpression(spelExpression); final boolean mightNeedExpressionObjects = StandardExpressionUtils.mightNeedExpressionObjects(spelExpression); exp = new ComputedSpelExpression(spelExpressionObject, mightNeedExpressionObjects); if (cache != null && null != exp) { cache.put(new ExpressionCacheKey(EXPRESSION_CACHE_TYPE_SPEL,spelExpression), exp); } } return exp; }