org.springframework.beans.factory.support.AbstractBeanDefinition#setConstructorArgumentValues ( )源码实例Demo

下面列出了org.springframework.beans.factory.support.AbstractBeanDefinition#setConstructorArgumentValues ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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;
}
 
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;
}
 
源代码3 项目: lams   文件: GroovyBeanDefinitionWrapper.java
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;
}
 
源代码4 项目: blog_demos   文件: GroovyBeanDefinitionWrapper.java
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;
}
 
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;
}
 
源代码6 项目: zxl   文件: MulCommonBaseServiceParser.java
private BeanDefinition buildSqlSessionTemplateBeanDefinition(Element element, String name) {
	AbstractBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setAttribute(ID_ATTRIBUTE, name + SQL_SESSION_TEMPLATE_SUFFIX);
	beanDefinition.setBeanClass(SqlSessionTemplate.class);
	ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
	constructorArgumentValues.addIndexedArgumentValue(0, new RuntimeBeanReference(name + SQL_SESSION_FACTORY_SUFFIX));
	beanDefinition.setConstructorArgumentValues(constructorArgumentValues);
	return beanDefinition;
}
 
源代码7 项目: zxl   文件: MqBeanParser.java
protected void buildRabbitTemplateBeanDefinition(String beanName, String connectionFactoryBeanName, BeanDefinitionRegistry beanDefinitionRegistry) {
	AbstractBeanDefinition rabbitTemplateBeanDefinition = new GenericBeanDefinition();
	rabbitTemplateBeanDefinition.setBeanClass(RabbitTemplate.class);
	ConstructorArgumentValues rabbitTemplateConstructorArgumentValues = new ConstructorArgumentValues();
	rabbitTemplateConstructorArgumentValues.addIndexedArgumentValue(0, new RuntimeBeanReference(connectionFactoryBeanName));
	rabbitTemplateBeanDefinition.setConstructorArgumentValues(rabbitTemplateConstructorArgumentValues);
	beanDefinitionRegistry.registerBeanDefinition(beanName, rabbitTemplateBeanDefinition);
}
 
源代码8 项目: zxl   文件: MqBeanParser.java
protected void buildRabbitAdminBeanDefinition(String beanName, String connectionFactoryBeanName, BeanDefinitionRegistry beanDefinitionRegistry) {
	AbstractBeanDefinition rabbitAdminBeanDefinition = new GenericBeanDefinition();
	rabbitAdminBeanDefinition.setBeanClass(RabbitAdmin.class);
	ConstructorArgumentValues rabbitAdminConstructorArgumentValues = new ConstructorArgumentValues();
	rabbitAdminConstructorArgumentValues.addIndexedArgumentValue(0, new RuntimeBeanReference(connectionFactoryBeanName));
	rabbitAdminBeanDefinition.setConstructorArgumentValues(rabbitAdminConstructorArgumentValues);
	beanDefinitionRegistry.registerBeanDefinition(beanName, rabbitAdminBeanDefinition);
}
 
@Override
public void setProperty(String property, Object newValue) {
	if (PARENT.equals(property)) {
		setParent(newValue);
	}
	else {
		AbstractBeanDefinition bd = getBeanDefinition();
		if (AUTOWIRE.equals(property)) {
			if ("byName".equals(newValue)) {
				bd.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_NAME);
			}
			else if ("byType".equals(newValue)) {
				bd.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
			}
			else if ("constructor".equals(newValue)) {
				bd.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR);
			}
			else if (Boolean.TRUE.equals(newValue)) {
				bd.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_NAME);
			}
		}
		// constructorArgs
		else if (CONSTRUCTOR_ARGS.equals(property) && newValue instanceof List) {
			ConstructorArgumentValues cav = new ConstructorArgumentValues();
			List args = (List) newValue;
			for (Object arg : args) {
				cav.addGenericArgumentValue(arg);
			}
			bd.setConstructorArgumentValues(cav);
		}
		// factoryBean
		else if (FACTORY_BEAN.equals(property)) {
			if (newValue != null) {
				bd.setFactoryBeanName(newValue.toString());
			}
		}
		// factoryMethod
		else if (FACTORY_METHOD.equals(property)) {
			if (newValue != null) {
				bd.setFactoryMethodName(newValue.toString());
			}
		}
		// initMethod
		else if (INIT_METHOD.equals(property)) {
			if (newValue != null) {
				bd.setInitMethodName(newValue.toString());
			}
		}
		// destroyMethod
		else if (DESTROY_METHOD.equals(property)) {
			if (newValue != null) {
				bd.setDestroyMethodName(newValue.toString());
			}
		}
		// singleton property
		else if (SINGLETON.equals(property)) {
			bd.setScope(Boolean.TRUE.equals(newValue) ?
					BeanDefinition.SCOPE_SINGLETON : BeanDefinition.SCOPE_PROTOTYPE);
		}
		else if (this.definitionWrapper.isWritableProperty(property)) {
			this.definitionWrapper.setPropertyValue(property, newValue);
		}
		else {
			super.setProperty(property, newValue);
		}
	}
}
 
