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


Java GenericBeanDefinition.setPropertyValues方法代码示例

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


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

示例1: createBeanDefinition

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private static BeanDefinition createBeanDefinition(ComponentDefinition componentDefinition) {
    GenericBeanDefinition beanDefinition = new GenericBeanDefinition();

    beanDefinition.setBeanClassName(componentDefinition.getComponentClass());
    beanDefinition.setScope(getScope(componentDefinition.getScope()));
    beanDefinition.setAutowireCandidate(true);
    beanDefinition.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME);
    beanDefinition.setDependsOn(componentDefinition.getDependsOn());
    beanDefinition.setLazyInit(componentDefinition.isLazyInit());

    ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
    for (Object value : componentDefinition.getConstructorArguments()) {
        constructorArgumentValues.addIndexedArgumentValue(constructorArgumentValues.getArgumentCount(), value);
    }
    beanDefinition.setConstructorArgumentValues(constructorArgumentValues);

    MutablePropertyValues propertyValues = new MutablePropertyValues();
    for (PropertyValue propertyValue : componentDefinition.getPropertyValues()) {
        propertyValues.add(propertyValue.getName(), propertyValue.getValue());
    }
    beanDefinition.setPropertyValues(propertyValues);

    return beanDefinition;
}
 
开发者ID:Indoqa,项目名称:indoqa-spring,代码行数:25,代码来源:DynamicApplicationContextBuilder.java

示例2: toInternal

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * Convert from a DTO to an internal Spring bean definition.
 * 
 * @param beanDefinitionDto The DTO object.
 * @return Returns a Spring bean definition.
 */
