From ff61c2b05aea56937239429567fe777746e951ac Mon Sep 17 00:00:00 2001 From: James Fredley Date: Mon, 9 Sep 2024 22:45:19 -0400 Subject: [PATCH 1/2] Select the Grails messageSource when Micronaut creates a 2nd messageSource bean --- .../databinding/DataBindingConfiguration.java | 10 ++++- ...faultConstraintEvaluatorFactoryBean.groovy | 11 ++++- .../errors/AbstractVndErrorRenderer.groovy | 11 ++++- .../util/AbstractLinkingRenderer.groovy | 11 ++++- .../grails/validation/Validateable.groovy | 8 +++- .../support/MockApplicationContext.java | 42 ++++++++++--------- .../databinding/GrailsWebDataBinder.groovy | 9 ++-- 7 files changed, 73 insertions(+), 29 deletions(-) diff --git a/grails-plugin-databinding/src/main/groovy/org/grails/plugins/databinding/DataBindingConfiguration.java b/grails-plugin-databinding/src/main/groovy/org/grails/plugins/databinding/DataBindingConfiguration.java index 25c1e6a3b77..34bf4debf2e 100644 --- a/grails-plugin-databinding/src/main/groovy/org/grails/plugins/databinding/DataBindingConfiguration.java +++ b/grails-plugin-databinding/src/main/groovy/org/grails/plugins/databinding/DataBindingConfiguration.java @@ -8,11 +8,14 @@ import grails.web.databinding.GrailsWebDataBinder; import io.micronaut.core.util.ArrayUtils; import org.grails.databinding.bindingsource.DataBindingSourceCreator; +import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource; import org.grails.web.databinding.bindingsource.*; +import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.StaticMessageSource; import org.springframework.core.annotation.AnnotationAwareOrderComparator; @Configuration @@ -52,7 +55,12 @@ protected GrailsWebDataBinder grailsWebDataBinder( final DataBindingListener[] mainContextDataBindingListeners = mainContext .getBeansOfType(DataBindingListener.class).values().toArray(new DataBindingListener[0]); dataBinder.setDataBindingListeners(ArrayUtils.concat(dataBindingListeners,mainContextDataBindingListeners)); - dataBinder.setMessageSource(mainContext.getBean("messageSource", MessageSource.class)); + try{ + dataBinder.setMessageSource(mainContext.getBean("messageSource", StaticMessageSource.class)); + } catch(Exception e) { + dataBinder.setMessageSource(mainContext.getBean("messageSource", PluginAwareResourceBundleMessageSource.class)); + } + return dataBinder; } diff --git a/grails-plugin-domain-class/src/main/groovy/org/grails/plugins/domain/support/DefaultConstraintEvaluatorFactoryBean.groovy b/grails-plugin-domain-class/src/main/groovy/org/grails/plugins/domain/support/DefaultConstraintEvaluatorFactoryBean.groovy index 624ccb99946..4062744e155 100644 --- a/grails-plugin-domain-class/src/main/groovy/org/grails/plugins/domain/support/DefaultConstraintEvaluatorFactoryBean.groovy +++ b/grails-plugin-domain-class/src/main/groovy/org/grails/plugins/domain/support/DefaultConstraintEvaluatorFactoryBean.groovy @@ -6,6 +6,7 @@ import org.grails.datastore.gorm.validation.constraints.eval.DefaultConstraintEv import org.grails.datastore.gorm.validation.constraints.registry.ConstraintRegistry import org.grails.datastore.gorm.validation.constraints.registry.DefaultConstraintRegistry import org.grails.datastore.mapping.model.MappingContext +import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource import org.grails.validation.ConstraintEvalUtils import org.springframework.beans.factory.FactoryBean import org.springframework.beans.factory.annotation.Autowired @@ -14,9 +15,17 @@ import org.springframework.context.MessageSource class DefaultConstraintEvaluatorFactoryBean implements FactoryBean { - @Autowired MessageSource messageSource + @Autowired + void setMessageSource(PluginAwareResourceBundleMessageSource messageSource) { + this.messageSource = messageSource + } + + void setMessageSource(MessageSource messageSource) { + this.messageSource = messageSource + } + @Autowired @Qualifier('grailsDomainClassMappingContext') MappingContext grailsDomainClassMappingContext diff --git a/grails-plugin-rest/src/main/groovy/grails/rest/render/errors/AbstractVndErrorRenderer.groovy b/grails-plugin-rest/src/main/groovy/grails/rest/render/errors/AbstractVndErrorRenderer.groovy index 7193d972d99..134d952dd07 100644 --- a/grails-plugin-rest/src/main/groovy/grails/rest/render/errors/AbstractVndErrorRenderer.groovy +++ b/grails-plugin-rest/src/main/groovy/grails/rest/render/errors/AbstractVndErrorRenderer.groovy @@ -22,6 +22,7 @@ import grails.util.GrailsWebUtil import groovy.transform.CompileStatic import groovy.transform.TypeCheckingMode import grails.web.mapping.LinkGenerator +import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.MessageSource import org.springframework.validation.Errors @@ -46,9 +47,17 @@ abstract class AbstractVndErrorRenderer implements ContainerRenderer extends AbstractIncludeExcludeRenderer public static final String TEMPLATED_ATTRIBUTE = 'templated' public static final String DEPRECATED_ATTRIBUTE = 'deprecated' - @Autowired MessageSource messageSource + @Autowired + void setMessageSource(PluginAwareResourceBundleMessageSource messageSource) { + this.messageSource = messageSource + } + + void setMessageSource(MessageSource messageSource) { + this.messageSource = messageSource + } + @Autowired LinkGenerator linkGenerator diff --git a/grails-plugin-validation/src/main/groovy/grails/validation/Validateable.groovy b/grails-plugin-validation/src/main/groovy/grails/validation/Validateable.groovy index 6b12ae57ffe..f437ec283d1 100644 --- a/grails-plugin-validation/src/main/groovy/grails/validation/Validateable.groovy +++ b/grails-plugin-validation/src/main/groovy/grails/validation/Validateable.groovy @@ -24,6 +24,7 @@ import org.grails.datastore.gorm.support.BeforeValidateHelper import org.grails.datastore.gorm.validation.constraints.eval.DefaultConstraintEvaluator import org.grails.datastore.gorm.validation.constraints.registry.DefaultConstraintRegistry import org.grails.datastore.mapping.keyvalue.mapping.config.KeyValueMappingContext +import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource import org.grails.validation.ConstraintEvalUtils import org.springframework.context.ApplicationContext import org.springframework.context.MessageSource @@ -243,8 +244,11 @@ trait Validateable { private MessageSource findMessageSource() { try { ApplicationContext ctx = Holders.findApplicationContext() - MessageSource messageSource = ctx?.containsBean('messageSource') ? ctx.getBean('messageSource', MessageSource) : null - return messageSource + try{ + return ctx.getBean("messageSource", StaticMessageSource.class); + } catch(Exception e1) { + return ctx.getBean("messageSource", PluginAwareResourceBundleMessageSource.class); + } } catch (Throwable ignored) { return null } diff --git a/grails-test-suite-base/src/main/groovy/org/grails/support/MockApplicationContext.java b/grails-test-suite-base/src/main/groovy/org/grails/support/MockApplicationContext.java index 63035c02f26..38271275404 100644 --- a/grails-test-suite-base/src/main/groovy/org/grails/support/MockApplicationContext.java +++ b/grails-test-suite-base/src/main/groovy/org/grails/support/MockApplicationContext.java @@ -15,8 +15,10 @@ */ package org.grails.support; -import groovy.lang.GroovyObjectSupport; import grails.util.GrailsStringUtils; +import groovy.lang.GroovyObjectSupport; +import jakarta.servlet.ServletContext; +import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanFactory; @@ -25,6 +27,7 @@ import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.*; +import org.springframework.context.support.StaticMessageSource; import org.springframework.core.ResolvableType; import org.springframework.core.env.Environment; import org.springframework.core.io.AbstractResource; @@ -37,12 +40,12 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.StandardServletEnvironment; -import jakarta.servlet.ServletContext; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.lang.annotation.Annotation; import java.util.*; +import java.nio.charset.StandardCharsets; public class MockApplicationContext extends GroovyObjectSupport implements WebApplicationContext { @@ -329,27 +332,15 @@ public BeanFactory getParentBeanFactory() { } public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) { - MessageSource messageSource = (MessageSource)getBean("messageSource"); - if (messageSource == null) { - throw new BeanCreationException("No bean [messageSource] found in MockApplicationContext"); - } - return messageSource.getMessage(code, args, defaultMessage, locale); + return getMessageSource().getMessage(code, args, defaultMessage, locale); } public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException { - MessageSource messageSource = (MessageSource)getBean("messageSource"); - if (messageSource == null) { - throw new BeanCreationException("No bean [messageSource] found in MockApplicationContext"); - } - return messageSource.getMessage(code, args, locale); + return getMessageSource().getMessage(code, args, locale); } public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException { - MessageSource messageSource = (MessageSource)getBean("messageSource"); - if (messageSource == null) { - throw new BeanCreationException("No bean [messageSource] found in MockApplicationContext"); - } - return messageSource.getMessage(resolvable, locale); + return getMessageSource().getMessage(resolvable, locale); } public Resource[] getResources(String locationPattern) throws IOException { @@ -409,10 +400,23 @@ public Environment getEnvironment() { return new StandardServletEnvironment(); } + private MessageSource getMessageSource() { + try { + return getBean("messageSource", StaticMessageSource.class); + } catch (Exception e) { + try { + return getBean("messageSource", PluginAwareResourceBundleMessageSource.class); + } catch (Exception ignored) { + } + } + + throw new BeanCreationException("No bean [messageSource] found in MockApplicationContext"); + } + public class MockResource extends AbstractResource { private String contents = ""; - private String location; + private final String location; public MockResource(String location) { this.location = location; @@ -433,7 +437,7 @@ public String getDescription() { } public InputStream getInputStream() throws IOException { - return new ByteArrayInputStream(contents.getBytes("UTF-8")); + return new ByteArrayInputStream(contents.getBytes(StandardCharsets.UTF_8)); } } diff --git a/grails-web-databinding/src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy b/grails-web-databinding/src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy index 42d2d075e90..e0ac9bb3154 100644 --- a/grails-web-databinding/src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy +++ b/grails-web-databinding/src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy @@ -20,7 +20,6 @@ import grails.databinding.* import grails.databinding.converters.FormattedValueConverter import grails.databinding.converters.ValueConverter import grails.databinding.events.DataBindingListener -import grails.util.Environment import grails.util.GrailsClassUtils import grails.util.GrailsMetaClassUtils import grails.util.GrailsNameUtils @@ -45,8 +44,8 @@ import org.grails.datastore.mapping.model.types.ManyToOne import org.grails.datastore.mapping.model.types.OneToMany import org.grails.datastore.mapping.model.types.OneToOne import org.grails.datastore.mapping.model.types.Simple +import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource import org.grails.web.databinding.DataBindingEventMulticastListener -import org.grails.web.databinding.DefaultASTDatabindingHelper import org.grails.web.databinding.GrailsWebDataBindingListener import org.grails.web.databinding.SpringConversionServiceAdapter import org.grails.web.databinding.converters.ByteArrayMultipartFileValueConverter @@ -59,8 +58,6 @@ import org.springframework.validation.FieldError import org.springframework.validation.ObjectError import java.lang.annotation.Annotation -import java.lang.reflect.Modifier -import java.util.concurrent.ConcurrentHashMap import static grails.web.databinding.DataBindingUtils.* @@ -645,6 +642,10 @@ class GrailsWebDataBinder extends SimpleDataBinder { } @Autowired + void setMessageSource(PluginAwareResourceBundleMessageSource messageSource) { + this.messageSource = messageSource + } + void setMessageSource(MessageSource messageSource) { this.messageSource = messageSource } From f3448ec58bea51802929d1aa368235a9e78318d8 Mon Sep 17 00:00:00 2001 From: James Fredley Date: Tue, 10 Sep 2024 02:07:13 -0400 Subject: [PATCH 2/2] Switch to @Qualifier annotation to help Spring select the right messageSource bean --- .../databinding/DataBindingConfiguration.java | 10 +---- ...faultConstraintEvaluatorFactoryBean.groovy | 12 +----- .../errors/AbstractVndErrorRenderer.groovy | 13 ++---- .../util/AbstractLinkingRenderer.groovy | 12 +----- .../grails/validation/Validateable.groovy | 8 +--- .../support/MockApplicationContext.java | 42 +++++++++---------- .../databinding/GrailsWebDataBinder.groovy | 11 ++--- 7 files changed, 35 insertions(+), 73 deletions(-) diff --git a/grails-plugin-databinding/src/main/groovy/org/grails/plugins/databinding/DataBindingConfiguration.java b/grails-plugin-databinding/src/main/groovy/org/grails/plugins/databinding/DataBindingConfiguration.java index 34bf4debf2e..25c1e6a3b77 100644 --- a/grails-plugin-databinding/src/main/groovy/org/grails/plugins/databinding/DataBindingConfiguration.java +++ b/grails-plugin-databinding/src/main/groovy/org/grails/plugins/databinding/DataBindingConfiguration.java @@ -8,14 +8,11 @@ import grails.web.databinding.GrailsWebDataBinder; import io.micronaut.core.util.ArrayUtils; import org.grails.databinding.bindingsource.DataBindingSourceCreator; -import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource; import org.grails.web.databinding.bindingsource.*; -import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.StaticMessageSource; import org.springframework.core.annotation.AnnotationAwareOrderComparator; @Configuration @@ -55,12 +52,7 @@ protected GrailsWebDataBinder grailsWebDataBinder( final DataBindingListener[] mainContextDataBindingListeners = mainContext .getBeansOfType(DataBindingListener.class).values().toArray(new DataBindingListener[0]); dataBinder.setDataBindingListeners(ArrayUtils.concat(dataBindingListeners,mainContextDataBindingListeners)); - try{ - dataBinder.setMessageSource(mainContext.getBean("messageSource", StaticMessageSource.class)); - } catch(Exception e) { - dataBinder.setMessageSource(mainContext.getBean("messageSource", PluginAwareResourceBundleMessageSource.class)); - } - + dataBinder.setMessageSource(mainContext.getBean("messageSource", MessageSource.class)); return dataBinder; } diff --git a/grails-plugin-domain-class/src/main/groovy/org/grails/plugins/domain/support/DefaultConstraintEvaluatorFactoryBean.groovy b/grails-plugin-domain-class/src/main/groovy/org/grails/plugins/domain/support/DefaultConstraintEvaluatorFactoryBean.groovy index 4062744e155..1fff431ab49 100644 --- a/grails-plugin-domain-class/src/main/groovy/org/grails/plugins/domain/support/DefaultConstraintEvaluatorFactoryBean.groovy +++ b/grails-plugin-domain-class/src/main/groovy/org/grails/plugins/domain/support/DefaultConstraintEvaluatorFactoryBean.groovy @@ -6,7 +6,6 @@ import org.grails.datastore.gorm.validation.constraints.eval.DefaultConstraintEv import org.grails.datastore.gorm.validation.constraints.registry.ConstraintRegistry import org.grails.datastore.gorm.validation.constraints.registry.DefaultConstraintRegistry import org.grails.datastore.mapping.model.MappingContext -import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource import org.grails.validation.ConstraintEvalUtils import org.springframework.beans.factory.FactoryBean import org.springframework.beans.factory.annotation.Autowired @@ -15,16 +14,9 @@ import org.springframework.context.MessageSource class DefaultConstraintEvaluatorFactoryBean implements FactoryBean { - MessageSource messageSource - @Autowired - void setMessageSource(PluginAwareResourceBundleMessageSource messageSource) { - this.messageSource = messageSource - } - - void setMessageSource(MessageSource messageSource) { - this.messageSource = messageSource - } + @Qualifier("pluginAwareResourceBundleMessageSource") + MessageSource messageSource @Autowired @Qualifier('grailsDomainClassMappingContext') diff --git a/grails-plugin-rest/src/main/groovy/grails/rest/render/errors/AbstractVndErrorRenderer.groovy b/grails-plugin-rest/src/main/groovy/grails/rest/render/errors/AbstractVndErrorRenderer.groovy index 134d952dd07..09014f4f1b0 100644 --- a/grails-plugin-rest/src/main/groovy/grails/rest/render/errors/AbstractVndErrorRenderer.groovy +++ b/grails-plugin-rest/src/main/groovy/grails/rest/render/errors/AbstractVndErrorRenderer.groovy @@ -22,8 +22,8 @@ import grails.util.GrailsWebUtil import groovy.transform.CompileStatic import groovy.transform.TypeCheckingMode import grails.web.mapping.LinkGenerator -import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource import org.springframework.beans.factory.annotation.Autowired +import org.springframework.beans.factory.annotation.Qualifier import org.springframework.context.MessageSource import org.springframework.validation.Errors import org.springframework.validation.ObjectError @@ -47,16 +47,9 @@ abstract class AbstractVndErrorRenderer implements ContainerRenderer extends AbstractIncludeExcludeRenderer public static final String TEMPLATED_ATTRIBUTE = 'templated' public static final String DEPRECATED_ATTRIBUTE = 'deprecated' - MessageSource messageSource - @Autowired - void setMessageSource(PluginAwareResourceBundleMessageSource messageSource) { - this.messageSource = messageSource - } - - void setMessageSource(MessageSource messageSource) { - this.messageSource = messageSource - } + @Qualifier("pluginAwareResourceBundleMessageSource") + MessageSource messageSource @Autowired LinkGenerator linkGenerator diff --git a/grails-plugin-validation/src/main/groovy/grails/validation/Validateable.groovy b/grails-plugin-validation/src/main/groovy/grails/validation/Validateable.groovy index f437ec283d1..6b12ae57ffe 100644 --- a/grails-plugin-validation/src/main/groovy/grails/validation/Validateable.groovy +++ b/grails-plugin-validation/src/main/groovy/grails/validation/Validateable.groovy @@ -24,7 +24,6 @@ import org.grails.datastore.gorm.support.BeforeValidateHelper import org.grails.datastore.gorm.validation.constraints.eval.DefaultConstraintEvaluator import org.grails.datastore.gorm.validation.constraints.registry.DefaultConstraintRegistry import org.grails.datastore.mapping.keyvalue.mapping.config.KeyValueMappingContext -import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource import org.grails.validation.ConstraintEvalUtils import org.springframework.context.ApplicationContext import org.springframework.context.MessageSource @@ -244,11 +243,8 @@ trait Validateable { private MessageSource findMessageSource() { try { ApplicationContext ctx = Holders.findApplicationContext() - try{ - return ctx.getBean("messageSource", StaticMessageSource.class); - } catch(Exception e1) { - return ctx.getBean("messageSource", PluginAwareResourceBundleMessageSource.class); - } + MessageSource messageSource = ctx?.containsBean('messageSource') ? ctx.getBean('messageSource', MessageSource) : null + return messageSource } catch (Throwable ignored) { return null } diff --git a/grails-test-suite-base/src/main/groovy/org/grails/support/MockApplicationContext.java b/grails-test-suite-base/src/main/groovy/org/grails/support/MockApplicationContext.java index 38271275404..63035c02f26 100644 --- a/grails-test-suite-base/src/main/groovy/org/grails/support/MockApplicationContext.java +++ b/grails-test-suite-base/src/main/groovy/org/grails/support/MockApplicationContext.java @@ -15,10 +15,8 @@ */ package org.grails.support; -import grails.util.GrailsStringUtils; import groovy.lang.GroovyObjectSupport; -import jakarta.servlet.ServletContext; -import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource; +import grails.util.GrailsStringUtils; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanFactory; @@ -27,7 +25,6 @@ import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.*; -import org.springframework.context.support.StaticMessageSource; import org.springframework.core.ResolvableType; import org.springframework.core.env.Environment; import org.springframework.core.io.AbstractResource; @@ -40,12 +37,12 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.StandardServletEnvironment; +import jakarta.servlet.ServletContext; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.lang.annotation.Annotation; import java.util.*; -import java.nio.charset.StandardCharsets; public class MockApplicationContext extends GroovyObjectSupport implements WebApplicationContext { @@ -332,15 +329,27 @@ public BeanFactory getParentBeanFactory() { } public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) { - return getMessageSource().getMessage(code, args, defaultMessage, locale); + MessageSource messageSource = (MessageSource)getBean("messageSource"); + if (messageSource == null) { + throw new BeanCreationException("No bean [messageSource] found in MockApplicationContext"); + } + return messageSource.getMessage(code, args, defaultMessage, locale); } public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException { - return getMessageSource().getMessage(code, args, locale); + MessageSource messageSource = (MessageSource)getBean("messageSource"); + if (messageSource == null) { + throw new BeanCreationException("No bean [messageSource] found in MockApplicationContext"); + } + return messageSource.getMessage(code, args, locale); } public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException { - return getMessageSource().getMessage(resolvable, locale); + MessageSource messageSource = (MessageSource)getBean("messageSource"); + if (messageSource == null) { + throw new BeanCreationException("No bean [messageSource] found in MockApplicationContext"); + } + return messageSource.getMessage(resolvable, locale); } public Resource[] getResources(String locationPattern) throws IOException { @@ -400,23 +409,10 @@ public Environment getEnvironment() { return new StandardServletEnvironment(); } - private MessageSource getMessageSource() { - try { - return getBean("messageSource", StaticMessageSource.class); - } catch (Exception e) { - try { - return getBean("messageSource", PluginAwareResourceBundleMessageSource.class); - } catch (Exception ignored) { - } - } - - throw new BeanCreationException("No bean [messageSource] found in MockApplicationContext"); - } - public class MockResource extends AbstractResource { private String contents = ""; - private final String location; + private String location; public MockResource(String location) { this.location = location; @@ -437,7 +433,7 @@ public String getDescription() { } public InputStream getInputStream() throws IOException { - return new ByteArrayInputStream(contents.getBytes(StandardCharsets.UTF_8)); + return new ByteArrayInputStream(contents.getBytes("UTF-8")); } } diff --git a/grails-web-databinding/src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy b/grails-web-databinding/src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy index e0ac9bb3154..53fc9c98399 100644 --- a/grails-web-databinding/src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy +++ b/grails-web-databinding/src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy @@ -20,6 +20,7 @@ import grails.databinding.* import grails.databinding.converters.FormattedValueConverter import grails.databinding.converters.ValueConverter import grails.databinding.events.DataBindingListener +import grails.util.Environment import grails.util.GrailsClassUtils import grails.util.GrailsMetaClassUtils import grails.util.GrailsNameUtils @@ -44,13 +45,14 @@ import org.grails.datastore.mapping.model.types.ManyToOne import org.grails.datastore.mapping.model.types.OneToMany import org.grails.datastore.mapping.model.types.OneToOne import org.grails.datastore.mapping.model.types.Simple -import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource import org.grails.web.databinding.DataBindingEventMulticastListener +import org.grails.web.databinding.DefaultASTDatabindingHelper import org.grails.web.databinding.GrailsWebDataBindingListener import org.grails.web.databinding.SpringConversionServiceAdapter import org.grails.web.databinding.converters.ByteArrayMultipartFileValueConverter import org.grails.web.servlet.mvc.GrailsWebRequest import org.springframework.beans.factory.annotation.Autowired +import org.springframework.beans.factory.annotation.Qualifier import org.springframework.context.MessageSource import org.springframework.validation.BeanPropertyBindingResult import org.springframework.validation.BindingResult @@ -58,6 +60,8 @@ import org.springframework.validation.FieldError import org.springframework.validation.ObjectError import java.lang.annotation.Annotation +import java.lang.reflect.Modifier +import java.util.concurrent.ConcurrentHashMap import static grails.web.databinding.DataBindingUtils.* @@ -642,10 +646,7 @@ class GrailsWebDataBinder extends SimpleDataBinder { } @Autowired - void setMessageSource(PluginAwareResourceBundleMessageSource messageSource) { - this.messageSource = messageSource - } - + @Qualifier("pluginAwareResourceBundleMessageSource") void setMessageSource(MessageSource messageSource) { this.messageSource = messageSource }