@Override
public void setProperty(String property, Object newValue) {
	if (PARENT.equals(property)) {
		setParent(newValue);
	}
	else {
		AbstractBeanDefinition bd = getBeanDefinition();
		if (AUTOWIRE.equals(property)) {
			if ("byName".equals(newValue)) {
				bd.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_NAME);
			}
			else if ("byType".equals(newValue)) {
				bd.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
			}
			else if ("constructor".equals(newValue)) {
				bd.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR);
			}
			else if (Boolean.TRUE.equals(newValue)) {
				bd.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_NAME);
			}
		}
		// constructorArgs
		else if (CONSTRUCTOR_ARGS.equals(property) && newValue instanceof List) {
			ConstructorArgumentValues cav = new ConstructorArgumentValues();
			List args = (List) newValue;
			for (Object arg : args) {
				cav.addGenericArgumentValue(arg);
			}
			bd.setConstructorArgumentValues(cav);
		}
		// factoryBean
		else if (FACTORY_BEAN.equals(property)) {
			if (newValue != null) {
				bd.setFactoryBeanName(newValue.toString());
			}
		}
		// factoryMethod
		else if (FACTORY_METHOD.equals(property)) {
			if (newValue != null) {
				bd.setFactoryMethodName(newValue.toString());
			}
		}
		// initMethod
		else if (INIT_METHOD.equals(property)) {
			if (newValue != null) {
				bd.setInitMethodName(newValue.toString());
			}
		}
		// destroyMethod
		else if (DESTROY_METHOD.equals(property)) {
			if (newValue != null) {
				bd.setDestroyMethodName(newValue.toString());
			}
		}
		// singleton property
		else if (SINGLETON.equals(property)) {
			bd.setScope(Boolean.TRUE.equals(newValue) ?
					BeanDefinition.SCOPE_SINGLETON : BeanDefinition.SCOPE_PROTOTYPE);
		}
		else if (this.definitionWrapper.isWritableProperty(property)) {
			this.definitionWrapper.setPropertyValue(property, newValue);
		}
		else {
			super.setProperty(property, newValue);
		}
	}
}
 
源代码11 项目: lams   文件: GroovyBeanDefinitionWrapper.java
public void setProperty(String property, Object newValue) {
	if (PARENT.equals(property)) {
		setParent(newValue);
	}
	else {
		AbstractBeanDefinition bd = getBeanDefinition();
		if (AUTOWIRE.equals(property)) {
			if ("byName".equals(newValue)) {
				bd.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME);
			}
			else if ("byType".equals(newValue)) {
				bd.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE);
			}
			else if ("constructor".equals(newValue)) {
				bd.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR);
			}
			else if (Boolean.TRUE.equals(newValue)) {
				bd.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME);
			}
		}
		// constructorArgs
		else if (CONSTRUCTOR_ARGS.equals(property) && newValue instanceof List) {
			ConstructorArgumentValues cav = new ConstructorArgumentValues();
			List args = (List) newValue;
			for (Object arg : args) {
				cav.addGenericArgumentValue(arg);
			}
			bd.setConstructorArgumentValues(cav);
		}
		// factoryBean
		else if (FACTORY_BEAN.equals(property)) {
			if (newValue != null) {
				bd.setFactoryBeanName(newValue.toString());
			}
		}
		// factoryMethod
		else if (FACTORY_METHOD.equals(property)) {
			if (newValue != null)
				bd.setFactoryMethodName(newValue.toString());
		}
		// initMethod
		else if (INIT_METHOD.equals(property)) {
			if (newValue != null) {
				bd.setInitMethodName(newValue.toString());
			}
		}
		// destroyMethod
		else if (DESTROY_METHOD.equals(property)) {
			if (newValue != null) {
				bd.setDestroyMethodName(newValue.toString());
			}
		}
		// singleton property
		else if (SINGLETON.equals(property)) {
			bd.setScope(Boolean.TRUE.equals(newValue) ?
					BeanDefinition.SCOPE_SINGLETON : BeanDefinition.SCOPE_PROTOTYPE);
		}
		else if (this.definitionWrapper.isWritableProperty(property)) {
			this.definitionWrapper.setPropertyValue(property, newValue);
		}
		else {
			super.setProperty(property, newValue);
		}
	}
}
 
