grails / grails-gsp

GSP (Grails Server Pages) - A server-side view rendering technology based on Groovy
Apache License 2.0
15 stars 32 forks source link

Decouple SiteMesh 2 Final Phase - remove GroovyPageLayoutFinder requirement #384

Open codeconsole opened 1 year ago

codeconsole commented 1 year ago

GroovyPageLayoutFinder.groovy is coupled to too many things includingResponseRenderer.groovy

This could be solved by changing

    private GroovyPageLayoutFinder groovyPageLayoutFinder
    private GrailsPluginManager pluginManager

    @Generated
    @Autowired(required = false)
    void setGroovyPageLayoutFinder(GroovyPageLayoutFinder groovyPageLayoutFinder) {
        this.groovyPageLayoutFinder = groovyPageLayoutFinder

to

    private def groovyPageLayoutFinder
    private GrailsPluginManager pluginManager

    @Generated
    @Autowired(required = false)
    @Qualifier("groovyPageLayoutFinder") 
    void setGroovyPageLayoutFinder(def groovyPageLayoutFinder) {
        this.groovyPageLayoutFinder = groovyPageLayoutFinder
    }

but first the constants should be moved out of GroovyPageLayoutFinder and into a new java class since they can be utilized by both SiteMesh 2 and 3.

Plugin Breaking

Because this is a trait, this change would break any plugin controller compiled with a previous version of Grails. So this would require a warning to any Grails users that depend on old plugins with controllers. It probably should not be done until the next major version of Grails, but if that is the case a decision should be made whether to get rid of SiteMesh 2 support altogether. Since SiteMesh 2 hasn't officially been released for Jakarta, if Grails 7 is going to be Jakarta, the simplest route would be to just remove SiteMesh 2 altogether from Grails and go straight to SiteMesh 3.

Here is an example on how this breaks existing plugins:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stompWebSocketHandlerMapping' defined in class path resource [org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsInterceptorMappedInterceptor': Cannot create inner bean '(inner bean)#29dcd84a' of type [org.grails.plugins.web.interceptors.GrailsInterceptorHandlerInterceptorAdapter] while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#29dcd84a': Unsatisfied dependency expressed through method 'setInterceptors' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enabledInterceptor': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'groovyPageLayoutFinder' threw exception; nested exception is java.lang.AbstractMethodError: Receiver class org.grails.plugins.console.EnabledInterceptor does not define or inherit an implementation of the resolved method 'abstract java.lang.Object grails_artefact_controller_support_ResponseRenderer__groovyPageLayoutFinder$set(java.lang.Object)' of interface grails.artefact.controller.support.ResponseRenderer$Trait$FieldHelper.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsInterceptorMappedInterceptor': Cannot create inner bean '(inner bean)#29dcd84a' of type [org.grails.plugins.web.interceptors.GrailsInterceptorHandlerInterceptorAdapter] while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#29dcd84a': Unsatisfied dependency expressed through method 'setInterceptors' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enabledInterceptor': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'groovyPageLayoutFinder' threw exception; nested exception is java.lang.AbstractMethodError: Receiver class org.grails.plugins.console.EnabledInterceptor does not define or inherit an implementation of the resolved method 'abstract java.lang.Object grails_artefact_controller_support_ResponseRenderer__groovyPageLayoutFinder$set(java.lang.Object)' of interface grails.artefact.controller.support.ResponseRenderer$Trait$FieldHelper.
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:389)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#29dcd84a': Unsatisfied dependency expressed through method 'setInterceptors' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enabledInterceptor': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'groovyPageLayoutFinder' threw exception; nested exception is java.lang.AbstractMethodError: Receiver class org.grails.plugins.console.EnabledInterceptor does not define or inherit an implementation of the resolved method 'abstract java.lang.Object grails_artefact_controller_support_ResponseRenderer__groovyPageLayoutFinder$set(java.lang.Object)' of interface grails.artefact.controller.support.ResponseRenderer$Trait$FieldHelper.
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:824)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enabledInterceptor': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'groovyPageLayoutFinder' threw exception; nested exception is java.lang.AbstractMethodError: Receiver class org.grails.plugins.console.EnabledInterceptor does not define or inherit an implementation of the resolved method 'abstract java.lang.Object grails_artefact_controller_support_ResponseRenderer__groovyPageLayoutFinder$set(java.lang.Object)' of interface grails.artefact.controller.support.ResponseRenderer$Trait$FieldHelper.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1744)
Caused by: org.springframework.beans.PropertyBatchUpdateException: Failed properties: Property 'groovyPageLayoutFinder' threw exception; nested exception is java.lang.AbstractMethodError: Receiver class org.grails.plugins.console.EnabledInterceptor does not define or inherit an implementation of the resolved method 'abstract java.lang.Object grails_artefact_controller_support_ResponseRenderer__groovyPageLayoutFinder$set(java.lang.Object)' of interface grails.artefact.controller.support.ResponseRenderer$Trait$FieldHelper.
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:135)