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


Java ConstructorArgumentValues类代码示例

本文整理汇总了Java中org.springframework.beans.factory.config.ConstructorArgumentValues的典型用法代码示例。如果您正苦于以下问题:Java ConstructorArgumentValues类的具体用法?Java ConstructorArgumentValues怎么用?Java ConstructorArgumentValues使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setConfigBeanFactoryMethod

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
/**
 * 修改配置Bean定义,使用静态方法{@link ConfigBeanFactory#FACTORY_METHOD}来实例化。
 *
 * @param registry
 * @param beanName
 * @param beanDefinition
 * @param propertyName
 * @param converterType
 */
public static void setConfigBeanFactoryMethod(BeanDefinitionRegistry registry,
                                              String beanName, BeanDefinition beanDefinition,
                                              String propertyName, Class<?> converterType) {

    // 注册ConfigBeanPropertyResolver
    registerConfigBeanPropertyResolver(registry);

    // 注册ConfigBeanConversionService
    registerConfigBeanConversionService(registry);

    String beanClassName = beanDefinition.getBeanClassName();

    beanDefinition.setBeanClassName(ConfigBeanFactory.class.getName());
    beanDefinition.setFactoryMethodName(ConfigBeanFactory.FACTORY_METHOD);
    ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
    constructorArgumentValues.addGenericArgumentValue(propertyName, String.class.getName());
    constructorArgumentValues.addGenericArgumentValue(beanClassName, Class.class.getName());
    constructorArgumentValues.addGenericArgumentValue(converterType);
    constructorArgumentValues.addGenericArgumentValue(new RuntimeBeanReference(CONFIG_BEAN_PROPERTY_RESOLVER_BEAN_NAME));
    constructorArgumentValues.addGenericArgumentValue(new RuntimeBeanReference(CONFIG_BEAN_CONVERSION_SERVICE_BEAN_NAME));
    beanDefinition.getConstructorArgumentValues().addArgumentValues(constructorArgumentValues);
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:32,代码来源:ConfigBeanConfigUtils.java

示例2: getDefaultKeyValueTemplateBeanDefinition

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
@Override
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(
        RepositoryConfigurationSource configurationSource) {
    RootBeanDefinition keyValueTemplateDefinition = new RootBeanDefinition(TarantoolKeyValueTemplate.class);

    ConstructorArgumentValues constructorArgumentValuesForKeyValueTemplate = new ConstructorArgumentValues();
    constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(0,
            new RuntimeBeanReference(TARANTOOL_OPS_IMPL_BEAN_NAME));
    constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(1,
            new RuntimeBeanReference(MAPPING_CONTEXT_BEAN_NAME));
    constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(2,
            new RuntimeBeanReference(TARANTOOL_CONVERTER_BEAN_NAME));

    keyValueTemplateDefinition.setConstructorArgumentValues(constructorArgumentValuesForKeyValueTemplate);

    return keyValueTemplateDefinition;
}
 
开发者ID:saladinkzn,项目名称:spring-data-tarantool,代码行数:18,代码来源:TarantoolRepositoryConfigurationExtension.java

示例3: getBeanArguments

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的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);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:27,代码来源:MetadataUtils.java

示例4: postProcessBeanFactory

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

		boolean trace = log.isTraceEnabled();

		String[] names = beanFactory.getBeanDefinitionNames();
		for (String name : names) {
			BeanDefinition definition = beanFactory.getBeanDefinition(name);
			if (definition.hasAttribute(ParsingUtils.BLUEPRINT_MARKER_NAME)) {
				ConstructorArgumentValues cArgs = definition.getConstructorArgumentValues();
				if (trace)
					log.trace("Inspecting cycles for (blueprint) bean " + name);

				tag(cArgs.getGenericArgumentValues(), name, definition);
				tag(cArgs.getIndexedArgumentValues().values(), name, definition);
			}
		}
	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:CycleOrderingProcessor.java

示例5: createBeanDefinition

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:GroovyBeanDefinitionWrapper.java

