Permalink
Browse files

replaced uses of deprecated XmlBeanDefinitionReader with DefaultLista…

…bleBeanFactory
  • Loading branch information...
1 parent c296705 commit f8b08ab6338ff15719d9191cf860428afa640bda Burt Beckwith committed Aug 13, 2012
@@ -37,7 +37,8 @@
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.beans.factory.xml.XmlBeanFactory;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
@@ -273,11 +274,12 @@ private void doPostResourceConfiguration(GrailsApplication app, RuntimeSpringCon
}
if (springResources != null && springResources.exists()) {
- LOG.debug("[RuntimeConfiguration] Configuring additional beans from " + springResources.getURL());
- XmlBeanFactory xmlBf = new XmlBeanFactory(springResources);
+ if (LOG.isDebugEnabled()) LOG.debug("[RuntimeConfiguration] Configuring additional beans from " + springResources.getURL());
+ DefaultListableBeanFactory xmlBf = new DefaultListableBeanFactory();
+ new XmlBeanDefinitionReader(xmlBf).loadBeanDefinitions(springResources);
xmlBf.setBeanClassLoader(classLoader);
String[] beanNames = xmlBf.getBeanDefinitionNames();
- LOG.debug("[RuntimeConfiguration] Found [" + beanNames.length + "] beans to configure");
+ if (LOG.isDebugEnabled()) LOG.debug("[RuntimeConfiguration] Found [" + beanNames.length + "] beans to configure");
for (String beanName : beanNames) {
BeanDefinition bd = xmlBf.getBeanDefinition(beanName);
final String beanClassName = bd.getBeanClassName();
@@ -30,7 +30,8 @@ import org.codehaus.groovy.grails.support.DevelopmentShutdownHook
import org.codehaus.groovy.grails.support.proxy.DefaultProxyHandler
import org.springframework.beans.factory.config.CustomEditorConfigurer
import org.springframework.beans.factory.config.MethodInvokingFactoryBean
-import org.springframework.beans.factory.xml.XmlBeanFactory
+import org.springframework.beans.factory.support.DefaultListableBeanFactory
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader
import org.springframework.core.io.Resource
import grails.util.*
@@ -146,7 +147,8 @@ class CoreGrailsPlugin {
def onChange = { event ->
if (event.source instanceof Resource) {
- def xmlBeans = new XmlBeanFactory(event.source)
+ def xmlBeans = new DefaultListableBeanFactory()
+ new XmlBeanDefinitionReader(xmlBeans).loadBeanDefinitions(event.source)
xmlBeans.beanDefinitionNames.each { name ->
event.ctx.registerBeanDefinition(name, xmlBeans.getBeanDefinition(name))
}
@@ -52,7 +52,8 @@ import org.springframework.beans.SimpleTypeConverter
import org.springframework.beans.TypeMismatchException
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.PropertiesFactoryBean
-import org.springframework.beans.factory.xml.XmlBeanFactory
+import org.springframework.beans.factory.support.DefaultListableBeanFactory
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader
import org.springframework.context.ApplicationContext
import org.springframework.dao.DataAccessException
import org.grails.datastore.mapping.model.MappingContext
@@ -688,7 +689,8 @@ Using Grails' default naming strategy: '${ImprovedNamingStrategy.name}'"""
try {
def resourcesXml = parent?.getResource(GrailsRuntimeConfigurator.SPRING_RESOURCES_XML)
if (resourcesXml && resourcesXml.exists()) {
- def xmlBeans = new XmlBeanFactory(resourcesXml)
+ def xmlBeans = new DefaultListableBeanFactory()
+ new XmlBeanDefinitionReader(xmlBeans).loadBeanDefinitions(resourcesXml)
if (xmlBeans.containsBean("dataSource")) {
LOG.info("Using dataSource bean definition from ${GrailsRuntimeConfigurator.SPRING_RESOURCES_XML}")
return xmlBeans.getMergedBeanDefinition("dataSource")

0 comments on commit f8b08ab

Please sign in to comment.