public static XmlBeanFactory loadBeanFactory(Resource r) {
XmlBeanFactory beanFactory = new XmlBeanFactory(r);
try {
if (beanFactory.containsBean("customEditorConfigurer")) {
CustomEditorConfigurer configurer = (CustomEditorConfigurer) beanFactory.getBean("customEditorConfigurer");
configurer.postProcessBeanFactory(beanFactory);
}
} catch (NoSuchBeanDefinitionException nsbde) {
throw new RuntimeException(nsbde);
}
Map<Class, PropertyEditor> map = new HashMap<Class, PropertyEditor>();
map.put(ColourPair.class, new ColourPairPropertyEditor());
map.put(Color.class, new ColourPropertyEditor());
map.put(Pattern.class, new PatternPropertyEditor());
map.put(DateFormat.class, new DateFormatPropertyEditor());
map.put(ColumnWidths.class, new ColumnWidthsPropertyEditor());
CustomEditorConfigurer configurer = new CustomEditorConfigurer();
configurer.setCustomEditors(map);
configurer.postProcessBeanFactory(beanFactory);
return beanFactory;
}