本文整理汇总了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;
}
示例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");
}
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}