codeconsole commented on code in PR #15585:
URL: https://github.com/apache/grails-core/pull/15585#discussion_r3139956539


##########
grails-gsp/grails-sitemesh3/src/main/groovy/org/grails/plugins/sitemesh3/Sitemesh3GrailsPlugin.groovy:
##########
@@ -48,55 +55,73 @@ class Sitemesh3GrailsPlugin extends Plugin {
     def loadBefore = ['groovyPages']
 
     def providedArtefacts = [
-        RenderSitemeshTagLib,
+            RenderSitemeshTagLib,
+            Sitemesh3LayoutTagLib,
     ]
 
     static PropertySource getDefaultPropertySource(ConfigurableEnvironment 
configurableEnvironment, String defaultLayout) {
-
         Map props = [
-                'grails.gsp.view.layoutViewResolver': 'false',
                 'sitemesh.decorator.metaTag': 'layout',
                 'sitemesh.decorator.attribute': WebUtils.LAYOUT_ATTRIBUTE,
                 'sitemesh.decorator.prefix': '/layouts/',
-                'sitemesh.filter.order': GrailsFilters.SITEMESH_FILTER.order,
-                'sitemesh.decorator.tagRuleBundles': 
['org.sitemesh.content.tagrules.html.Sm2TagRuleBundle']
         ]
         if (defaultLayout) {
             props['sitemesh.decorator.default'] = defaultLayout
         }
-        // if property already exists, don't override
         props.clone().each {
             if (configurableEnvironment.getProperty(it.key)) {
                 props.remove(it.key)
             }
         }
-        return new MapPropertySource('defaultSitemesh3Properties', props)
+        new MapPropertySource('defaultSitemesh3Properties', props)
     }
 
     Closure doWithSpring() {
         { ->
             ConfigurableEnvironment configurableEnvironment = 
grailsApplication.mainContext.environment as ConfigurableEnvironment
             def propertySources = configurableEnvironment.getPropertySources()
-            // https://grails.apache.org/docs/latest/guide/single.html#layouts
-            // Default view should be application, but it is inefficient to 
add a rule for a page that may not exist.
             String defaultLayout = 
grailsApplication.getConfig().getProperty('grails.sitemesh.default.layout')
             
propertySources.addFirst(getDefaultPropertySource(configurableEnvironment, 
defaultLayout))
-            propertySources.addFirst(new 
MapPropertySource('requiredSitemesh3Properties', [
-                    
(GroovyPageParser.CONFIG_PROPERTY_GSP_GRAILS_LAYOUT_PREPROCESS): 'false'
-            ]))
             (grailsApplication as DefaultGrailsApplication).config = new 
PropertySourcesConfig(propertySources)
 
-            grailsLayoutHandlerMapping(GrailsLayoutHandlerMapping)
+            Config config = grailsApplication.getConfig()
+            boolean developmentMode = 
Metadata.getCurrent().isDevelopmentEnvironmentAvailable()
+            Environment env = Environment.current
+            boolean enableReload = env.isReloadEnabled() ||
+                    config.getProperty('grails.gsp.enable.reload', Boolean, 
false) ||
+                    (developmentMode && env == Environment.DEVELOPMENT)
+            String resolvedDefaultLayout = 
config.getProperty('grails.sitemesh.default.layout') ?:
+                    config.getProperty('sitemesh.decorator.default')
+
+            // Bean names match the @ConditionalOnMissingBean(name = 
"contentProcessor"/"decoratorSelector")
+            // guards on upstream's SiteMeshViewResolverAutoConfiguration, so
+            // our implementations replace upstream's defaults.
+            contentProcessor(CaptureAwareContentProcessor)
+
+            decoratorSelector(Sitemesh3LayoutFinder, ref('groovyPageLocator')) 
{
+                gspReloadEnabled = enableReload
+                defaultDecoratorName = resolvedDefaultLayout ?: null
+            }
+
+            // Replace the filter registration from
+            // org.sitemesh.autoconfigure.SiteMeshAutoConfiguration with a 
no-op
+            // filter bean under the same name. SiteMeshAutoConfiguration is
+            // @ConditionalOnMissingBean(name = "sitemesh") so registering this
+            // bean disables the upstream filter-based integration entirely.
+            // Decoration is done by the Spring MVC view resolver chain.
+            sitemesh(FilterRegistrationBean) { bean ->

Review Comment:
   Added a comment explaining it satisfies SiteMeshAutoConfiguration's 
@ConditionalOnMissingBean(name = "sitemesh") guard and is intentionally never 
invoked.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to