Java Code Examples for org.springframework.web.context.support.XmlWebApplicationContext#getBeanFactory()

The following examples show how to use org.springframework.web.context.support.XmlWebApplicationContext#getBeanFactory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtensionsAdminController.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * hmmm, does not work yet, how to get a list with all overwritten beans like the output from to the log.info
 * http://www.docjar.com/html/api/org/springframework/beans/factory/support/DefaultListableBeanFactory.java.html
 * 
 * @return
 */
private List getOverwrittenBeans() {
    final ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(CoreSpringFactory.servletContext);
    final XmlWebApplicationContext context = (XmlWebApplicationContext) applicationContext;
    final ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
    final String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
    for (int i = 0; i < beanDefinitionNames.length; i++) {
        final String beanName = beanDefinitionNames[i];
        if (!beanName.contains("#")) {
            final BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName);
            // System.out.println(beanDef.getOriginatingBeanDefinition());
        }
    }
    return null;
}
 
Example 2
Source File: ExtensionsAdminController.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * hmmm, does not work yet, how to get a list with all overwritten beans like the output from to the log.info
 * http://www.docjar.com/html/api/org/springframework/beans/factory/support/DefaultListableBeanFactory.java.html
 * 
 * @return
 */
private List getOverwrittenBeans() {
    final ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(CoreSpringFactory.servletContext);
    final XmlWebApplicationContext context = (XmlWebApplicationContext) applicationContext;
    final ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
    final String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
    for (int i = 0; i < beanDefinitionNames.length; i++) {
        final String beanName = beanDefinitionNames[i];
        if (!beanName.contains("#")) {
            final BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName);
            // System.out.println(beanDef.getOriginatingBeanDefinition());
        }
    }
    return null;
}