Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Commit

Permalink
Merge branch 5.1.x into 5.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
rainboyan committed Jun 21, 2022
2 parents 1e23d51 + 05445cb commit 2e80f14
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jspApiVersion=2.1
jstlVersion=1.1.2
spockVersion=2.0-groovy-3.0
springVersion=5.3.20
springBootVersion=2.6.2
springBootVersion=2.6.8
slf4jVersion=1.7.32
antVersion=1.10.12
controllersRef=https://docs.grails.org/latest/ref/Controllers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,6 @@ public void setJspTagLibraryResolver(TagLibraryResolver jspTagLibraryResolver) {
this.jspTagLibraryResolver = jspTagLibraryResolver;
}

/**
* Sets the ClassLoader that the TemplateEngine should use to
* @param classLoader The ClassLoader to use when compilation of Groovy Pages occurs
*/
public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}

/**
* Retrieves a line number matrix for the specified page that can be used
* to retrieve the actual line number within the GSP page if the line number within the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.springframework.beans.factory.config.RuntimeBeanReference
import org.springframework.beans.factory.support.BeanDefinitionRegistry
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
import org.springframework.beans.factory.support.GenericBeanDefinition
import org.springframework.core.io.DescriptiveResource
import org.springframework.core.Ordered

/**
Expand Down Expand Up @@ -69,6 +70,7 @@ class GrailsLayoutViewResolverPostProcessor implements BeanDefinitionRegistryPos
if (markBeanPrimary) {
beanDefinition.primary = true
}
beanDefinition.setResource(new DescriptiveResource("org.grails.plugins.web.GroovyPagesGrailsPlugin"))
final MutablePropertyValues propertyValues = beanDefinition.getPropertyValues()
propertyValues.addPropertyValue('innerViewResolver', previousViewResolver)
propertyValues.addPropertyValue('groovyPageLayoutFinder', new RuntimeBeanReference((String) GROOVY_PAGE_LAYOUT_FINDER_BEAN_NAME, false))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2005 the original author or authors.
* Copyright 2004-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,10 +48,12 @@ import org.springframework.boot.web.servlet.ServletRegistrationBean
import org.springframework.core.io.Resource
import org.springframework.util.ClassUtils
import org.springframework.web.servlet.view.InternalResourceViewResolver

/**
* Sets up and configures the GSP and GSP tag library support in Grails.
*
* @author Graeme Rocher
* @author Michael Yan
* @since 1.1
*/
@Slf4j
Expand Down Expand Up @@ -129,9 +131,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
}

// resolves GSP tag libraries
gspTagLibraryLookup(TagLibraryLookup) { bean ->
bean.lazyInit = true
}
gspTagLibraryLookup(TagLibraryLookup)


boolean customResourceLoader = false
Expand Down Expand Up @@ -202,7 +202,6 @@ class GroovyPagesGrailsPlugin extends Plugin {

// Setup the main templateEngine used to render GSPs
groovyPagesTemplateEngine(GroovyPagesTemplateEngine) { bean ->
classLoader = ref("classLoader")
groovyPageLocator = groovyPageLocator
if (enableReload) {
reloadEnabled = enableReload
Expand Down Expand Up @@ -262,7 +261,9 @@ class GroovyPagesGrailsPlugin extends Plugin {
}

// Now go through tag libraries and configure them in Spring too. With AOP proxies and so on
for (taglib in application.tagLibClasses) {
def start = System.currentTimeMillis()
def taglibs = application.getArtefacts(TagLibArtefactHandler.TYPE)
for (taglib in taglibs) {

final tagLibClass = taglib.clazz

Expand All @@ -274,6 +275,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
//bean.scope = 'request'
}
}
log.info(String.format("Found %d TagLibs: initialization completed in %d ms", taglibs.size(), (System.currentTimeMillis() - start)))

errorsViewStackTracePrinter(ErrorsViewStackTracePrinter, ref('grailsResourceLocator'))
filteringCodecsByContentTypeSettings(FilteringCodecsByContentTypeSettings, application)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2005 the original author or authors.
* Copyright 2004-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,6 +45,7 @@ import javax.servlet.http.HttpServletResponse
* This tag library tends to get extended by others as tags within here can be re-used in said libraries
*
* @author Graeme Rocher
* @author Michael Yan
*/
@TagLib
class ApplicationTagLib implements ApplicationContextAware, InitializingBean, GrailsApplicationAware, TagLibrary {
Expand All @@ -53,7 +54,6 @@ class ApplicationTagLib implements ApplicationContextAware, InitializingBean, Gr
ApplicationContext applicationContext
GrailsPluginManager pluginManager
GrailsApplication grailsApplication
UrlMappingsHolder grailsUrlMappingsHolder

@Autowired
LinkGenerator linkGenerator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class PageRendererSpec extends Specification {
tll.applicationContext = ctx

tll.afterPropertiesSet()
tll.afterSingletonsInstantiated()

te.tagLibraryLookup = tll

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.grails.taglib.encoder.WithCodecHelper;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

Expand All @@ -36,19 +37,23 @@
* @author Graeme Rocher
* @since 1.1
*/
public class TagLibraryLookup implements ApplicationContextAware, GrailsApplicationAware, InitializingBean {
public class TagLibraryLookup implements ApplicationContextAware, GrailsApplicationAware, InitializingBean, SmartInitializingSingleton {
protected ApplicationContext applicationContext;
protected GrailsApplication grailsApplication;
protected Map<String, Map<String, Object>> tagNamespaces = new HashMap<>();
protected Map<String, NamespacedTagDispatcher> namespaceDispatchers = new HashMap<>();
protected Map<String, Set<String>> tagsThatReturnObjectForNamespace = new HashMap<String, Set<String>>();
protected Map<String, Map<String,Map<String, Object>>> encodeAsForTagNamespaces = new HashMap<String, Map<String,Map<String, Object>>>();

@Override
public void afterPropertiesSet() throws Exception {
if (grailsApplication == null || applicationContext == null) {
return;
}
}

@Override
public void afterSingletonsInstantiated() {
try {
registerTagLibraries();
} catch (GrailsConfigurationException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class TagLibraryLookupSpec extends Specification {
lookup.grailsApplication = application
lookup.applicationContext = applicationContext
lookup.afterPropertiesSet()
lookup.afterSingletonsInstantiated()

def context = new MockServletContext()
context.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationContext)
Expand Down

0 comments on commit 2e80f14

Please sign in to comment.