Tabnine Logo
ICacheManager
Code IndexAdd Tabnine to your IDE (free)

How to use
ICacheManager
in
org.thymeleaf.cache

Best Java code snippets using org.thymeleaf.cache.ICacheManager (Showing top 20 results out of 315)

origin: thymeleaf/thymeleaf

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;
}
origin: thymeleaf/thymeleaf

/**
 * <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);
}

origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf

/**
 * <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());
  }
}

origin: org.wisdom-framework/thymeleaf-template-engine

/**
 * Clears the cache when a template have been updated.
 */
public synchronized void updatedTemplate() {
  // Synchronized because of the access to engine.
  engine.getCacheManager().clearAllCaches();
}
origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf

messagesCache = cacheManager.getMessageCache();
if (messagesCache != null) {
  properties = messagesCache.get(cacheKey);
origin: org.wisdom-framework/thymeleaf-template-engine

/**
 * 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();
}
origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf

messagesCache = cacheManager.getMessageCache();
if (messagesCache != null) {
  properties = messagesCache.get(cacheKey);
origin: thymeleaf/thymeleaf

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);
    }
  }
}
origin: thymeleaf/thymeleaf

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));
    }
  }
}
origin: thymeleaf/thymeleaf

final ICache<ExpressionCacheKey, Object> expressionCache = (cacheManager == null? null : cacheManager.getExpressionCache());
origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf

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);
    }
  }
}

origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf

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;
}
origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf

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;
}
origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf

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;
}
origin: thymeleaf/thymeleaf-spring

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;
  
}
origin: org.thymeleaf/thymeleaf-spring3

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;
  
}
origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf

final ICacheManager cacheManager = configuration.getCacheManager();
if (cacheManager != null) {
  cache = cacheManager.getExpressionCache();
  if (cache != null) {
    expressionTree = cache.get(OGNL_CACHE_PREFIX + expression);
origin: thymeleaf/thymeleaf-spring

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;
  
}
origin: thymeleaf/thymeleaf-spring

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;
  
}
origin: org.thymeleaf/thymeleaf-spring4

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;
  
}
org.thymeleaf.cacheICacheManager

Javadoc

Common interface for all cache manager implementations.

This class is in charge of providing the corresponding cache objects to the template engine. Every call to each of the getXCache()methods must always return the XCache object (i.e. only one cache object should be ever created for each type of cache, and returned every time it is requested).

These caches are predefined:

  • A template cache, used for storing parsed templates referenced by their template name and other resolution info (see TemplateCacheKey).
  • An expression cache, used for storing expression evaluation artifacts (for example, org.thymeleaf.standard.expression.Expression parsed trees, OGNL/Spring EL parsed trees, etc). Given that this cache can usually store objects of different classes (referenced by their String representation), prefixes are normally applied to the String keys in order to being able to differentiate these classes when retrieving cache entries.

Only the caches listed above are needed by the template engine when the standard dialects are being used, but users might want to define new dialects and use new types of caches, which can be provided by the cache manager using the #getSpecificCache(String)method.

Any of these methods could return null, in which case the engine will consider that no cache must be applied for that specific function.

Note a class with this name existed since 2.0.0, but it was completely reimplemented in Thymeleaf 3.0

Most used methods

  • getExpressionCache
    Returns the cache of expression evaluation artifacts. This cache is meant to store artifacts of d
  • getTemplateCache
    Returns the cache of parsed templates. Keys are the template names, as specified at the org.thymele
  • clearAllCaches
    Clears all the caches managed by this cache manager instance. This method is mainly intended for
  • getFragmentCache
    Returns the cache of template code fragments. These fragments are pieces of template code that need
  • getMessageCache
    Returns the cache used for externalized/internationalized messages. This cache uses as keys the t

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • onRequestPermissionsResult (Fragment)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Path (java.nio.file)
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Option (scala)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now