private static ExpressionCacheKey computeMethodCacheKey(final Class<?> targetClass, final String propertyName) { return new ExpressionCacheKey(EXPRESSION_CACHE_TYPE_OGNL_SHORTCUT, targetClass.getName(), propertyName); }
public ExpressionCacheKey(final String type, final String expression0, final String expression1) { super(); Validate.notNull(type, "Type cannot be null"); Validate.notNull(expression0, "Expression cannot be null"); this.type = type; this.expression0 = expression0; this.expression1 = expression1; // This being a cache key, its equals and hashCode methods will potentially execute many // times, so this could help performance this.h = computeHashCode(); }
private Object prefix(final K key) { final String testName = TestExecutor.getThreadTestName(); if (key instanceof String) { return testName + "_" + key; } if (key instanceof TemplateCacheKey) { final TemplateCacheKey cacheKey = (TemplateCacheKey)key; return new TemplateCacheKey( cacheKey.getOwnerTemplate(), testName + "_" + cacheKey.getTemplate(), cacheKey.getTemplateSelectors(), cacheKey.getLineOffset(), cacheKey.getColOffset(), cacheKey.getTemplateMode(), cacheKey.getTemplateResolutionAttributes()); } if (key instanceof ExpressionCacheKey) { final ExpressionCacheKey cacheKey = (ExpressionCacheKey)key; return new ExpressionCacheKey(testName + "_" + cacheKey.getType(), cacheKey.getExpression0(), cacheKey.getExpression1()); } return key; }
private Object prefix(final K key) { final String testName = TestExecutor.getThreadTestName(); if (key instanceof String) { return testName + "_" + key; } if (key instanceof TemplateCacheKey) { final TemplateCacheKey cacheKey = (TemplateCacheKey)key; return new TemplateCacheKey( cacheKey.getOwnerTemplate(), testName + "_" + cacheKey.getTemplate(), cacheKey.getTemplateSelectors(), cacheKey.getLineOffset(), cacheKey.getColOffset(), cacheKey.getTemplateMode(), cacheKey.getTemplateResolutionAttributes()); } if (key instanceof ExpressionCacheKey) { final ExpressionCacheKey cacheKey = (ExpressionCacheKey)key; return new ExpressionCacheKey(testName + "_" + cacheKey.getType(), cacheKey.getExpression0(), cacheKey.getExpression1()); } return key; }
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); } } }
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)); } } }
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; }