jdaugherty commented on code in PR #14876:
URL: https://github.com/apache/grails-core/pull/14876#discussion_r2187457471
##########
grails-gsp/plugin/src/main/groovy/org/grails/plugins/web/GroovyPagesGrailsPlugin.groovy:
##########
@@ -97,180 +97,180 @@ class GroovyPagesGrailsPlugin extends Plugin {
/**
* Configures the various Spring beans required by GSP
*/
- Closure doWithSpring() {{->
- def application = grailsApplication
- Config config = application.config
- boolean developmentMode = isDevelopmentMode()
- Environment env = Environment.current
+ Closure doWithSpring() {
+ { ->
+ def application = grailsApplication
+ Config config = application.config
+ boolean developmentMode = isDevelopmentMode()
+ Environment env = Environment.current
- boolean enableReload = env.isReloadEnabled() ||
-
config.getProperty(GroovyPagesTemplateEngine.CONFIG_PROPERTY_GSP_ENABLE_RELOAD,
Boolean, false) ||
- (developmentMode && env ==
Environment.DEVELOPMENT)
+ boolean enableReload = env.isReloadEnabled() ||
+
config.getProperty(GroovyPagesTemplateEngine.CONFIG_PROPERTY_GSP_ENABLE_RELOAD,
Boolean, false) ||
+ (developmentMode && env == Environment.DEVELOPMENT)
- boolean warDeployed = application.warDeployed
- boolean warDeployedWithReload = warDeployed && enableReload
+ boolean warDeployed = application.warDeployed
+ boolean warDeployedWithReload = warDeployed && enableReload
- long gspCacheTimeout = config.getProperty(GSP_RELOAD_INTERVAL, Long,
(developmentMode && env == Environment.DEVELOPMENT) ? 0L : 5000L)
- boolean enableCacheResources =
!config.getProperty(GroovyPagesTemplateEngine.CONFIG_PROPERTY_DISABLE_CACHING_RESOURCES,
Boolean, false)
- String viewsDir = config.getProperty(GSP_VIEWS_DIR, '')
+ long gspCacheTimeout = config.getProperty(GSP_RELOAD_INTERVAL,
Long, (developmentMode && env == Environment.DEVELOPMENT) ? 0L : 5000L)
+ boolean enableCacheResources =
!config.getProperty(GroovyPagesTemplateEngine.CONFIG_PROPERTY_DISABLE_CACHING_RESOURCES,
Boolean, false)
+ String viewsDir = config.getProperty(GSP_VIEWS_DIR, '')
- RuntimeSpringConfiguration spring = springConfig
+ RuntimeSpringConfiguration spring = springConfig
- // resolves JSP tag libraries
- boolean resolveJspTagLibraries =
ClassUtils.isPresent('org.grails.gsp.jsp.TagLibraryResolverImpl',
application.classLoader)
- if (resolveJspTagLibraries) {
- jspTagLibraryResolver(TagLibraryResolverImpl)
- }
+ // resolves JSP tag libraries
+ boolean resolveJspTagLibraries =
ClassUtils.isPresent('org.grails.gsp.jsp.TagLibraryResolverImpl',
application.classLoader)
+ if (resolveJspTagLibraries) {
+ jspTagLibraryResolver(TagLibraryResolverImpl)
+ }
- // resolves GSP tag libraries
- gspTagLibraryLookup(TagLibraryLookup) { bean ->
- bean.lazyInit = true
- }
+ // resolves GSP tag libraries
+ gspTagLibraryLookup(TagLibraryLookup) { bean ->
+ bean.lazyInit = true
+ }
- boolean customResourceLoader = false
- // If the development environment is used we need to load GSP files
relative to the base directory
- // as oppose to in WAR deployment where views are loaded from /WEB-INF
+ boolean customResourceLoader = false
+ // If the development environment is used we need to load GSP
files relative to the base directory
+ // as oppose to in WAR deployment where views are loaded from
/WEB-INF
- if (viewsDir) {
- log.info "Configuring GSP views directory as '${viewsDir}'"
- customResourceLoader = true
- groovyPageResourceLoader(GroovyPageResourceLoader) {
- baseResource = "file:${viewsDir}"
- }
- }
- else {
- if (developmentMode) {
+ if (viewsDir) {
+ log.info "Configuring GSP views directory as '${viewsDir}'"
customResourceLoader = true
- groovyPageResourceLoader(GroovyPageResourceLoader) { bean ->
- bean.lazyInit = true
- def location =
GroovyPagesGrailsPlugin.transformToValidLocation(BuildSettings.BASE_DIR.absolutePath)
- baseResource = "file:$location"
+ groovyPageResourceLoader(GroovyPageResourceLoader) {
+ baseResource = "file:${viewsDir}"
}
- }
- else {
- if (warDeployedWithReload && env.hasReloadLocation()) {
+ } else {
+ if (developmentMode) {
customResourceLoader = true
- groovyPageResourceLoader(GroovyPageResourceLoader) {
- def location =
GroovyPagesGrailsPlugin.transformToValidLocation(env.reloadLocation)
- baseResource = "file:${location}"
+ groovyPageResourceLoader(GroovyPageResourceLoader) { bean
->
+ bean.lazyInit = true
+ def location =
GroovyPagesGrailsPlugin.transformToValidLocation(BuildSettings.BASE_DIR.absolutePath)
+ baseResource = "file:$location"
+ }
+ } else {
+ if (warDeployedWithReload && env.hasReloadLocation()) {
+ customResourceLoader = true
+ groovyPageResourceLoader(GroovyPageResourceLoader) {
+ def location =
GroovyPagesGrailsPlugin.transformToValidLocation(env.reloadLocation)
+ baseResource = "file:${location}"
+ }
}
}
}
- }
- def deployed =
!Metadata.getCurrent().isDevelopmentEnvironmentAvailable()
- groovyPageLocator(CachingGrailsConventionGroovyPageLocator) { bean ->
- bean.lazyInit = true
- if (customResourceLoader) {
- resourceLoader = groovyPageResourceLoader
- }
- if (deployed) {
- Resource defaultViews =
applicationContext?.getResource('gsp/views.properties')
+ def deployed =
!Metadata.getCurrent().isDevelopmentEnvironmentAvailable()
+ groovyPageLocator(CachingGrailsConventionGroovyPageLocator) { bean
->
+ bean.lazyInit = true
+ if (customResourceLoader) {
+ resourceLoader = groovyPageResourceLoader
+ }
+ if (deployed) {
+ Resource defaultViews =
applicationContext?.getResource('gsp/views.properties')
- if(defaultViews != null) {
- if(!defaultViews.exists()) {
- defaultViews =
applicationContext?.getResource('classpath:gsp/views.properties')
+ if (defaultViews != null) {
+ if (!defaultViews.exists()) {
+ defaultViews =
applicationContext?.getResource('classpath:gsp/views.properties')
+ }
}
- }
- if(defaultViews?.exists()) {
- precompiledGspMap = { PropertiesFactoryBean pfb ->
- ignoreResourceNotFound = true
- locations = [defaultViews] as Resource[]
+ if (defaultViews?.exists()) {
+ precompiledGspMap = { PropertiesFactoryBean pfb ->
+ ignoreResourceNotFound = true
+ locations = [defaultViews] as Resource[]
+ }
}
}
+ if (enableReload) {
+ cacheTimeout = gspCacheTimeout
+ }
+ reloadEnabled = enableReload
}
- if (enableReload) {
- cacheTimeout = gspCacheTimeout
- }
- reloadEnabled = enableReload
- }
- grailsResourceLocator(CachingGroovyPageStaticResourceLocator) { bean ->
- bean.parent = "abstractGrailsResourceLocator"
- if (enableReload) {
- cacheTimeout = gspCacheTimeout
+ grailsResourceLocator(CachingGroovyPageStaticResourceLocator) {
bean ->
+ bean.parent = "abstractGrailsResourceLocator"
+ if (enableReload) {
+ cacheTimeout = gspCacheTimeout
+ }
}
- }
- // Setup the main templateEngine used to render GSPs
- groovyPagesTemplateEngine(GroovyPagesTemplateEngine) {
- classLoader = ref("classLoader")
- groovyPageLocator = groovyPageLocator
- if (enableReload) {
- reloadEnabled = enableReload
- }
- tagLibraryLookup = gspTagLibraryLookup
- if (resolveJspTagLibraries) {
- jspTagLibraryResolver = jspTagLibraryResolver
+ // Setup the main templateEngine used to render GSPs
+ groovyPagesTemplateEngine(GroovyPagesTemplateEngine) {
+ classLoader = ref("classLoader")
+ groovyPageLocator = groovyPageLocator
+ if (enableReload) {
+ reloadEnabled = enableReload
+ }
+ tagLibraryLookup = gspTagLibraryLookup
+ if (resolveJspTagLibraries) {
+ jspTagLibraryResolver = jspTagLibraryResolver
+ }
+ cacheResources = enableCacheResources
}
- cacheResources = enableCacheResources
- }
- spring.addAlias('groovyTemplateEngine', 'groovyPagesTemplateEngine')
+ spring.addAlias('groovyTemplateEngine',
'groovyPagesTemplateEngine')
- groovyPageRenderer(PageRenderer, ref("groovyPagesTemplateEngine")) {
bean ->
- bean.lazyInit = true
- groovyPageLocator = groovyPageLocator
- }
+ groovyPageRenderer(PageRenderer, ref("groovyPagesTemplateEngine"))
{ bean ->
+ bean.lazyInit = true
+ groovyPageLocator = groovyPageLocator
+ }
- groovyPagesTemplateRenderer(GroovyPagesTemplateRenderer) { bean ->
- bean.autowire = true
- if (enableReload) {
- reloadEnabled = enableReload
+ groovyPagesTemplateRenderer(GroovyPagesTemplateRenderer) { bean ->
+ bean.autowire = true
+ if (enableReload) {
+ reloadEnabled = enableReload
+ }
}
- }
- // Setup the GroovyPagesUriService
- groovyPagesUriService(DefaultGroovyPagesUriService) { bean ->
- bean.lazyInit = true
- }
-
- boolean jstlPresent = ClassUtils.isPresent(
- "jakarta.servlet.jsp.jstl.core.Config",
InternalResourceViewResolver.class.getClassLoader())
-
- abstractViewResolver {
- prefix = GrailsApplicationAttributes.PATH_TO_VIEWS
- suffix = jstlPresent ? GroovyPageViewResolver.JSP_SUFFIX :
GroovyPageViewResolver.GSP_SUFFIX
- resolveJspView = jstlPresent
- templateEngine = groovyPagesTemplateEngine
- groovyPageLocator = groovyPageLocator
- if (enableReload) {
- cacheTimeout = gspCacheTimeout
+ // Setup the GroovyPagesUriService
+ groovyPagesUriService(DefaultGroovyPagesUriService) { bean ->
+ bean.lazyInit = true
}
- }
- // Configure a Spring MVC view resolver
- jspViewResolver(GroovyPageViewResolver) { bean ->
- bean.lazyInit = true
- bean.parent = "abstractViewResolver"
- }
- // Now go through tag libraries and configure them in Spring too. With
AOP proxies and so on
- for (taglib in application.tagLibClasses) {
+ boolean jstlPresent = ClassUtils.isPresent(
+ "jakarta.servlet.jsp.jstl.core.Config",
InternalResourceViewResolver.class.getClassLoader())
Review Comment:
FYI: Most of this code was a direct restore. I've gone ahead and formatted
the file + changed all of the double quotes to single strings ...
--
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]