From e736c6a9e2a061e8c73b643da0ebd6dca9e82642 Mon Sep 17 00:00:00 2001 From: Scott Murphy Date: Wed, 25 Oct 2023 11:04:31 -0700 Subject: [PATCH] Allow custom tag rule bundles using Spring Boot autoconfiguration. Rename bundles -> tagRuleBundles --- .../springboot/src/main/resources/config/application.yml | 2 +- .../sitemesh/autoconfigure/SiteMeshAutoConfiguration.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/springboot/src/main/resources/config/application.yml b/examples/springboot/src/main/resources/config/application.yml index d25f8b4..492350a 100644 --- a/examples/springboot/src/main/resources/config/application.yml +++ b/examples/springboot/src/main/resources/config/application.yml @@ -8,7 +8,7 @@ spring: sitemesh: decorator: metaTag: decorator -# bundles: sm2 +# tagRuleBundles: org.sitemesh.content.tagrules.html.Sm2TagRuleBundle exclusions: /assets/* mappings: - path: /* diff --git a/spring-boot-starter-sitemesh/src/main/java/org/sitemesh/autoconfigure/SiteMeshAutoConfiguration.java b/spring-boot-starter-sitemesh/src/main/java/org/sitemesh/autoconfigure/SiteMeshAutoConfiguration.java index 227b2c7..de30701 100644 --- a/spring-boot-starter-sitemesh/src/main/java/org/sitemesh/autoconfigure/SiteMeshAutoConfiguration.java +++ b/spring-boot-starter-sitemesh/src/main/java/org/sitemesh/autoconfigure/SiteMeshAutoConfiguration.java @@ -20,6 +20,7 @@ import org.sitemesh.config.ConfigurableSiteMeshFilter; import org.sitemesh.config.MetaTagBasedDecoratorSelector; import org.sitemesh.config.RequestAttributeDecoratorSelector; +import org.sitemesh.content.tagrules.TagRuleBundle; import org.sitemesh.content.tagrules.html.Sm2TagRuleBundle; import org.sitemesh.webapp.WebAppContext; import org.springframework.beans.factory.annotation.Value; @@ -52,7 +53,7 @@ public void setMappings(List> mappings) { private String prefix; @Value("${sitemesh.decorator.metaTag:decorator}") private String metaTagName; - @Value("${sitemesh.decorator.bundles:}") + @Value("${sitemesh.decorator.tagRuleBundles:}") private List bundles; @Value("${sitemesh.decorator.attribute:}") private String attribute; @@ -87,9 +88,7 @@ protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) { } } for (String bundle : bundles) { - if (bundle.trim().equals("sm2")) { - builder.addTagRuleBundle(new Sm2TagRuleBundle()); - } + builder.addTagRuleBundle((TagRuleBundle) getObjectFactory().create(bundle)); } builder.setIncludeErrorPages(includeErrorPages); }