BeanFactoryLocator alternative in Spring 5

2k Views Asked by At

We were using 4.2.x version of spring and we are using BeanFactoryLocator to create a factory from xml file.

method to return Beanfactory:

private BeanFactory createServicesContainer() {
        BeanFactoryLocator bfLocator = SingletonBeanFactoryLocator.getInstance("Connector.xml");
        BeanFactoryReference bfReference = bfLocator.useBeanFactory("bigBean");
        return bfReference.getFactory();
    }

my Connector.xml file contains:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
       default-lazy-init="false">

    <!--
        The Big Bean for accessing all the repository services. This factory bean serves as
        and umbrella bean for all the underlying repository services.
    -->
    <bean id="bigBean" class="org.springframework.context.support.ClassPathXmlApplicationContext">
        <constructor-arg>
            <list>
                <value>sample1-connector.xml</value>
                <value>sample2-connector.xml</value>
                <value>sample3-connector.xml</value>
            </list>
        </constructor-arg>
    </bean>
</beans>

Now how can make changes it to work in Spring 5.x

0

There are 0 best solutions below