本文整理匯總了Java中org.springframework.context.support.ClassPathXmlApplicationContext.getBeanFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassPathXmlApplicationContext.getBeanFactory方法的具體用法?Java ClassPathXmlApplicationContext.getBeanFactory怎麽用?Java ClassPathXmlApplicationContext.getBeanFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.context.support.ClassPathXmlApplicationContext
的用法示例。
在下文中一共展示了ClassPathXmlApplicationContext.getBeanFactory方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getContext
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
private static ClassPathXmlApplicationContext getContext(Object... beans) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("emptyContext.xml");
ConfigurableListableBeanFactory factory = context.getBeanFactory();
for (Object bean : beans) {
factory.registerSingleton(bean.getClass().getName(), bean);
}
return context;
}
示例2: testNonSingletonSteps
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test(expectedExceptions = FatalBeanException.class)
public void testNonSingletonSteps() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("emptyContext.xml");
ConfigurableListableBeanFactory factory = context.getBeanFactory();
GenericBeanDefinition definition = new GenericBeanDefinition();
definition.setBeanClass(DuplicateGivenBeanA.class);
definition.setLazyInit(false);
definition.setScope("prototype");
BeanDefinitionRegistry registry = BeanDefinitionRegistry.class.cast(factory);
registry.registerBeanDefinition(DuplicateGivenBeanA.class.getName(), definition);
process(context, new DuplicateGivenBeanA());
}