Repository navigation
Register the scaffolding view resolver without the bean DSL - #15966
Merged
jdaugherty merged 6 commits intoJul 11, 2026
Merged
Conversation
Move the jspViewResolver registration out of doWithSpring() into a ScaffoldingViewResolverDefinitionPostProcessor registered through beanRegistrar(). The post-processor runs at order -2 — before the SiteMesh 2 module's GrailsLayoutViewResolverPostProcessor (-1), which embeds the definition as its inner view resolver, and before the GSP plugin's GroovyPagesPostProcessor (0), which only contributes the plain GSP resolver when no definition exists — so the established resolver pipeline is preserved exactly. An existing jspViewResolver definition still wins, matching the old override semantics. The definition keeps the abstractViewResolver parent template rather than duplicating the GSP resolver defaults, and reads grails.scaffolding.enableNamespaceViewDefaults from the Spring Environment instead of the post-hoc Grails config. With no bean-builder closure left, the plugin descriptor is annotated @CompileStatic.
Pure Spring infrastructure with no Groovy idiom - Java matches the sibling Sitemesh3ViewResolverDefinitionPostProcessor, puts the class under checkstyle, and drops the awkward fully-qualified references that the grails.util.Environment / Spring Environment name clash forced in Groovy.
The declared BeanRegistrar return type already coerces the returned closure; the 'as BeanRegistrar' was redundant.
Hardcoding -2 would silently misorder the resolver pipeline if the GSP post-processor's order ever moved. grails-scaffolding already depends on the GSP plugin at runtime (loadAfter groovyPages, the abstractViewResolver parent bean), so declaring the compile dependency makes the coupling explicit and lets the constant be relative.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #15966 +/- ##
==================================================
+ Coverage 49.6092% 49.6359% +0.0267%
- Complexity 16955 16968 +13
==================================================
Files 1999 2000 +1
Lines 93791 93803 +12
Branches 16421 16424 +3
==================================================
+ Hits 46529 46560 +31
+ Misses 40090 40073 -17
+ Partials 7172 7170 -2
🚀 New features to boost your workflow:
|
codeconsole
requested review from
borinquenkid,
jamesfredley,
jdaugherty,
matrei and
sbglasius
July 10, 2026 22:33
jdaugherty
approved these changes
Jul 10, 2026
The ordering test asserted against a literal with the collaborators' orders recorded only in a comment, so renumbering GrailsLayoutViewResolverPostProcessor or GroovyPagesPostProcessor would break the pipeline while the test kept passing. It now asserts against the real constants, with grails-layout added as a test dependency. Also correct the stand-down comment: suppression applies to any existing definition, which is stricter than the old doWithSpring() registration that overwrote definitions from earlier-loading plugins.
This comment has been minimized.
This comment has been minimized.
codeconsole
added a commit
that referenced
this pull request
Jul 19, 2026
…trar() Migrates the in-tree framework plugins off the deprecated doWithSpring() bean DSL onto the BeanRegistrar API, following the pattern established by the SiteMesh 3 (#15964) and scaffolding (#15966) conversions. Descriptors are now statically compiled where the remaining hooks allow it. Converted with a straight registrar (config reads move to the Spring Environment, constructor/property refs become supplier lookups): async, cache, converters, datasource, dbmigration (hibernate5 + 7), domain-class, events, fields, gorm-graphql, layout, markup views, json views, rest-transforms, url-mappings. Per-artefact bean definitions (controllers, interceptors, services) and the redis pool beans need definition-level features the BeanRegistry API cannot express: autowire-by-name, arbitrary scopes, destroy methods and dynamic property values. Those registrations move to dedicated BeanDefinitionRegistryPostProcessors registered through beanRegistrar(). They run with highest priority so their definitions are visible to Spring Boot auto-configuration conditions, matching the visibility the doWithSpring() drain gave them, and an existing definition always wins so applications can still override the beans by name. Notable adjustments preserving behaviour: - The interceptor handler adapter becomes the named bean grailsInterceptorHandlerInterceptorAdapter (previously an inner bean) so its @Autowired members, including the Interceptor[] array, are still injected. - The converters error marshaller registerers reference the existing named marshaller beans instead of duplicating them as inner beans, keeping the ApplicationContextAware callback. - RedisConfigurationUtil gains a BeanDefinitionRegistry-based configureService variant; the bean-builder closure form remains for existing consumers. - GrailsUnitTest.defineBeans(plugin) now also applies a plugin's beanRegistrar(), so test setup that passes converted plugin instances (converters, json views) keeps working. - The chainedTransactionManagerPostProcessor registration drops the unrefreshed-context transactionManager guard; the post-processor itself only acts when a transactionManager definition and multiple chainable managers exist. The plugin and web-plugin profile skeletons and the plugin developer guide now show beanRegistrar() instead of the deprecated hook. Still on doWithSpring() (deferred): CoreGrailsPlugin and GroovyPagesGrailsPlugin (abstract parent bean templates and XML namespace handlers - the resolver-pipeline linchpin), the hibernate/mongodb/neo4j plugins (their datastore SpringInitializers return bean DSL closures) and the spring-security suite (config-driven DSL throughout).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates
ScaffoldingGrailsPluginoff the deprecateddoWithSpring()bean DSL (deprecated by #15934) and makes the descriptor fully@CompileStatic— the second in-tree plugin on the modern registration API, following the SiteMesh 3 module in #15964. The two PRs are independent; both preserve the same view-resolver pipeline.Why not a straight
beanRegistrar()portThe old DSL definition relied on
bean.parent = 'abstractViewResolver', and parent/abstract bean templates are one of the DSL constructsBeanRegistrydeliberately has no equivalent for (per #15934). Re-declaring the GSP resolver defaults inside scaffolding would duplicate them and drift.Instead,
beanRegistrar()registers a smallScaffoldingViewResolverDefinitionPostProcessorthat contributes thejspViewResolverdefinition — same class, sameabstractViewResolverparent, samelazyInit— at order -2, which slots into the established post-processor pipeline exactly where the DSL registration used to sit:ScaffoldingViewResolverDefinitionPostProcessor(this PR)GrailsLayoutViewResolverPostProcessor(grails-layout / SiteMesh 2)GroovyPagesPostProcessor(grails-gsp)Sitemesh3ViewResolverDefinitionPostProcessor(#15964)Behavioural parity notes:
jspViewResolverdefinition (applicationresources.groovy, another plugin) still wins, matching the old override semantics.grails.scaffolding.enableNamespaceViewDefaultsis now read from the SpringEnvironmentrather than the Grails config object — equivalent since the config is built from the environment.Environment.current/ development-mode metadata) is unchanged, just relocated.Testing
ScaffoldingViewResolverDefinitionPostProcessorSpeccovering registration (parent template, lazy-init, property values), the environment-drivenenableNamespaceViewDefaults, existing-definition precedence, and the pipeline ordering contract.:grails-scaffolding:testpasses.(view:)URL mappings both render with layouts applied through the SiteMesh 3 view-resolver chain, and the resolver arrives wrapped asGrailsSiteMeshViewResolver[inner=ScaffoldingViewResolver].