当前位置: 首页>>代码示例>>Java>>正文


Java DefaultListableBeanFactory.getBeanDefinition方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultListableBeanFactory.getBeanDefinition方法的具体用法?Java DefaultListableBeanFactory.getBeanDefinition怎么用?Java DefaultListableBeanFactory.getBeanDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.support.DefaultListableBeanFactory的用法示例。


在下文中一共展示了DefaultListableBeanFactory.getBeanDefinition方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNonLenientDependencyMatching

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testNonLenientDependencyMatching() {
	DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
	AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("lenientDependencyTestBean");
	bd.setLenientConstructorResolution(false);
	try {
		xbf.getBean("lenientDependencyTestBean");
		fail("Should have thrown BeanCreationException");
	}
	catch (BeanCreationException ex) {
		// expected
		ex.printStackTrace();
		assertTrue(ex.getMostSpecificCause().getMessage().contains("Ambiguous"));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:XmlBeanFactoryTests.java

示例2: testNonLenientDependencyMatchingFactoryMethod

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testNonLenientDependencyMatchingFactoryMethod() {
	DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
	AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("lenientDependencyTestBeanFactoryMethod");
	bd.setLenientConstructorResolution(false);
	try {
		xbf.getBean("lenientDependencyTestBeanFactoryMethod");
		fail("Should have thrown BeanCreationException");
	}
	catch (BeanCreationException ex) {
		// expected
		ex.printStackTrace();
		assertTrue(ex.getMostSpecificCause().getMessage().contains("Ambiguous"));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:XmlBeanFactoryTests.java

示例3: defaultLazyInit

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void defaultLazyInit() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
			new ClassPathResource("NestedBeansElementAttributeRecursionTests-lazy-context.xml", this.getClass()));

	BeanDefinition foo = bf.getBeanDefinition("foo");
	BeanDefinition bar = bf.getBeanDefinition("bar");
	BeanDefinition baz = bf.getBeanDefinition("baz");
	BeanDefinition biz = bf.getBeanDefinition("biz");
	BeanDefinition buz = bf.getBeanDefinition("buz");

	assertThat(foo.isLazyInit(), is(false));
	assertThat(bar.isLazyInit(), is(true));
	assertThat(baz.isLazyInit(), is(false));
	assertThat(biz.isLazyInit(), is(true));
	assertThat(buz.isLazyInit(), is(true));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:NestedBeansElementAttributeRecursionTests.java

示例4: testExplicitScopeInheritanceForChildBeanDefinitions

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testExplicitScopeInheritanceForChildBeanDefinitions() throws Exception {
	String theChildScope = "bonanza!";

	RootBeanDefinition parent = new RootBeanDefinition();
	parent.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);

	AbstractBeanDefinition child = BeanDefinitionBuilder.childBeanDefinition("parent").getBeanDefinition();
	child.setBeanClass(TestBean.class);
	child.setScope(theChildScope);

	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	factory.registerBeanDefinition("parent", parent);
	factory.registerBeanDefinition("child", child);

	AbstractBeanDefinition def = (AbstractBeanDefinition) factory.getBeanDefinition("child");
	assertEquals("Child 'scope' not overriding parent scope (it must).", theChildScope, def.getScope());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:DefaultListableBeanFactoryTests.java

示例5: afterTestClass

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Override
public void afterTestClass(TestContext testContext) throws Exception {
    super.afterTestClass(testContext);
    /**
     * 重新注册被污染的bean
     */
    DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) testContext.getApplicationContext()
            .getAutowireCapableBeanFactory();
    for (Entry<String, Object> entry : testedObjects.entrySet()) {
        BeanDefinition beanDefinition = beanFactory.getBeanDefinition(entry.getKey());
        beanFactory.removeBeanDefinition(entry.getKey());
        beanFactory.registerBeanDefinition(entry.getKey(), beanDefinition);
    }
}
 
开发者ID:warlock-china,项目名称:wisp,代码行数:15,代码来源:UnitTestDependencyInjectionTestExecutionListener.java

示例6: beanDef

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
private AbstractBeanDefinition beanDef(Class<?> configClass) {
	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	factory.registerBeanDefinition("config", new RootBeanDefinition(configClass));
	ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
	pp.postProcessBeanFactory(factory);
	return (AbstractBeanDefinition) factory.getBeanDefinition("foo");
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:BeanAnnotationAttributePropagationTests.java

示例7: testJavaLangStringConstructor

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testJavaLangStringConstructor() {
	DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
	AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("string");
	bd.setLenientConstructorResolution(false);
	String str = (String) xbf.getBean("string");
	assertEquals("test", str);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:XmlBeanFactoryTests.java

示例8: testCustomStringConstructor

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testCustomStringConstructor() {
	DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
	AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("stringConstructor");
	bd.setLenientConstructorResolution(false);
	StringConstructorTestBean tb = (StringConstructorTestBean) xbf.getBean("stringConstructor");
	assertEquals("test", tb.name);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:XmlBeanFactoryTests.java

示例9: testStringConstructorArrayNoTypeNonLenient

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
@Test
public void testStringConstructorArrayNoTypeNonLenient() {
	DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
	AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("constructorArrayNoType");
	bd.setLenientConstructorResolution(false);
	ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("constructorArrayNoType");
	assertTrue(bean.array instanceof String[]);
	assertEquals(0, ((String[]) bean.array).length);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:XmlBeanFactoryTests.java

示例10: getBeanDefinition

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
/**
 * 获取bean定义
 * @param beanName
 */
public static BeanDefinition getBeanDefinition(String beanName) {
	DefaultListableBeanFactory beanFactory = getDefaultBeanFactory();
	BeanDefinition def = beanFactory.getBeanDefinition(beanName);
	return def;
}
 
开发者ID:jambo-framework,项目名称:jambo2,代码行数:10,代码来源:SpringContextManager.java

示例11: assertBeanPropertyValueOf

import org.springframework.beans.factory.support.DefaultListableBeanFactory; //导入方法依赖的package包/类
private void assertBeanPropertyValueOf(String propertyName, String expected, DefaultListableBeanFactory factory) {
	BeanDefinition bean = factory.getBeanDefinition(expected);
	PropertyValue value = bean.getPropertyValues().getPropertyValue(propertyName);
	assertThat(value, is(notNullValue()));
	assertThat(value.getValue().toString(), is(expected));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:JdbcNamespaceIntegrationTests.java


注:本文中的org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。