本文整理汇总了Java中org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder类的典型用法代码示例。如果您正苦于以下问题:Java ValueHolder类的具体用法?Java ValueHolder怎么用?Java ValueHolder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ValueHolder类属于org.springframework.beans.factory.config.ConstructorArgumentValues包,在下文中一共展示了ValueHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBeanArguments
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
static List<BeanArgument> getBeanArguments(BeanDefinition definition) {
List<BeanArgument> temp;
ConstructorArgumentValues ctorValues = definition.getConstructorArgumentValues();
// get indexed values
Map<Integer, ValueHolder> indexedArguments = ctorValues.getIndexedArgumentValues();
// check first the indexed arguments
if (!indexedArguments.isEmpty()) {
temp = new ArrayList<BeanArgument>(indexedArguments.size());
for (Map.Entry<Integer, ValueHolder> entry : indexedArguments.entrySet()) {
temp.add(new SimpleBeanArgument(entry.getKey(), entry.getValue()));
}
} else {
// followed by the generic arguments
List<ValueHolder> args = ctorValues.getGenericArgumentValues();
temp = new ArrayList<BeanArgument>(args.size());
for (ValueHolder valueHolder : args) {
temp.add(new SimpleBeanArgument(valueHolder));
}
}
return Collections.unmodifiableList(temp);
}
示例2: tag
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
private void tag(Collection<ValueHolder> values, String name, BeanDefinition definition) {
boolean trace = log.isTraceEnabled();
for (ValueHolder value : values) {
Object val = value.getValue();
if (val instanceof BeanMetadataElement) {
if (val instanceof RuntimeBeanReference) {
String beanName = ((RuntimeBeanReference) val).getBeanName();
if (trace) {
log.trace("Adding (cycle breaking) depends-on on " + name + " to " + beanName);
}
addSyntheticDependsOn(definition, beanName);
}
}
}
}
示例3: testConstructorArg
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
public void testConstructorArg() throws Exception {
AbstractBeanDefinition def = (AbstractBeanDefinition) context.getBeanDefinition("constructor-arg");
assertEquals(Integer.class.getName(), def.getBeanClassName());
assertEquals("description", def.getDescription());
ValueHolder argumentValue = def.getConstructorArgumentValues().getArgumentValue(0, int.class);
assertNotNull(argumentValue);
}
示例4: checkName
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
private boolean checkName(String name, Collection<ValueHolder> values) {
for (ValueHolder holder : values) {
if (name.equals(holder.getName())) {
return true;
}
}
return false;
}
示例5: updatePostProcessor
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
private void updatePostProcessor(BeanDefinitionRegistry registry, Set<String> packagesToScan) {
BeanDefinition definition = registry.getBeanDefinition(BEAN_NAME);
ValueHolder constructorArguments = definition.getConstructorArgumentValues().getGenericArgumentValue(Set.class);
@SuppressWarnings("unchecked")
Set<String> mergedPackages = (Set<String>) constructorArguments.getValue();
mergedPackages.addAll(packagesToScan);
constructorArguments.setValue(mergedPackages);
}
开发者ID:PebbleTemplates,项目名称:pebble-spring-boot-starter,代码行数:9,代码来源:ServletComponentScanRegistrar.java
示例6: updatePostProcessor
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
private void updatePostProcessor(BeanDefinitionRegistry registry,
Set<String> packagesToScan) {
BeanDefinition definition = registry.getBeanDefinition(BEAN_NAME);
ValueHolder constructorArguments = definition.getConstructorArgumentValues()
.getGenericArgumentValue(Set.class);
@SuppressWarnings("unchecked")
Set<String> mergedPackages = (Set<String>) constructorArguments.getValue();
mergedPackages.addAll(packagesToScan);
constructorArguments.setValue(mergedPackages);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:ServletComponentScanRegistrar.java
示例7: updateEntityScanBeanPostProcessor
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
private void updateEntityScanBeanPostProcessor(BeanDefinitionRegistry registry,
Set<String> packagesToScan) {
BeanDefinition definition = registry.getBeanDefinition(BEAN_NAME);
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));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:EntityScanRegistrar.java
示例8: register
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
/**
* Register the processor with a {@link BeanDefinitionRegistry}. Not required when
* using the {@link SpringRunner} as registration is automatic.
* @param registry the bean definition registry
* @param postProcessor the post processor class to register
* @param definitions the initial mock/spy definitions
*/
@SuppressWarnings("unchecked")
public static void register(BeanDefinitionRegistry registry,
Class<? extends MockitoPostProcessor> postProcessor,
Set<Definition> definitions) {
SpyPostProcessor.register(registry);
BeanDefinition definition = getOrAddBeanDefinition(registry, postProcessor);
ValueHolder constructorArg = definition.getConstructorArgumentValues()
.getIndexedArgumentValue(0, Set.class);
Set<Definition> existing = (Set<Definition>) constructorArg.getValue();
if (definitions != null) {
existing.addAll(definitions);
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:21,代码来源:MockitoPostProcessor.java
示例9: findBeanType
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
private Type findBeanType(AbstractBeanDefinition definition,
MethodMetadataReadingVisitor visitor) {
Class<?> factory = ClassUtils
.resolveClassName(visitor.getDeclaringClassName(), null);
List<Class<?>> params = new ArrayList<>();
for (ValueHolder holder : definition.getConstructorArgumentValues()
.getIndexedArgumentValues().values()) {
params.add(ClassUtils.resolveClassName(holder.getType(), null));
}
Method method = ReflectionUtils.findMethod(factory, visitor.getMethodName(),
params.toArray(new Class<?>[0]));
Type type = method.getGenericReturnType();
return type;
}
开发者ID:spring-cloud,项目名称:spring-cloud-function,代码行数:15,代码来源:ContextFunctionCatalogAutoConfiguration.java
示例10: testDoParseElementBeanDefinitionBuilder
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
/**
* JAVADOC Method Level Comments
*/
@Test
public void testDoParseElementBeanDefinitionBuilder() {
Element element = mock(Element.class);
when(element.getAttribute(SingletonBeanFactory.INSTANCE_FACTORY_ID)).thenReturn("exex");
when(element.getAttribute("tokenRepository")).thenReturn("hoho");
when(element.getAttribute("tokenClass")).thenReturn("pipi");
BeanDefinitionBuilder builder = mock(BeanDefinitionBuilder.class);
when(builder.addConstructorArgReference("exex")).thenReturn(builder);
when(builder.addConstructorArgReference("hoho")).thenReturn(builder);
when(builder.addConstructorArgReference("pipi")).thenReturn(builder);
AbstractBeanDefinition abd = mock(AbstractBeanDefinition.class);
ConstructorArgumentValues cav = mock(ConstructorArgumentValues.class);
cav.addGenericArgumentValue(any(ValueHolder.class));
cav.addGenericArgumentValue(any(ValueHolder.class));
cav.addGenericArgumentValue(any(ValueHolder.class));
when(abd.getConstructorArgumentValues()).thenReturn(cav);
when(builder.getRawBeanDefinition()).thenReturn(abd);
parser.doParse(element, builder);
}
示例11: parseBeanDefinition
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
private ObjectConfiguration parseBeanDefinition(BeanDefinition beanDefinition)
{
LOGGER.debug("Resource description : " + beanDefinition.getResourceDescription());
ObjectConfiguration objectConfiguration = objectConfigurationFactory.createObjectConfiguration();
objectConfiguration.setClassName(hashHelper.hashClassName(beanDefinition.getBeanClassName()));
objectConfiguration.setSingleton(beanDefinition.isSingleton());
Map<String, ElementConfiguration> fields = new LinkedHashMap<String, ElementConfiguration>();
objectConfiguration.setFields(fields);
for (PropertyValue ppt : beanDefinition.getPropertyValues().getPropertyValueList())
{
try
{
ElementConfiguration fieldConfiguration = beanPropertyParser.parseProperty(ppt.getValue());
fields.put(hashHelper.hashFieldName(beanDefinition.getBeanClassName(), ppt.getName()),
fieldConfiguration);
}
catch (Exception e)
{
LOGGER.error("The value " + ppt.getValue() + " of property " + ppt + " cannot be parsed", e);
}
}
List<ElementConfiguration> constructorArguments = new ArrayList<ElementConfiguration>();
objectConfiguration.setConstructorArguments(constructorArguments);
for (ValueHolder va : beanDefinition.getConstructorArgumentValues().getGenericArgumentValues())
{
ElementConfiguration constructorAgrument = beanPropertyParser.parseProperty(va.getValue());
constructorArguments.add(constructorAgrument);
}
return objectConfiguration;
}
示例12: getValue
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
static Object getValue(ValueHolder valueHolder) {
// return (valueHolder.isConverted() ? valueHolder.getConvertedValue() : valueHolder.getValue());
return valueHolder.getValue();
}
示例13: SimpleBeanArgument
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
public SimpleBeanArgument(ValueHolder valueHolder) {
this(UNSPECIFIED_INDEX, valueHolder);
}
示例14: decorate
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
if (node instanceof Attr) {
Attr attr = (Attr) node;
String argName = StringUtils.trimWhitespace(parserContext.getDelegate().getLocalName(attr));
String argValue = StringUtils.trimWhitespace(attr.getValue());
ConstructorArgumentValues cvs = definition.getBeanDefinition().getConstructorArgumentValues();
boolean ref = false;
// handle -ref arguments
if (argName.endsWith(REF_SUFFIX)) {
ref = true;
argName = argName.substring(0, argName.length() - REF_SUFFIX.length());
}
ValueHolder valueHolder = new ValueHolder(ref ? new RuntimeBeanReference(argValue) : argValue);
valueHolder.setSource(parserContext.getReaderContext().extractSource(attr));
// handle "escaped"/"_" arguments
if (argName.startsWith(DELIMITER_PREFIX)) {
String arg = argName.substring(1).trim();
// fast default check
if (!StringUtils.hasText(arg)) {
cvs.addGenericArgumentValue(valueHolder);
}
// assume an index otherwise
else {
int index = -1;
try {
index = Integer.parseInt(arg);
} catch (NumberFormatException ex) {
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' specifies an invalid integer", attr);
}
if (index < 0) {
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' specifies a negative index", attr);
}
if (cvs.hasIndexedArgumentValue(index)){
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' with index "+ index+" already defined using <constructor-arg>." +
" Only one approach may be used per argument.", attr);
}
cvs.addIndexedArgumentValue(index, valueHolder);
}
}
// no escaping -> ctr name
else {
String name = Conventions.attributeNameToPropertyName(argName);
if (containsArgWithName(name, cvs)){
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' already defined using <constructor-arg>." +
" Only one approach may be used per argument.", attr);
}
valueHolder.setName(Conventions.attributeNameToPropertyName(argName));
cvs.addGenericArgumentValue(valueHolder);
}
}
return definition;
}
示例15: decorate
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入依赖的package包/类
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
if (node instanceof Attr) {
Attr attr = (Attr) node;
String argName = StringUtils.trimWhitespace(parserContext.getDelegate().getLocalName(attr));
String argValue = StringUtils.trimWhitespace(attr.getValue());
ConstructorArgumentValues cvs = definition.getBeanDefinition().getConstructorArgumentValues();
boolean ref = false;
// handle -ref arguments
if (argName.endsWith(REF_SUFFIX)) {
ref = true;
argName = argName.substring(0, argName.length() - REF_SUFFIX.length());
}
ValueHolder valueHolder = new ValueHolder(ref ? new RuntimeBeanReference(argValue) : argValue);
valueHolder.setSource(parserContext.getReaderContext().extractSource(attr));
// handle "escaped"/"_" arguments
if (argName.startsWith(DELIMITER_PREFIX)) {
String arg = argName.substring(1).trim();
// fast default check
if (!StringUtils.hasText(arg)) {
cvs.addGenericArgumentValue(valueHolder);
}
// assume an index otherwise
else {
int index = -1;
try {
index = Integer.parseInt(arg);
}
catch (NumberFormatException ex) {
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' specifies an invalid integer", attr);
}
if (index < 0) {
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' specifies a negative index", attr);
}
if (cvs.hasIndexedArgumentValue(index)){
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' with index "+ index+" already defined using <constructor-arg>." +
" Only one approach may be used per argument.", attr);
}
cvs.addIndexedArgumentValue(index, valueHolder);
}
}
// no escaping -> ctr name
else {
String name = Conventions.attributeNameToPropertyName(argName);
if (containsArgWithName(name, cvs)){
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' already defined using <constructor-arg>." +
" Only one approach may be used per argument.", attr);
}
valueHolder.setName(Conventions.attributeNameToPropertyName(argName));
cvs.addGenericArgumentValue(valueHolder);
}
}
return definition;
}