codeconsole commented on code in PR #15934: URL: https://github.com/apache/grails-core/pull/15934#discussion_r3546843127
########## grails-core/src/main/groovy/grails/boot/config/ApplicationClassScanner.groovy: ########## @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package grails.boot.config + +import groovy.transform.CompileStatic + +import grails.boot.config.tools.ClassPathScanner +import org.grails.compiler.injection.AbstractGrailsArtefactTransformer + +/** + * Discovers the classes that constitute a Grails application by scanning the classpath relative + * to an application class. This is the single implementation of the default scanning performed by + * {@link GrailsAutoConfiguration#classes()}, also used by + * {@link GrailsEarlyPluginRegistrationPostProcessor} to perform artefact discovery before Spring + * Boot auto-configuration is processed. + * + * @since 8.0 + */ +@CompileStatic +final class ApplicationClassScanner { Review Comment: Since `BeanRegistrar` is a functional interface, only a coerced closure is needed — no separate class and no real boilerplate. I've reworked the docs to lead with that form (see the reply on `beanRegistrar()` in `Plugin` above): ```groovy BeanRegistrar beanRegistrar() { { BeanRegistry registry, Environment env -> registry.registerBean('myService', MyServiceImpl) } as BeanRegistrar } ``` Returning a single `BeanRegistrar` is not a limitation — a registrar can register any number of beans, and returning one mirrors `doWithSpring` returning one closure. Kept the return type because it's Spring's native abstraction and a reusable first-class object; happy to switch to passing the `BeanRegistry` in if you'd prefer. -- 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]