public BeanDefinition toInternal(BeanDefinitionInfo beanDefinitionInfo) {
	if (beanDefinitionInfo instanceof GenericBeanDefinitionInfo) {
		GenericBeanDefinitionInfo genericInfo = (GenericBeanDefinitionInfo) beanDefinitionInfo;
		GenericBeanDefinition def = new GenericBeanDefinition();
		def.setBeanClassName(genericInfo.getClassName());
		if (genericInfo.getPropertyValues() != null) {
			MutablePropertyValues propertyValues = new MutablePropertyValues();
			for (Entry<String, BeanMetadataElementInfo> entry : genericInfo.getPropertyValues().entrySet()) {
				BeanMetadataElementInfo info = entry.getValue();
				propertyValues.add(entry.getKey(), toInternal(info));
			}
			def.setPropertyValues(propertyValues);
		}
		return def;
	} else if (beanDefinitionInfo instanceof ObjectBeanDefinitionInfo) {
		ObjectBeanDefinitionInfo objectInfo = (ObjectBeanDefinitionInfo) beanDefinitionInfo;
		return createBeanDefinitionByIntrospection(objectInfo.getObject());
	} else {
		throw new IllegalArgumentException("Conversion to internal of " + beanDefinitionInfo.getClass().getName()
				+ " not implemented");
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:29,代码来源:BeanDefinitionDtoConverterServiceImpl.java

示例3: createBeanDefinitionByIntrospection

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private BeanDefinition createBeanDefinitionByIntrospection(Object object, NamedBeanMap refs,
		ConversionService conversionService) {
	validate(object);
	GenericBeanDefinition def = new GenericBeanDefinition();
	def.setBeanClass(object.getClass());
	MutablePropertyValues propertyValues = new MutablePropertyValues();
	for (PropertyDescriptor descriptor : BeanUtils.getPropertyDescriptors(object.getClass())) {
		if (descriptor.getWriteMethod() != null) {
			try {
				Object value = descriptor.getReadMethod().invoke(object, (Object[]) null);
				if (value != null) {
					if ("id".equals(descriptor.getName())) {

					} else {
						propertyValues.addPropertyValue(descriptor.getName(),
								createMetadataElementByIntrospection(value, refs, conversionService));
					}
				}
			} catch (Exception e) {
				// our contract says to ignore this property
			}
		}
	}
	def.setPropertyValues(propertyValues);
	return def;
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:27,代码来源:BeanDefinitionDtoConverterServiceImpl.java

示例4: createBeans

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<BeanDefinitionHolder> createBeans(Map<String, Object> parameters) throws RuntimeConfigException {
	GenericBeanDefinition def = new GenericBeanDefinition();
	def.setBeanClassName(className);
	MutablePropertyValues propertyValues = new MutablePropertyValues();
	List<NamedObject> namedObjects = new ArrayList<NamedObject>();
	if (checkCollection(BEAN_REFS, NamedObject.class, parameters) != Priority.NONE) {
		namedObjects.addAll((Collection) parameters.get(BEAN_REFS));
	}
	for (String name : parameters.keySet()) {
		if (!ignoredParams.contains(name)) {
			propertyValues.addPropertyValue(name, beanDefinitionDtoConverterService
					.createBeanMetadataElementByIntrospection(parameters.get(name), namedObjects));
		}
	}
	def.setPropertyValues(propertyValues);
	BeanDefinitionHolder holder = new BeanDefinitionHolder(def, (String) parameters.get(BEAN_NAME));
	List<BeanDefinitionHolder> holders = new ArrayList<BeanDefinitionHolder>();
	holders.add(holder);
	return holders;
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:22,代码来源:BaseBeanFactory.java

示例5: registerWithServer

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@PostConstruct
public void registerWithServer() {
	AutowireCapableBeanFactory factory = context
			.getAutowireCapableBeanFactory();
	BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory;
	GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setBeanClass(RmiServiceExporter.class);
	beanDefinition.setAutowireCandidate(true);

	MutablePropertyValues propertyValues = new MutablePropertyValues();

	Class<?> serviceInterface = this.getClass().getInterfaces()[0];

	propertyValues.addPropertyValue("serviceInterface", serviceInterface);
	String serviceName = serviceInterface.getCanonicalName();
	propertyValues.addPropertyValue("serviceName", serviceName);
	propertyValues.addPropertyValue("service", this);
	propertyValues.addPropertyValue("registryPort", "1099");
	beanDefinition.setPropertyValues(propertyValues);

	registry.registerBeanDefinition(serviceName, beanDefinition);
	context.getBean(serviceName); // Need this else
									// NotBoundException
	getService().registerClient(getHostAddress());

}
 
开发者ID:DevOpsDistilled,项目名称:OpERP,代码行数:27,代码来源:AbstractEntityModel.java

示例6: registryMangoDao

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * 向spring中注入dao代理
 * @param beanFactory
 */
private void registryMangoDao(DefaultListableBeanFactory beanFactory){
    for (Class<?> daoClass : findMangoDaoClasses(config.getScanPackage())) {
        GenericBeanDefinition bf = new GenericBeanDefinition();
        bf.setBeanClassName(daoClass.getName());
        MutablePropertyValues pvs = bf.getPropertyValues();
        pvs.addPropertyValue("daoClass", daoClass);
        bf.setBeanClass(factoryBeanClass);
        bf.setPropertyValues(pvs);
        bf.setLazyInit(false);
        beanFactory.registerBeanDefinition(daoClass.getName(), bf);
    }
}
 
开发者ID:jfaster,项目名称:mango-spring-boot-starter,代码行数:17,代码来源:MangoDaoAutoCreator.java

示例7: createBeanReferenceDefinition

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private AbstractBeanDefinition createBeanReferenceDefinition(String beanName, BeanDefinition actualDef) {
	GenericBeanDefinition def = new GenericBeanDefinition();
	def.setBeanClass(BeanReferenceFactoryBean.class);
	def.setAttribute(GENERATED_REF, Boolean.TRUE);
	def.setOriginatingBeanDefinition(actualDef);
	def.setDependsOn(new String[] { beanName });
	def.setSynthetic(true);
	MutablePropertyValues mpv = new MutablePropertyValues();
	mpv.addPropertyValue(TARGET_BEAN_NAME_PROP, beanName);
	def.setPropertyValues(mpv);
	return def;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:13,代码来源:AbstractReferenceDefinitionParser.java

示例8: registerSingleton

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * Register a singleton bean with the underlying bean factory.
 * <p>For more advanced needs, register with the underlying BeanFactory directly.
 * @see #getDefaultListableBeanFactory
 */
public void registerSingleton(String name, Class<?> clazz, MutablePropertyValues pvs) throws BeansException {
	GenericBeanDefinition bd = new GenericBeanDefinition();
	bd.setBeanClass(clazz);
	bd.setPropertyValues(pvs);
	getDefaultListableBeanFactory().registerBeanDefinition(name, bd);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:StaticApplicationContext.java

示例9: registerPrototype

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * Register a prototype bean with the underlying bean factory.
 * <p>For more advanced needs, register with the underlying BeanFactory directly.
 * @see #getDefaultListableBeanFactory
 */
public void registerPrototype(String name, Class<?> clazz, MutablePropertyValues pvs) throws BeansException {
	GenericBeanDefinition bd = new GenericBeanDefinition();
	bd.setScope(GenericBeanDefinition.SCOPE_PROTOTYPE);
	bd.setBeanClass(clazz);
	bd.setPropertyValues(pvs);
	getDefaultListableBeanFactory().registerBeanDefinition(name, bd);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:StaticApplicationContext.java

示例10: createBeanDefinition

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private BeanDefinition createBeanDefinition(Class<?> beanType) {
	GenericBeanDefinition beanDef = new GenericBeanDefinition();
	beanDef.setBeanClass(beanType);

	MutablePropertyValues values = new MutablePropertyValues();
	beanDef.setPropertyValues(values);
	
	return beanDef;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:10,代码来源:AbstractStoreBeanDefinitionRegistrar.java

示例11: registerSingleton

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * Register a singleton bean with the underlying bean factory.
 * <p>For more advanced needs, register with the underlying BeanFactory directly.
 * @see #getDefaultListableBeanFactory
 */
public void registerSingleton(String name, Class clazz, MutablePropertyValues pvs) throws BeansException {
	GenericBeanDefinition bd = new GenericBeanDefinition();
	bd.setBeanClass(clazz);
	bd.setPropertyValues(pvs);
	getDefaultListableBeanFactory().registerBeanDefinition(name, bd);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:12,代码来源:StaticApplicationContext.java

示例12: registerPrototype

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * Register a prototype bean with the underlying bean factory.
 * <p>For more advanced needs, register with the underlying BeanFactory directly.
 * @see #getDefaultListableBeanFactory
 */
public void registerPrototype(String name, Class clazz, MutablePropertyValues pvs) throws BeansException {
	GenericBeanDefinition bd = new GenericBeanDefinition();
	bd.setScope(GenericBeanDefinition.SCOPE_PROTOTYPE);
	bd.setBeanClass(clazz);
	bd.setPropertyValues(pvs);
	getDefaultListableBeanFactory().registerBeanDefinition(name, bd);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:13,代码来源:StaticApplicationContext.java

示例13: registerMockFactoryBeanForField

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private void registerMockFactoryBeanForField(final BeanDefinitionRegistry registry, final FieldDefinition fieldDef) {
	GenericBeanDefinition mockFactoryBeanDefinition = new GenericBeanDefinition();
	mockFactoryBeanDefinition.setBeanClass(MockFactoryBean.class);
	MutablePropertyValues values = new MutablePropertyValues();
	values.addPropertyValue(new PropertyValue("type", fieldDef.type));
	mockFactoryBeanDefinition.setPropertyValues(values);

	registry.registerBeanDefinition(fieldDef.name, mockFactoryBeanDefinition);
}
 
开发者ID:rinoto,项目名称:spring-auto-mock,代码行数:10,代码来源:AutoMockRegistryPostProcessor.java

示例14: getDefinition

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private GenericBeanDefinition getDefinition(String serverName, String url, String userName, String password){
	GenericBeanDefinition sessionFactoryDef = new GenericBeanDefinition();
	Map<String, Object> paramData = new HashMap<String, Object>();
	paramData.put("driverClassName" ,"com.mysql.jdbc.Driver");
	paramData.put("url",url);
	paramData.put("username" ,userName);
	paramData.put("password" ,password);
	paramData.put("initialSize" ,5);
	paramData.put("maxActive" ,20);
	paramData.put("maxIdle",10);
	sessionFactoryDef.setBeanClass(BasicDataSource.class);
	sessionFactoryDef.setPropertyValues(new MutablePropertyValues(paramData));
	return sessionFactoryDef;
}
 
开发者ID:youngor,项目名称:openclouddb,代码行数:15,代码来源:MonitorService.java

示例15: createBeanReferenceDefinition

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private AbstractBeanDefinition createBeanReferenceDefinition(String beanName) {
	GenericBeanDefinition def = new GenericBeanDefinition();
	def.setBeanClass(BeanReferenceFactoryBean.class);
	def.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	MutablePropertyValues mpv = new MutablePropertyValues();
	mpv.addPropertyValue(TARGET_BEAN_NAME_PROP, beanName);
	def.setPropertyValues(mpv);
	return def;
}
 
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:10,代码来源:AbstractReferenceDefinitionParser.java


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