/** * <p> * Sets the Cache Manager to be used. If set to null, no caches will be used * throughout the engine. * </p> * <p> * By default, an instance of {@link org.thymeleaf.cache.StandardCacheManager} * is set. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param cacheManager the cache manager to be set. * */ public void setCacheManager(final ICacheManager cacheManager) { // Can be set to null (= no caches at all) checkNotInitialized(); this.cacheManager = cacheManager; }
/** * <p> * Removes all the currently configured dialects. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> */ public void clearDialects() { checkNotInitialized(); this.dialectConfigurations.clear(); }
/** * <p> * Adds a new template resolver to the current set. * </p> * * @param templateResolver the new template resolver. */ public void addTemplateResolver(final ITemplateResolver templateResolver) { Validate.notNull(templateResolver, "Template Resolver cannot be null"); checkNotInitialized(); this.templateResolvers.add(templateResolver); }
/** * <p> * Sets a single template resolver for this template engine. * </p> * <p> * Calling this method is equivalent to calling {@link #setTemplateResolvers(Set)} * passing a Set with only one template resolver. * </p> * * @param templateResolver the template resolver to be set. */ public void setTemplateResolver(final ITemplateResolver templateResolver) { Validate.notNull(templateResolver, "Template Resolver cannot be null"); checkNotInitialized(); this.templateResolvers.clear(); this.templateResolvers.add(templateResolver); }
/** * <p> * Adds a message resolver to the set of message resolvers to be used * by the template engine. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param messageResolver the new message resolver to be added. */ public void addMessageResolver(final IMessageResolver messageResolver) { Validate.notNull(messageResolver, "Message Resolver cannot be null"); checkNotInitialized(); this.messageResolvers.add(messageResolver); }
/** * <p> * Adds a link builder to the set of link builders to be used * by the template engine. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param linkBuilder the new link builder to be added. */ public void addLinkBuilder(final ILinkBuilder linkBuilder) { Validate.notNull(linkBuilder, "Link Builder cannot be null"); checkNotInitialized(); this.linkBuilders.add(linkBuilder); }
/** * <p> * Sets the Engine Context Factory (implementation of {@link IEngineContextFactory}) to be * used for template processing. * </p> * <p> * By default, an instance of {@link org.thymeleaf.context.StandardEngineContextFactory} * is set. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param engineContextFactory the engine context factory to be used. * */ public void setEngineContextFactory(final IEngineContextFactory engineContextFactory) { Validate.notNull(engineContextFactory, "Engine Context Factory cannot be set to null"); checkNotInitialized(); this.engineContextFactory = engineContextFactory; }
/** * <p> * Sets a single message resolver for this template engine. * </p> * <p> * Calling this method is equivalent to calling {@link #setMessageResolvers(Set)} * passing a Set with only one message resolver. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param messageResolver the message resolver to be set. */ public void setMessageResolver(final IMessageResolver messageResolver) { Validate.notNull(messageResolver, "Message Resolver cannot be null"); checkNotInitialized(); this.messageResolvers.clear(); this.messageResolvers.add(messageResolver); }
/** * <p> * Sets a single link builder for this template engine. * </p> * <p> * Calling this method is equivalent to calling {@link #setLinkBuilders(Set)} * passing a Set with only one link builder. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param linkBuilder the message resolver to be set. */ public void setLinkBuilder(final ILinkBuilder linkBuilder) { Validate.notNull(linkBuilder, "Link Builder cannot be null"); checkNotInitialized(); this.linkBuilders.clear(); this.linkBuilders.add(linkBuilder); }
/** * <p> * Sets the Decoupled Template Logic Resolver (implementation of * {@link IDecoupledTemplateLogicResolver}) to be used for templates that require so. * </p> * <p> * By default, an instance of {@link org.thymeleaf.templateparser.markup.decoupled.StandardDecoupledTemplateLogicResolver} * is set. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param decoupledTemplateLogicResolver the engine context factory to be used. * */ public void setDecoupledTemplateLogicResolver(final IDecoupledTemplateLogicResolver decoupledTemplateLogicResolver) { Validate.notNull(decoupledTemplateLogicResolver, "Decoupled Template Logic Resolver cannot be set to null"); checkNotInitialized(); this.decoupledTemplateLogicResolver = decoupledTemplateLogicResolver; }
/** * <p> * Sets the entire set of template resolvers. * </p> * * @param templateResolvers the new template resolvers. */ public void setTemplateResolvers(final Set<ITemplateResolver> templateResolvers) { Validate.notNull(templateResolvers, "Template Resolver set cannot be null"); checkNotInitialized(); this.templateResolvers.clear(); for (final ITemplateResolver templateResolver : templateResolvers) { addTemplateResolver(templateResolver); } }
/** * <p> * Sets a new set of dialects for this template engine, referenced * by the prefixes they will be using. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param dialects the new map of {@link IDialect} objects to be used, referenced * by their prefixes. */ public void setDialectsByPrefix(final Map<String,IDialect> dialects) { Validate.notNull(dialects, "Dialect map cannot be null"); checkNotInitialized(); this.dialectConfigurations.clear(); for (final Map.Entry<String,IDialect> dialectEntry : dialects.entrySet()) { addDialect(dialectEntry.getKey(), dialectEntry.getValue()); } }
/** * <p> * Sets a new unique dialect for this template engine. * </p> * <p> * This operation is equivalent to removing all the currently configured dialects and then * adding this one. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param dialect the new unique {@link IDialect} to be used. */ public void setDialect(final IDialect dialect) { Validate.notNull(dialect, "Dialect cannot be null"); checkNotInitialized(); this.dialectConfigurations.clear(); this.dialectConfigurations.add(new DialectConfiguration(dialect)); }
/** * <p> * Sets a new set of dialects for this template engine, all of them using * their default prefixes. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param dialects the new set of {@link IDialect} objects to be used. */ public void setDialects(final Set<IDialect> dialects) { Validate.notNull(dialects, "Dialect set cannot be null"); checkNotInitialized(); this.dialectConfigurations.clear(); for (final IDialect dialect : dialects) { addDialect(dialect); } }
/** * <p> * Adds a new dialect for this template engine, using the dialect's specified * default dialect. * </p> * <p> * This dialect will be added to the set of currently configured ones. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param dialect the new {@link IDialect} to be added to the existing ones. */ public void addDialect(final IDialect dialect) { Validate.notNull(dialect, "Dialect cannot be null"); checkNotInitialized(); this.dialectConfigurations.add(new DialectConfiguration(dialect)); }
/** * <p> * Adds a new dialect for this template engine, using the specified prefix. * </p> * <p> * This dialect will be added to the set of currently configured ones. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param prefix the prefix that will be used for this dialect * @param dialect the new {@link IDialect} to be added to the existing ones. */ public void addDialect(final String prefix, final IDialect dialect) { Validate.notNull(dialect, "Dialect cannot be null"); checkNotInitialized(); this.dialectConfigurations.add(new DialectConfiguration(prefix, dialect)); }
/** * <p> * Sets the message resolvers to be used by this template engine. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param messageResolvers the Set of template resolvers. */ public void setMessageResolvers(final Set<IMessageResolver> messageResolvers) { Validate.notNull(messageResolvers, "Message Resolver set cannot be null"); checkNotInitialized(); this.messageResolvers.clear(); for (final IMessageResolver messageResolver : messageResolvers) { addMessageResolver(messageResolver); } }
/** * <p> * Sets the link builders to be used by this template engine. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param linkBuilders the Set of link builders. */ public void setLinkBuilders(final Set<ILinkBuilder> linkBuilders) { Validate.notNull(linkBuilders, "Link Builder set cannot be null"); checkNotInitialized(); this.linkBuilders.clear(); for (final ILinkBuilder linkBuilder : linkBuilders) { addLinkBuilder(linkBuilder); } }
/** * <p> * Sets an additional set of dialects for this template engine, all of them using * their default prefixes. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param additionalDialects the new set of {@link IDialect} objects to be used. * * @since 2.0.9 * */ public void setAdditionalDialects(final Set<IDialect> additionalDialects) { Validate.notNull(additionalDialects, "Dialect set cannot be null"); checkNotInitialized(); for (final IDialect dialect : additionalDialects) { addDialect(dialect); } }