在JSF + Spring Web应用程序中更改上下文属性值并重新加载上下文

时间:2013-07-02 07:13:04

标签: java spring jsf-2

我正在使用JSF 2.0和Spring 3.1构建应用程序。 在Spring应用程序上下文文件中,我正在设置属性 XMLOutputFilePath

Spring ApplicationContextFile : 

<bean id="placeholderConfig"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>/WEB-INF/classes/config.properties</value>
            </list>
        </property>
    </bean>
    <bean id="DetailsBean"
            class="sections.DetailsBeanFactory"
            factory-method="createInstance">
            <constructor-arg index="0" value="${XMLOutputFilePath}" />
        </bean>

当应用程序首次部署时,我正在从config.property文件中读取 XMLOutputFilePath

JSF Bean代码:

for (String filePath : _filePathList) {
                    System.setProperty("XMLOutputFilePath", filePath);
                    System.out.println("For file : " + filePath);
                    _context = new ClassPathXmlApplicationContext("WEB-INF/applicationContext.xml");
//Some code here
                }

我想在我的JSF Bean类中做两件事:

  1. 我有一个文件路径列表,我想用这个新路径为每个新文件路径更改 XMLOutputFilePath 值。 (可以在代码中看到。)
  2. 使用此新属性值重新加载上下文。
  3. 我试图以这种方式做到但它不起作用。它不会改变 XMLOutputFilePath *值也不会读取上下文文件。

    我怎么能这样做......可以帮助一下吗??

0 个答案:

没有答案
相关问题