use of org.springframework.beans.factory.config.ConstructorArgumentValues in project grails-core by grails.
the class ChainedTransactionManagerPostProcessor method createTransactionManagerBeanReferences.
protected ManagedList<RuntimeBeanReference> createTransactionManagerBeanReferences(BeanDefinition chainedTransactionManagerBeanDefinition) {
ManagedList<RuntimeBeanReference> transactionManagerRefs = new ManagedList<RuntimeBeanReference>();
ConstructorArgumentValues constructorValues = chainedTransactionManagerBeanDefinition.getConstructorArgumentValues();
constructorValues.addIndexedArgumentValue(0, transactionManagerRefs);
transactionManagerRefs.add(new RuntimeBeanReference(PRIMARY_TRANSACTION_MANAGER));
return transactionManagerRefs;
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues in project grails-core by grails.
the class DefaultBeanConfiguration method createBeanDefinition.
protected AbstractBeanDefinition createBeanDefinition() {
AbstractBeanDefinition bd = new GenericBeanDefinition();
if (!constructorArgs.isEmpty()) {
ConstructorArgumentValues cav = new ConstructorArgumentValues();
for (Object constructorArg : constructorArgs) {
cav.addGenericArgumentValue(constructorArg);
}
bd.setConstructorArgumentValues(cav);
}
if (clazz != null) {
bd.setLazyInit(clazz.getAnnotation(Lazy.class) != null);
bd.setBeanClass(clazz);
}
bd.setScope(singleton ? AbstractBeanDefinition.SCOPE_SINGLETON : AbstractBeanDefinition.SCOPE_PROTOTYPE);
if (parentName != null) {
bd.setParentName(parentName);
}
wrapper = new BeanWrapperImpl(bd);
return bd;
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues in project spring-framework by spring-projects.
the class InjectAnnotationAutowireContextTests method testAutowiredFieldWithMultipleNonQualifiedCandidates.
@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());
}
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues in project spring-framework by spring-projects.
the class InjectAnnotationAutowireContextTests method testAutowiredFieldWithSingleQualifiedCandidate.
@Test
public void testAutowiredFieldWithSingleQualifiedCandidate() {
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(QualifiedFieldTestBean.class));
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
context.refresh();
QualifiedFieldTestBean bean = (QualifiedFieldTestBean) context.getBean("autowired");
assertEquals(JUERGEN, bean.getPerson().getName());
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues in project spring-framework by spring-projects.
the class InjectAnnotationAutowireContextTests method testAutowiredConstructorArgumentWithSingleQualifiedCandidate.
@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());
}
Aggregations