11/*
2- * Copyright 2004-2023 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.
3939import grails .web .mvc .FlashScope ;
4040import grails .web .pages .GroovyPagesUriService ;
4141
42- import org .grails .gsp .ResourceAwareTemplateEngine ;
4342import org .grails .web .pages .DefaultGroovyPagesUriService ;
4443import org .grails .web .util .GrailsApplicationAttributes ;
4544
@@ -64,9 +63,6 @@ public class DefaultGrailsApplicationAttributes implements GrailsApplicationAttr
6463
6564 private ApplicationContext appContext ;
6665
67- // Beans used very often
68- private ResourceAwareTemplateEngine pagesTemplateEngine ;
69-
7066 private GrailsApplication grailsApplication ;
7167
7268 private GroovyPagesUriService groovyPagesUriService ;
@@ -85,6 +81,7 @@ public DefaultGrailsApplicationAttributes(ServletContext context) {
8581 }
8682 }
8783
84+ @ Override
8885 public ApplicationContext getApplicationContext () {
8986 return this .appContext ;
9087 }
@@ -115,6 +112,7 @@ private <T> T fetchBeanFromAppCtx(String name) {
115112 }
116113 }
117114
115+ @ Override
118116 public String getPluginContextPath (HttpServletRequest request ) {
119117 GroovyObject controller = getController (request );
120118 if (controller != null && getPluginManager () != null ) {
@@ -125,10 +123,12 @@ public String getPluginContextPath(HttpServletRequest request) {
125123 return "" ;
126124 }
127125
126+ @ Override
128127 public GroovyObject getController (ServletRequest request ) {
129128 return (GroovyObject ) request .getAttribute (CONTROLLER );
130129 }
131130
131+ @ Override
132132 public String getControllerUri (ServletRequest request ) {
133133 return "/" + getControllerName (request );
134134 }
@@ -166,10 +166,12 @@ public String getApplicationUri(ServletRequest request) {
166166 return appUri ;
167167 }
168168
169+ @ Override
169170 public ServletContext getServletContext () {
170171 return this .context ;
171172 }
172173
174+ @ Override
173175 public FlashScope getFlashScope (ServletRequest request ) {
174176 if (!(request instanceof HttpServletRequest )) {
175177 return null ;
@@ -196,35 +198,30 @@ public FlashScope getFlashScope(ServletRequest request) {
196198 return fs ;
197199 }
198200
201+ @ Override
199202 public String getTemplateUri (CharSequence templateName , ServletRequest request ) {
200203 Assert .notNull (templateName , "Argument [template] cannot be null" );
201204 return getGroovyPagesUriService ().getTemplateURI (getControllerName (request ), templateName .toString ());
202205 }
203206
207+ @ Override
204208 public String getViewUri (String viewName , HttpServletRequest request ) {
205209 Assert .notNull (viewName , "Argument [view] cannot be null" );
206210 return getGroovyPagesUriService ().getDeployedViewURI (getControllerName (request ), viewName );
207211 }
208212
213+ @ Override
209214 public String getControllerActionUri (ServletRequest request ) {
210215 GroovyObject controller = getController (request );
211216 return (String ) controller .getProperty ("actionUri" );
212217 }
213218
219+ @ Override
214220 public Errors getErrors (ServletRequest request ) {
215221 return (Errors ) request .getAttribute (ERRORS );
216222 }
217223
218- public ResourceAwareTemplateEngine getPagesTemplateEngine () {
219- if (this .pagesTemplateEngine == null ) {
220- this .pagesTemplateEngine = fetchBeanFromAppCtx (ResourceAwareTemplateEngine .BEAN_ID );
221- }
222- if (this .pagesTemplateEngine == null && logger .isWarnEnabled ()) {
223- logger .warn ("No bean named [" + ResourceAwareTemplateEngine .BEAN_ID + "] defined in Spring application context!" );
224- }
225- return this .pagesTemplateEngine ;
226- }
227-
224+ @ Override
228225 public GrailsApplication getGrailsApplication () {
229226 if (this .grailsApplication == null ) {
230227 this .grailsApplication = fetchBeanFromAppCtx (GrailsApplication .APPLICATION_ID );
@@ -235,18 +232,22 @@ public GrailsApplication getGrailsApplication() {
235232 return this .grailsApplication ;
236233 }
237234
235+ @ Override
238236 public Writer getOut (HttpServletRequest request ) {
239237 return (Writer ) request .getAttribute (OUT );
240238 }
241239
240+ @ Override
242241 public void setOut (HttpServletRequest request , Writer out2 ) {
243242 request .setAttribute (OUT , out2 );
244243 }
245244
245+ @ Override
246246 public String getNoSuffixViewURI (GroovyObject controller , String viewName ) {
247247 return getGroovyPagesUriService ().getNoSuffixViewURI (controller , viewName );
248248 }
249249
250+ @ Override
250251 public String getTemplateURI (GroovyObject controller , String templateName ) {
251252 return getGroovyPagesUriService ().getTemplateURI (controller , templateName );
252253 }
@@ -256,6 +257,7 @@ public String getTemplateURI(GroovyObject controller, String templateName, boole
256257 return getGroovyPagesUriService ().getTemplateURI (controller , templateName , includeExtension );
257258 }
258259
260+ @ Override
259261 public GroovyPagesUriService getGroovyPagesUriService () {
260262 if (this .groovyPagesUriService == null ) {
261263 this .groovyPagesUriService = fetchBeanFromAppCtx (GroovyPagesUriService .BEAN_ID );
@@ -266,6 +268,7 @@ public GroovyPagesUriService getGroovyPagesUriService() {
266268 return this .groovyPagesUriService ;
267269 }
268270
271+ @ Override
269272 public MessageSource getMessageSource () {
270273 if (this .messageSource == null ) {
271274 this .messageSource = fetchBeanFromAppCtx ("messageSource" );
0 commit comments