11/*
2- * Copyright 2004-2024 the original author or authors.
2+ * Copyright 2004-2025 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -18,24 +18,10 @@ package org.grails.plugins.web
1818import groovy.transform.CompileStatic
1919import org.springframework.core.Ordered
2020
21- import grails.core.gsp.GrailsTagLibClass
2221import grails.plugins.Plugin
2322import grails.util.GrailsUtil
2423import grails.web.pages.GroovyPagesUriService
25- import org.grails.core.artefact.gsp.TagLibArtefactHandler
2624import org.grails.gsp.GroovyPagesTemplateEngine
27- import org.grails.plugins.web.taglib.ApplicationTagLib
28- import org.grails.plugins.web.taglib.CountryTagLib
29- import org.grails.plugins.web.taglib.FormTagLib
30- import org.grails.plugins.web.taglib.FormatTagLib
31- import org.grails.plugins.web.taglib.JavascriptTagLib
32- import org.grails.plugins.web.taglib.PluginTagLib
33- import org.grails.plugins.web.taglib.RenderTagLib
34- import org.grails.plugins.web.taglib.SitemeshTagLib
35- import org.grails.plugins.web.taglib.UrlMappingTagLib
36- import org.grails.plugins.web.taglib.ValidationTagLib
37- import org.grails.taglib.TagLibraryLookup
38- import org.grails.taglib.TagLibraryMetaUtils
3925import org.grails.web.pages.FilteringCodecsByContentTypeSettings
4026
4127/**
@@ -54,49 +40,14 @@ class GroovyPagesGrailsPlugin extends Plugin implements Ordered {
5440 def version = GrailsUtil . getGrailsVersion()
5541 def dependsOn = [core : GrailsUtil . getGrailsVersion()]
5642
57- def watchedResources = [" file:./plugins/*/grails-app/taglib/**/*TagLib.groovy" ,
58- " file:./grails-app/taglib/**/*TagLib.groovy" ,
59- " file:./plugins/*/app/taglib/**/*TagLib.groovy" ,
60- " file:./app/taglib/**/*TagLib.groovy" ]
61-
62- def providedArtefacts = [
63- ApplicationTagLib ,
64- CountryTagLib ,
65- FormatTagLib ,
66- FormTagLib ,
67- JavascriptTagLib ,
68- RenderTagLib ,
69- UrlMappingTagLib ,
70- ValidationTagLib ,
71- PluginTagLib ,
72- SitemeshTagLib
73- ]
74-
7543 int order = 600
7644
7745 /**
7846 * Configures the various Spring beans required by GSP
7947 */
80- Closure doWithSpring () {
81- { ->
82- def application = grailsApplication
83-
84- // Now go through tag libraries and configure them in Spring too. With AOP proxies and so on
85- def taglibs = application. getArtefacts(TagLibArtefactHandler . TYPE )
86- for (taglib in taglibs) {
87- final tagLibClass = taglib. clazz
88-
89- " ${ taglib.fullName} " (tagLibClass) { bean ->
90- bean. autowire = true
91- bean. lazyInit = true
48+ Closure doWithSpring () { { ->
9249
93- // Taglib scoping support could be easily added here. Scope could be based on a static field in the taglib class.
94- // bean.scope = 'request'
95- }
96- }
97-
98- }
99- }
50+ } }
10051
10152 /**
10253 * Clear the page cache with the ApplicationContext is loaded
@@ -109,27 +60,8 @@ class GroovyPagesGrailsPlugin extends Plugin implements Ordered {
10960
11061 @Override
11162 void onChange (Map<String , Object > event ) {
112- def application = grailsApplication
11363 def ctx = applicationContext
11464
115- if (application. isArtefactOfType(TagLibArtefactHandler . TYPE , event. source)) {
116- GrailsTagLibClass taglibClass = (GrailsTagLibClass ) application. addArtefact(TagLibArtefactHandler . TYPE , event. source)
117- if (taglibClass) {
118- // replace tag library bean
119- def beanName = taglibClass. fullName
120- beans {
121- " $beanName " (taglibClass. clazz) { bean ->
122- bean. autowire = true
123- }
124- }
125-
126- // The tag library lookup class caches "tag -> taglib class"
127- // so we need to update it now.
128- def lookup = applicationContext. getBean(' gspTagLibraryLookup' , TagLibraryLookup )
129- lookup. registerTagLib(taglibClass)
130- TagLibraryMetaUtils . enhanceTagLibMetaClass(taglibClass, lookup)
131- }
132- }
13365 // clear uri cache after changes
13466 ctx. getBean(' groovyPagesUriService' , GroovyPagesUriService ). clear()
13567 }
0 commit comments