本文整理汇总了Java中org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder方法的典型用法代码示例。如果您正苦于以下问题:Java ConstructorArgumentValues.ValueHolder方法的具体用法?Java ConstructorArgumentValues.ValueHolder怎么用?Java ConstructorArgumentValues.ValueHolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.config.ConstructorArgumentValues
的用法示例。
在下文中一共展示了ConstructorArgumentValues.ValueHolder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addConstructorArgs
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
public void addConstructorArgs(Object value, Class type, BeanDefinition bd) {
ConstructorArgumentValues.ValueHolder vHolder
= new ConstructorArgumentValues.ValueHolder(value, type.getName());
ConstructorArgumentValues args
= bd.getConstructorArgumentValues();
args.addIndexedArgumentValue(args.getArgumentCount(), vHolder);
}
示例2: updateEntityScanBeanPostProcessor
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
private void updateEntityScanBeanPostProcessor(BeanDefinitionRegistry registry,
Set<String> packagesToScan) {
BeanDefinition definition = registry
.getBeanDefinition(this.beanPostProcessorName);
ConstructorArgumentValues.ValueHolder constructorArguments = definition
.getConstructorArgumentValues().getGenericArgumentValue(String[].class);
Set<String> mergedPackages = new LinkedHashSet<String>();
mergedPackages.addAll(Arrays.asList((String[]) constructorArguments.getValue()));
mergedPackages.addAll(packagesToScan);
constructorArguments.setValue(toArray(mergedPackages));
}
示例3: parseConstructorArgElement
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
private void parseConstructorArgElement(Element ele, AbstractBeanDefinition beanDefinition) {
String indexAttr = ele.getAttribute(BeanDefinitionParserDelegate.INDEX_ATTRIBUTE);
String typeAttr = ele.getAttribute(BeanDefinitionParserDelegate.TYPE_ATTRIBUTE);
boolean hasIndex = false;
int index = -1;
if (StringUtils.hasLength(indexAttr)) {
hasIndex = true;
try {
index = Integer.parseInt(indexAttr);
} catch (NumberFormatException ex) {
error("Attribute 'index' of tag 'constructor-arg' must be an integer", ele);
}
if (index < 0) {
error("'index' cannot be lower than 0", ele);
}
}
try {
this.parseState.push(hasIndex ? new ConstructorArgumentEntry(index) : new ConstructorArgumentEntry());
ConstructorArgumentValues values = beanDefinition.getConstructorArgumentValues();
// Blueprint failure (index duplication)
Integer indexInt = Integer.valueOf(index);
if (values.getIndexedArgumentValues().containsKey(indexInt)) {
error("duplicate 'index' with value=[" + index + "] specified", ele);
}
Object value = parsePropertyValue(ele, beanDefinition, null);
ConstructorArgumentValues.ValueHolder valueHolder = new ConstructorArgumentValues.ValueHolder(value);
if (StringUtils.hasLength(typeAttr)) {
valueHolder.setType(typeAttr);
}
valueHolder.setSource(extractSource(ele));
if (hasIndex) {
values.addIndexedArgumentValue(index, valueHolder);
} else {
values.addGenericArgumentValue(valueHolder);
}
// Blueprint failure (mixed index/non-indexed arguments)
if (!values.getGenericArgumentValues().isEmpty() && !values.getIndexedArgumentValues().isEmpty()) {
error("indexed and non-indexed constructor arguments are not supported by Blueprint; "
+ "consider using the Spring namespace instead", ele);
}
} finally {
this.parseState.pop();
}
}