源代码12 项目: blog_demos   文件: GroovyBeanDefinitionWrapper.java
public void setProperty(String property, Object newValue) {
	if (PARENT.equals(property)) {
		setParent(newValue);
	}
	else {
		AbstractBeanDefinition bd = getBeanDefinition();
		if (AUTOWIRE.equals(property)) {
			if ("byName".equals(newValue)) {
				bd.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME);
			}
			else if ("byType".equals(newValue)) {
				bd.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE);
			}
			else if ("constructor".equals(newValue)) {
				bd.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR);
			}
			else if (Boolean.TRUE.equals(newValue)) {
				bd.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME);
			}
		}
		// constructorArgs
		else if (CONSTRUCTOR_ARGS.equals(property) && newValue instanceof List) {
			ConstructorArgumentValues cav = new ConstructorArgumentValues();
			List args = (List) newValue;
			for (Object arg : args) {
				cav.addGenericArgumentValue(arg);
			}
			bd.setConstructorArgumentValues(cav);
		}
		// factoryBean
		else if (FACTORY_BEAN.equals(property)) {
			if (newValue != null) {
				bd.setFactoryBeanName(newValue.toString());
			}
		}
		// factoryMethod
		else if (FACTORY_METHOD.equals(property)) {
			if (newValue != null)
				bd.setFactoryMethodName(newValue.toString());
		}
		// initMethod
		else if (INIT_METHOD.equals(property)) {
			if (newValue != null) {
				bd.setInitMethodName(newValue.toString());
			}
		}
		// destroyMethod
		else if (DESTROY_METHOD.equals(property)) {
			if (newValue != null) {
				bd.setDestroyMethodName(newValue.toString());
			}
		}
		// singleton property
		else if (SINGLETON.equals(property)) {
			bd.setScope(Boolean.TRUE.equals(newValue) ?
					BeanDefinition.SCOPE_SINGLETON : BeanDefinition.SCOPE_PROTOTYPE);
		}
		else if (this.definitionWrapper.isWritableProperty(property)) {
			this.definitionWrapper.setPropertyValue(property, newValue);
		}
		else {
			super.setProperty(property, newValue);
		}
	}
}
 
public void setProperty(String property, Object newValue) {
	if (PARENT.equals(property)) {
		setParent(newValue);
	}
	else {
		AbstractBeanDefinition bd = getBeanDefinition();
		if (AUTOWIRE.equals(property)) {
			if ("byName".equals(newValue)) {
				bd.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME);
			}
			else if ("byType".equals(newValue)) {
				bd.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE);
			}
			else if ("constructor".equals(newValue)) {
				bd.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR);
			}
			else if (Boolean.TRUE.equals(newValue)) {
				bd.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME);
			}
		}
		// constructorArgs
		else if (CONSTRUCTOR_ARGS.equals(property) && newValue instanceof List) {
			ConstructorArgumentValues cav = new ConstructorArgumentValues();
			List args = (List) newValue;
			for (Object arg : args) {
				cav.addGenericArgumentValue(arg);
			}
			bd.setConstructorArgumentValues(cav);
		}
		// factoryBean
		else if (FACTORY_BEAN.equals(property)) {
			if (newValue != null) {
				bd.setFactoryBeanName(newValue.toString());
			}
		}
		// factoryMethod
		else if (FACTORY_METHOD.equals(property)) {
			if (newValue != null)
				bd.setFactoryMethodName(newValue.toString());
		}
		// initMethod
		else if (INIT_METHOD.equals(property)) {
			if (newValue != null) {
				bd.setInitMethodName(newValue.toString());
			}
		}
		// destroyMethod
		else if (DESTROY_METHOD.equals(property)) {
			if (newValue != null) {
				bd.setDestroyMethodName(newValue.toString());
			}
		}
		// singleton property
		else if (SINGLETON.equals(property)) {
			bd.setScope(Boolean.TRUE.equals(newValue) ?
					BeanDefinition.SCOPE_SINGLETON : BeanDefinition.SCOPE_PROTOTYPE);
		}
		else if (this.definitionWrapper.isWritableProperty(property)) {
			this.definitionWrapper.setPropertyValue(property, newValue);
		}
		else {
			super.setProperty(property, newValue);
		}
	}
}
 
源代码14 项目: ignite   文件: GridFactorySelfTest.java
/**
 * Gets test Spring application context with single {@link StringBuilder} bean
 * with name "myBean" and value "Test string".
 *
 * @return Spring application context.
 */
private ApplicationContext getTestApplicationContext() {
    AbstractBeanDefinition def = new GenericBeanDefinition();

    def.setBeanClass(StringBuilder.class);

    ConstructorArgumentValues args = new ConstructorArgumentValues();
    args.addGenericArgumentValue("Test string");

    def.setConstructorArgumentValues(args);

    GenericApplicationContext ctx = new GenericApplicationContext();

    ctx.registerBeanDefinition("myBean", def);

    return ctx;
}