Skip to content

Commit 16e4c88

Browse files
committed
Merge branch '3.2.x' of https://github.com/grails/grails-core into 3.2.x
2 parents 7947188 + dcfdbee commit 16e4c88

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

grails-core/src/main/groovy/grails/boot/config/GrailsApplicationPostProcessor.groovy

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import grails.spring.BeanBuilder
1313
import grails.util.Environment
1414
import grails.util.Holders
1515
import groovy.transform.CompileStatic
16-
import groovy.util.logging.Commons
16+
import groovy.util.logging.Slf4j
1717
import org.grails.config.NavigableMap
1818
import org.grails.config.PrefixedMapPropertySource
1919
import org.grails.config.PropertySourcesConfig
@@ -34,9 +34,12 @@ import org.springframework.context.event.ApplicationContextEvent
3434
import org.springframework.context.event.ContextClosedEvent
3535
import org.springframework.context.event.ContextRefreshedEvent
3636
import org.springframework.core.convert.converter.Converter
37+
import org.springframework.core.convert.support.ConfigurableConversionService
3738
import org.springframework.core.env.AbstractEnvironment
3839
import org.springframework.core.env.ConfigurableEnvironment
3940
import 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
4952
class 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

grails-core/src/main/groovy/org/grails/spring/context/support/MapBasedSmartPropertyOverrideConfigurer.groovy

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ class MapBasedSmartPropertyOverrideConfigurer implements BeanFactoryPostProcesso
6060
final beanPropertyValue = beanPropertiesMap.get(beanPropertyName)
6161
applyPropertyValue(factory, beanName.toString(), beanPropertyName.toString(), beanPropertyValue)
6262
}
63-
6463
}
65-
6664
}
67-
6865
}
6966

7067
protected void applyPropertyValue(ConfigurableListableBeanFactory factory, String beanName, String property, Object value) {
@@ -116,15 +113,14 @@ class MapBasedSmartPropertyOverrideConfigurer implements BeanFactoryPostProcesso
116113
}
117114

118115
protected BeanDefinition getTargetBeanDefinitionForFactoryBean(ConfigurableListableBeanFactory factory,
119-
String beanName, BeanDefinition beanDefinition, Class beanClass) {
116+
String beanName, BeanDefinition beanDefinition, Class<? extends FactoryBean> beanClass) {
120117

121118
if (TransactionProxyFactoryBean.isAssignableFrom(beanClass)) {
122119
getTargetBeanDefinition(factory, beanName,
123120
(BeanDefinition)beanDefinition.propertyValues.getPropertyValue("target").value)
124121
}
125122
else {
126-
throw new BeanCreationException(beanName,
127-
"Unable to determine target bean definition for FactoryBeans of type " + beanClass.name)
123+
beanDefinition
128124
}
129125
}
130126
}

0 commit comments

Comments
 (0)