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; }
/** * <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()); } }
/** * Clears the cache when a template have been updated. */ public synchronized void updatedTemplate() { // Synchronized because of the access to engine. engine.getCacheManager().clearAllCaches(); }
messagesCache = cacheManager.getMessageCache(); if (messagesCache != null) { properties = messagesCache.get(cacheKey);
/** * Deletes the given template. The service is unregistered, and the cache is cleared. * * @param template the template */ public void deleteTemplate(ThymeLeafTemplateImplementation template) { // 1 - unregister the service try { ServiceRegistration reg = registrations.remove(template); if (reg != null) { reg.unregister(); } } catch (Exception e) { //NOSONAR // May already have been unregistered during the shutdown sequence. } // 2 - as templates can have dependencies, and expressions kept in memory, we clear all caches. // Despite this may really impact performance, it should not happen too often on real systems. synchronized (this) { engine.getCacheManager().clearAllCaches(); } OgnlRuntime.clearCache(); // Unfortunately, the previous method do not clear the get and set method cache // (ognl.OgnlRuntime.cacheGetMethod and ognl.OgnlRuntime.cacheSetMethod) clearMethodCaches(); }
messagesCache = cacheManager.getMessageCache(); if (messagesCache != null) { properties = messagesCache.get(cacheKey);
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); } } }
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)); } } }
final ICache<ExpressionCacheKey, Object> expressionCache = (cacheManager == null? null : cacheManager.getExpressionCache());
private static <V> void putIntoCache(final Configuration configuration, final String input, final V value, final String prefix) { final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { final ICache<String,Object> cache = cacheManager.getExpressionCache(); if (cache != null) { cache.put(prefix + input, value); } } }
private static Object getFromCache(final Configuration configuration, final String input, final String prefix) { final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { final ICache<String,Object> cache = cacheManager.getExpressionCache(); if (cache != null) { return cache.get(prefix + input); } } return null; }
public final List<Node> extractFragment(final Configuration configuration, final List<Node> nodes) { DOMSelector selector = null; ICache<String,Object> expressionCache = null; final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { expressionCache = cacheManager.getExpressionCache(); if (expressionCache != null) { selector = (DOMSelector) expressionCache.get(this.domSelectorCacheKey); } } if (selector == null) { selector = new DOMSelector(this.selectorExpression); if (expressionCache != null) { expressionCache.put(this.domSelectorCacheKey, selector); } } final List<Node> extraction = selector.select(nodes, this.referenceChecker); if (extraction == null || extraction.size() == 0) { return null; } return extraction; }
public final List<Node> extractFragment(final Configuration configuration, final List<Node> nodes) { DOMSelector selector = null; ICache<String,Object> expressionCache = null; final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { expressionCache = cacheManager.getExpressionCache(); if (expressionCache != null) { selector = (DOMSelector) expressionCache.get(this.domSelectorCacheKey); } } if (selector == null) { selector = new DOMSelector(this.selectorExpression); if (expressionCache != null) { expressionCache.put(this.domSelectorCacheKey, selector); } } final DOMSelector.INodeReferenceChecker referenceChecker = getReferenceChecker(configuration); final List<Node> extraction = selector.select(nodes, referenceChecker); if (extraction == null || extraction.size() == 0) { return null; } return extraction; }
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; }
final ICacheManager cacheManager = configuration.getCacheManager(); if (cacheManager != null) { cache = cacheManager.getExpressionCache(); if (cache != null) { expressionTree = cache.get(OGNL_CACHE_PREFIX + expression);
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; }