@groovy.transform.CompileStatic @org.springframework.boot.autoconfigure.AutoConfiguration @org.springframework.boot.autoconfigure.AutoConfigureAfter(name: org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfiguration) @org.springframework.boot.autoconfigure.AutoConfigureBefore(name: org.sitemesh.autoconfigure.SiteMeshViewResolverAutoConfiguration) @org.springframework.boot.autoconfigure.condition.ConditionalOnClass(value: SiteMeshViewResolverBeanPostProcessor) @org.springframework.boot.autoconfigure.condition.ConditionalOnProperty(name: sitemesh.integration, havingValue: view-resolver, matchIfMissing: true) class Sitemesh3GrailsPlugin extends Plugin
Provides GSP layout decoration through SiteMesh 3's filter-less,
view-resolver-based integration. It is a drop-in replacement for the
grails-layout module; the two are mutually exclusive. Because this module
arrives transitively through grails-dependencies-starter-web, an
application that declares grails-layout can end up with both on the
classpath — that state is tolerated for migration compatibility (SiteMesh 2
keeps decorating and this module stands down) but warned about by
Sitemesh3EnvironmentPostProcessor, and support for it may be removed.
Default configuration properties are contributed by
Sitemesh3EnvironmentPostProcessor (registered in
META-INF/spring.factories). The view-resolver decoration beans are
declared in this class's beans block, which @GrailsBeans
compiles into the generated Sitemesh3AutoConfiguration class — the
Spring annotations above this class gate and order that auto-configuration,
not the plugin itself, and move onto it at compile time.
The decoration beans register ahead of the upstream auto-configuration:
the Sitemesh3ViewResolverDefinitionPostProcessor (which rewrites the
jspViewResolver definition into the decorating
GrailsSiteMeshViewResolver), the
GrailsSiteMeshViewResolverBeanPostProcessor, the
CaptureAwareContentProcessor (contentProcessor) and the
Sitemesh3LayoutFinder (decoratorSelector).
The definition-level rewrite is what applies decoration: because it acts
on the bean definition, the decorating resolver is what gets instantiated no
matter how early a consumer forces the lazy jspViewResolver into
existence (see Sitemesh3ViewResolverDefinitionPostProcessor, the
Grails implementation of upstream's bean-definition wrap mode). The
bean post-processor is the fallback tier: it decorates a
jspViewResolver registered as an instance rather than a definition.
Upstream's post-processor never re-wraps a resolver that is already a
SiteMeshViewResolver, so the two tiers cannot double-decorate.
Upstream's SiteMeshViewResolverAutoConfiguration declares its
beans with @ConditionalOnMissingBean guards. By scheduling the
generated configuration first (via AutoConfigureBefore) the Grails
implementations are registered before those guards are evaluated, so the
upstream defaults back off cleanly rather than being registered and then
overridden after the fact. The two post-processors here cover all of
upstream's registrations by type: the definition post-processor preempts the
bean-definition mode bean, and the bean post-processor preempts both
the wrap-all and bean-instance mode beans.
The contentProcessor and decoratorSelector beans drive view
decoration, which is only meaningful when Spring MVC is resolving views, so
they are gated on a DispatcherServlet being present. This keeps them
out of the lightweight unit-test contexts built by grails-testing-support,
which have no dispatcher servlet — and because the definition post-processor
only rewrites jspViewResolver when both of those beans are registered,
it keeps decoration out of such contexts too.
| Type | Name and description |
|---|---|
java.lang.Object |
author |
java.lang.Object |
authorEmail |
java.lang.Object |
beans |
java.lang.Object |
description |
java.lang.Object |
grailsVersion |
java.lang.Object |
license |
java.lang.Object |
loadBefore |
java.lang.Object |
profiles |
java.lang.Object |
providedArtefacts |
java.lang.Object |
title |
| Properties inherited from class | Properties |
|---|---|
class Plugin |
applicationContext, artefacts, environment, grailsApplication, plugin, pluginManager |
| Constructor and description |
|---|
Sitemesh3GrailsPlugin() |
| Methods inherited from class | Name |
|---|---|
class Plugin |
beanRegistrar, beans, doWithApplicationContext, doWithDynamicMethods, doWithSpring, doWithSpring, getApplicationContext, getConfig, getManager, onChange, onConfigChange, onShutdown, onStartup, setApplicationContext |