use of org.springframework.beans.factory.config.ConstructorArgumentValues in project spring-framework by spring-projects.
the class QualifierAnnotationAutowireBeanFactoryTests method testAutowireCandidateWithMultipleCandidatesDescriptor.
@Test
public void testAutowireCandidateWithMultipleCandidatesDescriptor() throws Exception {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
cavs1.addGenericArgumentValue(JUERGEN);
RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
person1.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
lbf.registerBeanDefinition(JUERGEN, person1);
ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
cavs2.addGenericArgumentValue(MARK);
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
person2.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
lbf.registerBeanDefinition(MARK, person2);
DependencyDescriptor qualifiedDescriptor = new DependencyDescriptor(new MethodParameter(QualifiedTestBean.class.getDeclaredConstructor(Person.class), 0), false);
assertTrue(lbf.isAutowireCandidate(JUERGEN, qualifiedDescriptor));
assertTrue(lbf.isAutowireCandidate(MARK, qualifiedDescriptor));
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues in project ignite by apache.
the class GridFactorySelfTest method getTestApplicationContext.
/**
* Gets test Spring application context with single {@link StringBuilder} bean
* with name "myBean" and value "Test string".
*
* @return Spring application context.
*/
private ApplicationContext getTestApplicationContext() {
AbstractBeanDefinition def = new GenericBeanDefinition();
def.setBeanClass(StringBuilder.class);
ConstructorArgumentValues args = new ConstructorArgumentValues();
args.addGenericArgumentValue("Test string");
def.setConstructorArgumentValues(args);
GenericApplicationContext ctx = new GenericApplicationContext();
ctx.registerBeanDefinition("myBean", def);
return ctx;
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues in project spring-data-mongodb by spring-projects.
the class MongoDbFactoryParserIntegrationTests method setsUpMongoDbFactoryUsingAMongoClientUri.
// DATAMONGO-1218
@Test
public void setsUpMongoDbFactoryUsingAMongoClientUri() {
reader.loadBeanDefinitions(new ClassPathResource("namespace/mongo-client-uri.xml"));
BeanDefinition definition = factory.getBeanDefinition("mongoDbFactory");
ConstructorArgumentValues constructorArguments = definition.getConstructorArgumentValues();
assertThat(constructorArguments.getArgumentCount(), is(1));
ValueHolder argument = constructorArguments.getArgumentValue(0, MongoClientURI.class);
assertThat(argument, is(notNullValue()));
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues in project spring-data-mongodb by spring-projects.
the class MongoDbFactoryParserIntegrationTests method setsUpUriWithId.
// DATAMONGO-1293
@Test
public void setsUpUriWithId() {
reader.loadBeanDefinitions(new ClassPathResource("namespace/mongo-uri-and-id.xml"));
BeanDefinition definition = factory.getBeanDefinition("testMongo");
ConstructorArgumentValues constructorArguments = definition.getConstructorArgumentValues();
assertThat(constructorArguments.getArgumentCount(), is(1));
ValueHolder argument = constructorArguments.getArgumentValue(0, MongoClientURI.class);
assertThat(argument, is(notNullValue()));
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues in project cxf by apache.
the class BusWiringBeanFactoryPostProcessor method postProcessBeanFactory.
public void postProcessBeanFactory(ConfigurableListableBeanFactory factory) throws BeansException {
Object inject = bus;
if (inject == null) {
inject = getBusForName(Bus.DEFAULT_BUS_ID, factory, true, null);
} else {
if (!factory.containsBeanDefinition(Bus.DEFAULT_BUS_ID) && !factory.containsSingleton(Bus.DEFAULT_BUS_ID)) {
factory.registerSingleton(Bus.DEFAULT_BUS_ID, bus);
}
}
for (String beanName : factory.getBeanDefinitionNames()) {
BeanDefinition beanDefinition = factory.getBeanDefinition(beanName);
BusWiringType type = (BusWiringType) beanDefinition.getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE);
if (type == null) {
continue;
}
String busname = (String) beanDefinition.getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_NAME);
String create = (String) beanDefinition.getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_CREATE);
Object inj = inject;
if (busname != null) {
if (bus != null) {
continue;
}
inj = getBusForName(busname, factory, create != null, create);
}
beanDefinition.removeAttribute(AbstractBeanDefinitionParser.WIRE_BUS_NAME);
beanDefinition.removeAttribute(AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE);
beanDefinition.removeAttribute(AbstractBeanDefinitionParser.WIRE_BUS_CREATE);
if (create == null) {
if (BusWiringType.PROPERTY == type) {
beanDefinition.getPropertyValues().addPropertyValue("bus", inj);
} else if (BusWiringType.CONSTRUCTOR == type) {
ConstructorArgumentValues constructorArgs = beanDefinition.getConstructorArgumentValues();
insertConstructorArg(constructorArgs, inj);
}
}
}
}
Aggregations