本文整理匯總了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);
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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