use of org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder in project spring-integration by spring-projects.
the class AbstractConsumerEndpointParser method registerChannelForCreation.
private void registerChannelForCreation(ParserContext parserContext, String inputChannelName) {
if (parserContext.getRegistry().containsBeanDefinition(IntegrationContextUtils.AUTO_CREATE_CHANNEL_CANDIDATES_BEAN_NAME)) {
BeanDefinition channelRegistry = parserContext.getRegistry().getBeanDefinition(IntegrationContextUtils.AUTO_CREATE_CHANNEL_CANDIDATES_BEAN_NAME);
ConstructorArgumentValues caValues = channelRegistry.getConstructorArgumentValues();
ValueHolder vh = caValues.getArgumentValue(0, Collection.class);
if (vh == null) {
// although it should never happen if it does we can fix it
caValues.addIndexedArgumentValue(0, new ManagedSet<String>());
}
@SuppressWarnings("unchecked") Collection<String> channelCandidateNames = (Collection<String>) caValues.getArgumentValue(0, Collection.class).getValue();
// NOSONAR
channelCandidateNames.add(inputChannelName);
} else {
parserContext.getReaderContext().error("Failed to locate '" + IntegrationContextUtils.AUTO_CREATE_CHANNEL_CANDIDATES_BEAN_NAME + "'", parserContext.getRegistry());
}
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder in project spock by spockframework.
the class SpockMockPostprocessor method register.
/**
* Register the processor with a {@link BeanDefinitionRegistry}. Not required when
* using the Spocks {@link spock.lang.Specification} 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")
static void register(BeanDefinitionRegistry registry, Class<? extends SpockMockPostprocessor> 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);
}
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder in project spring-boot by spring-projects.
the class MockitoPostProcessor method register.
/**
* 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);
}
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder in project spring-data-mongodb by spring-projects.
the class MongoDbFactoryParserIntegrationTests method setsUpMongoDbFactoryUsingAMongoUriWithoutCredentials.
// DATAMONGO-306
@Test
public void setsUpMongoDbFactoryUsingAMongoUriWithoutCredentials() {
reader.loadBeanDefinitions(new ClassPathResource("namespace/mongo-uri-no-credentials.xml"));
BeanDefinition definition = factory.getBeanDefinition("mongoDbFactory");
ConstructorArgumentValues constructorArguments = definition.getConstructorArgumentValues();
assertThat(constructorArguments.getArgumentCount()).isOne();
ValueHolder argument = constructorArguments.getArgumentValue(0, ConnectionString.class);
assertThat(argument).isNotNull();
MongoDatabaseFactory dbFactory = factory.getBean("mongoDbFactory", MongoDatabaseFactory.class);
MongoDatabase db = dbFactory.getMongoDatabase();
assertThat(db.getName()).isEqualTo("database");
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder in project spring-data-mongodb by spring-projects.
the class MongoDbFactoryParserIntegrationTests method setsUpClientUriWithId.
// DATAMONGO-1293
@Test
public void setsUpClientUriWithId() {
reader.loadBeanDefinitions(new ClassPathResource("namespace/mongo-client-uri-and-id.xml"));
BeanDefinition definition = factory.getBeanDefinition("testMongo");
ConstructorArgumentValues constructorArguments = definition.getConstructorArgumentValues();
assertThat(constructorArguments.getArgumentCount()).isOne();
ValueHolder argument = constructorArguments.getArgumentValue(0, ConnectionString.class);
assertThat(argument).isNotNull();
}
Aggregations