示例6: testAutowiredFieldWithSingleNonQualifiedCandidate

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
@Test
public void testAutowiredFieldWithSingleNonQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
	context.registerBeanDefinition(JUERGEN, person);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedFieldTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	try {
		context.refresh();
		fail("expected BeanCreationException");
	}
	catch (BeanCreationException e) {
		assertTrue(e.getRootCause() instanceof NoSuchBeanDefinitionException);
		assertEquals("autowired", e.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:QualifierAnnotationAutowireContextTests.java

示例7: testAutowiredMethodParameterWithSingleNonQualifiedCandidate

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
@Test
public void testAutowiredMethodParameterWithSingleNonQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
	context.registerBeanDefinition(JUERGEN, person);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	try {
		context.refresh();
		fail("expected BeanCreationException");
	}
	catch (BeanCreationException e) {
		assertTrue(e.getRootCause() instanceof NoSuchBeanDefinitionException);
		assertEquals("autowired", e.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:QualifierAnnotationAutowireContextTests.java

示例8: testAutowiredConstructorArgumentWithSingleNonQualifiedCandidate

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
@Test
public void testAutowiredConstructorArgumentWithSingleNonQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
	context.registerBeanDefinition(JUERGEN, person);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	try {
		context.refresh();
		fail("expected BeanCreationException");
	}
	catch (BeanCreationException e) {
		assertTrue(e instanceof UnsatisfiedDependencyException);
		assertEquals("autowired", e.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:QualifierAnnotationAutowireContextTests.java

示例9: testAutowiredMethodParameterWithSingleQualifiedCandidate

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
@Test
public void testAutowiredMethodParameterWithSingleQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
	person.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
	context.registerBeanDefinition(JUERGEN, person);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	context.refresh();
	QualifiedMethodParameterTestBean bean =
			(QualifiedMethodParameterTestBean) context.getBean("autowired");
	assertEquals(JUERGEN, bean.getPerson().getName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:QualifierAnnotationAutowireContextTests.java

示例10: testAutowiredMethodParameterWithStaticallyQualifiedCandidate

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
@Test
public void testAutowiredMethodParameterWithStaticallyQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(QualifiedPerson.class, cavs, null);
	context.registerBeanDefinition(JUERGEN,
			ScopedProxyUtils.createScopedProxy(new BeanDefinitionHolder(person, JUERGEN), context, true).getBeanDefinition());
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	context.refresh();
	QualifiedMethodParameterTestBean bean =
			(QualifiedMethodParameterTestBean) context.getBean("autowired");
	assertEquals(JUERGEN, bean.getPerson().getName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:QualifierAnnotationAutowireContextTests.java

示例11: testAutowiredMethodParameterWithStaticallyQualifiedCandidateAmongOthers

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
@Test
public void testAutowiredMethodParameterWithStaticallyQualifiedCandidateAmongOthers() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(QualifiedPerson.class, cavs, null);
	ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
	cavs2.addGenericArgumentValue(MARK);
	RootBeanDefinition person2 = new RootBeanDefinition(DefaultValueQualifiedPerson.class, cavs2, null);
	context.registerBeanDefinition(JUERGEN, person);
	context.registerBeanDefinition(MARK, person2);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	context.refresh();
	QualifiedMethodParameterTestBean bean =
			(QualifiedMethodParameterTestBean) context.getBean("autowired");
	assertEquals(JUERGEN, bean.getPerson().getName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:QualifierAnnotationAutowireContextTests.java

示例12: testAutowiredConstructorArgumentWithSingleQualifiedCandidate

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
@Test
public void testAutowiredConstructorArgumentWithSingleQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
	person.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
	context.registerBeanDefinition(JUERGEN, person);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	context.refresh();
	QualifiedConstructorArgumentTestBean bean =
			(QualifiedConstructorArgumentTestBean) context.getBean("autowired");
	assertEquals(JUERGEN, bean.getPerson().getName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:QualifierAnnotationAutowireContextTests.java

示例13: testAutowiredFieldWithMultipleNonQualifiedCandidates

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
@Test
public void testAutowiredFieldWithMultipleNonQualifiedCandidates() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
	cavs1.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
	ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
	cavs2.addGenericArgumentValue(MARK);
	RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
	context.registerBeanDefinition(JUERGEN, person1);
	context.registerBeanDefinition(MARK, person2);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedFieldTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	try {
		context.refresh();
		fail("expected BeanCreationException");
	}
	catch (BeanCreationException e) {
		assertTrue(e.getRootCause() instanceof NoSuchBeanDefinitionException);
		assertEquals("autowired", e.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:QualifierAnnotationAutowireContextTests.java

示例14: testAutowiredMethodParameterWithMultipleNonQualifiedCandidates

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
@Test
public void testAutowiredMethodParameterWithMultipleNonQualifiedCandidates() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
	cavs1.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
	ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
	cavs2.addGenericArgumentValue(MARK);
	RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
	context.registerBeanDefinition(JUERGEN, person1);
	context.registerBeanDefinition(MARK, person2);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	try {
		context.refresh();
		fail("expected BeanCreationException");
	}
	catch (BeanCreationException e) {
		assertTrue(e.getRootCause() instanceof NoSuchBeanDefinitionException);
		assertEquals("autowired", e.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:QualifierAnnotationAutowireContextTests.java

示例15: testAutowiredConstructorArgumentWithMultipleNonQualifiedCandidates

import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入依赖的package包/类
@Test
public void testAutowiredConstructorArgumentWithMultipleNonQualifiedCandidates() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
	cavs1.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
	ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
	cavs2.addGenericArgumentValue(MARK);
	RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
	context.registerBeanDefinition(JUERGEN, person1);
	context.registerBeanDefinition(MARK, person2);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	try {
		context.refresh();
		fail("expected BeanCreationException");
	}
	catch (BeanCreationException e) {
		assertTrue(e instanceof UnsatisfiedDependencyException);
		assertEquals("autowired", e.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:QualifierAnnotationAutowireContextTests.java


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