Announcement Announcement Module
Collapse
No announcement yet.
ReLoad bean in a different context Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ReLoad bean in a different context

    Hello,

    I reload very well my bean with new properties in my web app with Spring 2.5.

    My bean is based on XML configuration file and when we want change the application configuration, we modify these XML file and we force the bean reloading.

    This bean is loaded from XML file with an unmarshall method that set all bean object properties.
    It's work very fine and I can see the new XML information in this unmarshall method with the debug mode.
    We get new values in the bean for the next action in the webapp.

    How I refresh my bean :
    Code:
    XmlWebApplicationContext xmlWebApplicationContext =
    			(XmlWebApplicationContext) ContextLoader.getCurrentWebApplicationContext();
    		
    		DefaultListableBeanFactory defaultListableBeanFactory =
    		(DefaultListableBeanFactory) xmlWebApplicationContext.getBeanFactory();
    		BeanDefinition beanDefinition = defaultListableBeanFactory.getBeanDefinition(beanName);
    		beanDefinition.setBeanClassName(beanClassPath);
    		defaultListableBeanFactory.destroyBean(beanName, beanInstance);
    		defaultListableBeanFactory.registerBeanDefinition(beanName, beanDefinition);
    When I package my web application in a jar file and intergrate it in other web app and I want reload my bean, I get a problem.
    My bean is not refreshed.

    I try same lib, extract my context file outside from the jar file, ...
    without success.

    No ideas about it ?
    Thank for your help,

    Pierrick
Working...
X