@@ -13,7 +13,7 @@ import grails.spring.BeanBuilder
1313import grails.util.Environment
1414import grails.util.Holders
1515import groovy.transform.CompileStatic
16- import groovy.util.logging.Commons
16+ import groovy.util.logging.Slf4j
1717import org.grails.config.NavigableMap
1818import org.grails.config.PrefixedMapPropertySource
1919import org.grails.config.PropertySourcesConfig
@@ -34,9 +34,12 @@ import org.springframework.context.event.ApplicationContextEvent
3434import org.springframework.context.event.ContextClosedEvent
3535import org.springframework.context.event.ContextRefreshedEvent
3636import org.springframework.core.convert.converter.Converter
37+ import org.springframework.core.convert.support.ConfigurableConversionService
3738import org.springframework.core.env.AbstractEnvironment
3839import org.springframework.core.env.ConfigurableEnvironment
3940import org.springframework.core.env.EnumerablePropertySource
41+ import org.springframework.core.io.Resource
42+ import org.springframework.core.io.support.PathMatchingResourcePatternResolver
4043
4144/**
4245 * A {@link BeanDefinitionRegistryPostProcessor} that enhances any ApplicationContext with plugin manager capabilities
@@ -45,7 +48,7 @@ import org.springframework.core.env.EnumerablePropertySource
4548 * @since 3.0
4649 */
4750@CompileStatic
48- @Commons
51+ @Slf4j
4952class GrailsApplicationPostProcessor implements BeanDefinitionRegistryPostProcessor , ApplicationContextAware , ApplicationListener<ApplicationContextEvent > {
5053 static final boolean RELOADING_ENABLED = Environment . isReloadingAgentEnabled()
5154
@@ -109,16 +112,23 @@ class GrailsApplicationPostProcessor implements BeanDefinitionRegistryPostProces
109112
110113 protected void loadApplicationConfig () {
111114 org.springframework.core.env.Environment environment = applicationContext. getEnvironment()
115+ ConfigurableConversionService conversionService = null
112116 if (environment instanceof ConfigurableEnvironment ) {
113117 if (environment instanceof AbstractEnvironment ) {
114- def cs = environment. getConversionService()
115- cs. addConverter(new Converter<NavigableMap.NullSafeNavigator , String > () {
118+ conversionService = environment. getConversionService()
119+ conversionService. addConverter(new Converter<String , Resource > () {
120+ @Override
121+ public Resource convert (String source ) {
122+ return applicationContext. getResource(source);
123+ }
124+ });
125+ conversionService. addConverter(new Converter<NavigableMap.NullSafeNavigator , String > () {
116126 @Override
117127 public String convert (NavigableMap.NullSafeNavigator source ) {
118128 return null ;
119129 }
120130 });
121- cs . addConverter(new Converter<NavigableMap.NullSafeNavigator , Object > () {
131+ conversionService . addConverter(new Converter<NavigableMap.NullSafeNavigator , Object > () {
122132 @Override
123133 public Object convert (NavigableMap.NullSafeNavigator source ) {
124134 return null ;
@@ -138,7 +148,11 @@ class GrailsApplicationPostProcessor implements BeanDefinitionRegistryPostProces
138148 }
139149 }
140150 }
141- ((DefaultGrailsApplication )grailsApplication). config = new PropertySourcesConfig (propertySources)
151+ def config = new PropertySourcesConfig (propertySources)
152+ if (conversionService != null ) {
153+ config. setConversionService( conversionService )
154+ }
155+ ((DefaultGrailsApplication )grailsApplication). config = config
142156 }
143157 }
144158
0 commit comments