use of org.springframework.beans.factory.support.AbstractBeanDefinition in project spring-framework by spring-projects.
the class XmlBeanFactoryTests method testStringConstructorArrayNoTypeNonLenient.
@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);
}
use of org.springframework.beans.factory.support.AbstractBeanDefinition in project spring-framework by spring-projects.
the class XmlBeanFactoryTests method testCustomStringConstructor.
@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);
}
use of org.springframework.beans.factory.support.AbstractBeanDefinition in project spring-boot by spring-projects.
the class RestDocumentationContextProviderRegistrar method registerBeanDefinitions.
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
Map<String, Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(AutoConfigureRestDocs.class.getName());
String outputDir = (String) annotationAttributes.get("outputDir");
AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(ManualRestDocumentation.class).addConstructorArgValue(outputDir).getBeanDefinition();
registry.registerBeanDefinition(ManualRestDocumentation.class.getName(), beanDefinition);
}
use of org.springframework.beans.factory.support.AbstractBeanDefinition in project spring-framework by spring-projects.
the class GroovyBeanDefinitionWrapper method createBeanDefinition.
protected AbstractBeanDefinition createBeanDefinition() {
AbstractBeanDefinition bd = new GenericBeanDefinition();
bd.setBeanClass(this.clazz);
if (!CollectionUtils.isEmpty(this.constructorArgs)) {
ConstructorArgumentValues cav = new ConstructorArgumentValues();
for (Object constructorArg : this.constructorArgs) {
cav.addGenericArgumentValue(constructorArg);
}
bd.setConstructorArgumentValues(cav);
}
if (this.parentName != null) {
bd.setParentName(this.parentName);
}
this.definitionWrapper = new BeanWrapperImpl(bd);
return bd;
}
use of org.springframework.beans.factory.support.AbstractBeanDefinition in project spring-framework by spring-projects.
the class UtilNamespaceHandlerTests method testEvents.
@Test
public void testEvents() {
ComponentDefinition propertiesComponent = this.listener.getComponentDefinition("myProperties");
assertNotNull("Event for 'myProperties' not sent", propertiesComponent);
AbstractBeanDefinition propertiesBean = (AbstractBeanDefinition) propertiesComponent.getBeanDefinitions()[0];
assertEquals("Incorrect BeanDefinition", PropertiesFactoryBean.class, propertiesBean.getBeanClass());
ComponentDefinition constantComponent = this.listener.getComponentDefinition("min");
assertNotNull("Event for 'min' not sent", propertiesComponent);
AbstractBeanDefinition constantBean = (AbstractBeanDefinition) constantComponent.getBeanDefinitions()[0];
assertEquals("Incorrect BeanDefinition", FieldRetrievingFactoryBean.class, constantBean.getBeanClass());
}
Aggregations