use of org.springframework.core.convert.converter.ConverterRegistry in project grails-core by grails.
the class AbstractGrailsPluginManager method doRuntimeConfiguration.
/**
* Base implementation that simply goes through the list of plugins and calls doWithRuntimeConfiguration on each
* @param springConfig The RuntimeSpringConfiguration instance
*/
public void doRuntimeConfiguration(RuntimeSpringConfiguration springConfig) {
ApplicationContext context = springConfig.getUnrefreshedApplicationContext();
AutowireCapableBeanFactory autowireCapableBeanFactory = context.getAutowireCapableBeanFactory();
if (autowireCapableBeanFactory instanceof ConfigurableListableBeanFactory) {
ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory) autowireCapableBeanFactory;
ConversionService existingConversionService = beanFactory.getConversionService();
ConverterRegistry converterRegistry;
if (existingConversionService == null) {
GenericConversionService conversionService = new GenericConversionService();
converterRegistry = conversionService;
beanFactory.setConversionService(conversionService);
} else {
converterRegistry = (ConverterRegistry) existingConversionService;
}
converterRegistry.addConverter(new Converter<NavigableMap.NullSafeNavigator, Object>() {
@Override
public Object convert(NavigableMap.NullSafeNavigator source) {
return null;
}
});
}
checkInitialised();
for (GrailsPlugin plugin : pluginList) {
if (plugin.supportsCurrentScopeAndEnvironment() && plugin.isEnabled(context.getEnvironment().getActiveProfiles())) {
plugin.doWithRuntimeConfiguration(springConfig);
}
}
}
use of org.springframework.core.convert.converter.ConverterRegistry in project cas by apereo.
the class CasCoreUtilConfiguration method init.
@PostConstruct
public void init() {
final ConfigurableApplicationContext ctx = applicationContextProvider().getConfigurableApplicationContext();
final DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(true);
conversionService.setEmbeddedValueResolver(new CasEmbeddedValueResolver(ctx));
ctx.getEnvironment().setConversionService(conversionService);
final ConfigurableEnvironment env = (ConfigurableEnvironment) ctx.getParent().getEnvironment();
env.setConversionService(conversionService);
final ConverterRegistry registry = (ConverterRegistry) DefaultConversionService.getSharedInstance();
registry.addConverter(zonedDateTimeToStringConverter());
}
Aggregations