codeconsole opened a new pull request, #15939:
URL: https://github.com/apache/grails-core/pull/15939

   ## Summary
   
   Introduces a statically-compilable, method-based `doWithSpring(BeanBuilder)` 
lifecycle hook alongside the existing closure-returning `doWithSpring()`. This 
is the plugin analog of the method-based TagLib syntax added in #15465, applied 
to the one plugin lifecycle hook that was still closure-based.
   
   Plugins (and any `GrailsApplicationLifeCycle`) can now register beans by 
overriding `doWithSpring(BeanBuilder)` and calling the builder directly, 
instead of returning a closure whose delegate the container wires up at runtime:
   
   ```groovy
   class I18nGrailsPlugin extends Plugin {
   
       def version = "0.1"
   
       @Override
       void doWithSpring(BeanBuilder beans) {
           beans.messageSource(ReloadableResourceBundleMessageSource) {
               basename = "WEB-INF/grails-app/i18n/messages"
           }
           beans.localeResolver(CookieLocaleResolver)
       }
   }
   ```
   
   ## Backwards compatibility
   
   Fully preserved. The new hook is added as a `default` no-op on 
`GrailsApplicationLifeCycle`, so existing implementors are unaffected, and 
overridden as a no-op on the `Plugin` base class and 
`GrailsApplicationLifeCycleAdapter`.
   
   Both dispatch sites — `DefaultGrailsPlugin` (plugin descriptors) and 
`GrailsApplicationPostProcessor` (the application lifecycle bean) — invoke 
**both** hooks, so a plugin may override `doWithSpring()`, 
`doWithSpring(BeanBuilder)`, or both. The tiers are:
   
   1. `doWithSpring(BeanBuilder)` method (new, on `Plugin`)
   2. `Closure doWithSpring()` method (existing, on `Plugin`)
   3. `def doWithSpring = { }` closure property (legacy, on non-`Plugin` 
descriptors)
   
   Tiers 2 and 3 remain unchanged and fully supported.
   
   ## Tests
   
   Adds `PluginDoWithSpringMethodSpec` covering:
   - `Plugin` / adapter / interface-default no-ops
   - direct method-form bean registration against a `BeanBuilder`
   - `DefaultGrailsPlugin` dispatch for the method form, for both hooks 
together, and a regression test for the legacy closure form
   
   `./gradlew clean aggregateViolations` reports no Checkstyle / CodeNarc / PMD 
/ SpotBugs violations.
   
   ## Docs
   
   Documents the new hook in the plugin runtime-configuration guide 
(`grails-doc`).


-- 
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