Trang

28 thg 7, 2011

ReLoad bean in a web context

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);

Không có nhận xét nào:

Đăng nhận xét