Example usage for org.springframework.context.support GenericApplicationContext getAutowireCapableBeanFactory

List of usage examples for org.springframework.context.support GenericApplicationContext getAutowireCapableBeanFactory

Introduction

In this page you can find the example usage for org.springframework.context.support GenericApplicationContext getAutowireCapableBeanFactory.

Prototype

@Override
    public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException 

Source Link

Usage

From source file:de.hybris.platform.btgcockpit.service.BTGCockpitServiceTest.java

public void initApplicationContext() {
    final GenericApplicationContext context = new GenericApplicationContext();
    context.setResourceLoader(new DefaultResourceLoader(Registry.class.getClassLoader()));
    context.setClassLoader(Registry.class.getClassLoader());
    context.getBeanFactory().setBeanClassLoader(Registry.class.getClassLoader());
    context.setParent(Registry.getGlobalApplicationContext());
    final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(context);
    xmlReader.setDocumentReaderClass(ScopeTenantIgnoreDocReader.class);
    xmlReader.setBeanClassLoader(Registry.class.getClassLoader());
    xmlReader.loadBeanDefinitions(getSpringConfigurationLocations());
    context.refresh();/*from   w  w  w .j av  a  2s . c om*/
    final AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
    beanFactory.autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, true);
    this.applicationContex = context;
}