本文整理汇总了Java中org.springframework.beans.factory.config.ConstructorArgumentValues.addIndexedArgumentValue方法的典型用法代码示例。如果您正苦于以下问题:Java ConstructorArgumentValues.addIndexedArgumentValue方法的具体用法?Java ConstructorArgumentValues.addIndexedArgumentValue怎么用?Java ConstructorArgumentValues.addIndexedArgumentValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.config.ConstructorArgumentValues
的用法示例。
在下文中一共展示了ConstructorArgumentValues.addIndexedArgumentValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
示例2: addMapping
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
@Override
public void addMapping(Element element, ManagedMap<String, Object> urlMap, ParserContext context) {
String pathAttribute = element.getAttribute("path");
List<String> mappings = Arrays.asList(StringUtils.tokenizeToStringArray(pathAttribute, ","));
RuntimeBeanReference handlerReference = new RuntimeBeanReference(element.getAttribute("handler"));
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addIndexedArgumentValue(0, handlerReference);
if (this.handshakeHandlerReference != null) {
cavs.addIndexedArgumentValue(1, this.handshakeHandlerReference);
}
RootBeanDefinition requestHandlerDef = new RootBeanDefinition(WebSocketHttpRequestHandler.class, cavs, null);
requestHandlerDef.setSource(context.extractSource(element));
requestHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
requestHandlerDef.getPropertyValues().add("handshakeInterceptors", this.interceptorsList);
String requestHandlerName = context.getReaderContext().registerWithGeneratedName(requestHandlerDef);
RuntimeBeanReference requestHandlerRef = new RuntimeBeanReference(requestHandlerName);
for (String mapping : mappings) {
urlMap.put(mapping, requestHandlerRef);
}
}
示例3: testCustomTypeConverter
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
@Test
public void testCustomTypeConverter() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
lbf.setTypeConverter(new CustomTypeConverter(nf));
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("myFloat", "1,1");
ConstructorArgumentValues cav = new ConstructorArgumentValues();
cav.addIndexedArgumentValue(0, "myName");
cav.addIndexedArgumentValue(1, "myAge");
lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, cav, pvs));
TestBean testBean = (TestBean) lbf.getBean("testBean");
assertEquals("myName", testBean.getName());
assertEquals(5, testBean.getAge());
assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}
示例4: testCustomTypeConverterWithBeanReference
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
@Test
public void testCustomTypeConverterWithBeanReference() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
lbf.setTypeConverter(new CustomTypeConverter(nf));
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("myFloat", new RuntimeBeanReference("myFloat"));
ConstructorArgumentValues cav = new ConstructorArgumentValues();
cav.addIndexedArgumentValue(0, "myName");
cav.addIndexedArgumentValue(1, "myAge");
lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, cav, pvs));
lbf.registerSingleton("myFloat", "1,1");
TestBean testBean = (TestBean) lbf.getBean("testBean");
assertEquals("myName", testBean.getName());
assertEquals(5, testBean.getAge());
assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}
示例5: getDefaultKeyValueTemplateBeanDefinition
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
@Override
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(
RepositoryConfigurationSource configurationSource) {
RootBeanDefinition keyValueTemplateDefinition = new RootBeanDefinition(
VaultKeyValueTemplate.class);
ConstructorArgumentValues constructorArgumentValuesForKeyValueTemplate = new ConstructorArgumentValues();
constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(0,
new RuntimeBeanReference(VAULT_ADAPTER_BEAN_NAME));
constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(1,
new RuntimeBeanReference(VAULT_MAPPING_CONTEXT_BEAN_NAME));
keyValueTemplateDefinition
.setConstructorArgumentValues(constructorArgumentValuesForKeyValueTemplate);
return keyValueTemplateDefinition;
}
示例6: jsonMapConversionWithCustomObjectMapper
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
@Test
public void jsonMapConversionWithCustomObjectMapper() throws Exception {
this.context = new GenericApplicationContext();
ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
constructorArgs.addIndexedArgumentValue(0, objectMapper);
this.context.registerBeanDefinition("endpointMbeanExporter",
new RootBeanDefinition(EndpointMBeanExporter.class, constructorArgs,
null));
this.context.registerBeanDefinition("endpoint1",
new RootBeanDefinition(JsonMapConversionEndpoint.class));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
Object response = mbeanExporter.getServer().invoke(
getObjectName("endpoint1", this.context), "getData", new Object[0],
new String[0]);
assertThat(response).isInstanceOf(Map.class);
assertThat(((Map<?, ?>) response).get("date")).isInstanceOf(String.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:21,代码来源:EndpointMBeanExporterTests.java
示例7: registerDataSources
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
/**
* 将数据源注入到Spring中
*
* @param registry
* @param dataSourcesMapping
*/
private void registerDataSources(BeanDefinitionRegistry registry,
Map<String, Map<DataSourceType, DataSource>> dataSourcesMapping) {
for (Map.Entry<String, Map<DataSourceType, DataSource>> entry : dataSourcesMapping.entrySet()) {
final String name = entry.getKey();
for (Map.Entry<DataSourceType, DataSource> subEntry : entry.getValue().entrySet()) {
GenericBeanDefinition dataSourceBeanDefinition = new GenericBeanDefinition();
dataSourceBeanDefinition.setBeanClass(DataSourceFactoryBean.class);
ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
constructorArgumentValues.addIndexedArgumentValue(0, subEntry.getValue());
dataSourceBeanDefinition.setConstructorArgumentValues(constructorArgumentValues);
String beanName = name + Character.toUpperCase(subEntry.getKey().name().charAt(0))
+ subEntry.getKey().name().substring(1) + "DataSource";
registry.registerBeanDefinition(beanName, dataSourceBeanDefinition);
}
}
}
示例8: addConstructorArgs
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
public void addConstructorArgs(Object value, Class type, BeanDefinition bd) {
ConstructorArgumentValues.ValueHolder vHolder
= new ConstructorArgumentValues.ValueHolder(value, type.getName());
ConstructorArgumentValues args
= bd.getConstructorArgumentValues();
args.addIndexedArgumentValue(args.getArgumentCount(), vHolder);
}
示例9: registerBeansForRoot
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
@Override
public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource) {
String tarantolSyncOpsRef = configurationSource.getAttribute("tarantoolSyncOpsRef");
// register context
RootBeanDefinition mappingContextDefinition = createTarantoolMappingContext();
mappingContextDefinition.setSource(configurationSource.getSource());
registerIfNotAlreadyRegistered(mappingContextDefinition, registry, MAPPING_CONTEXT_BEAN_NAME, configurationSource);
// Register converter
RootBeanDefinition redisConverterDefinition = createTarantoolConverterDefinition();
redisConverterDefinition.setSource(configurationSource.getSource());
registerIfNotAlreadyRegistered(redisConverterDefinition, registry, TARANTOOL_CONVERTER_BEAN_NAME, configurationSource);
// register tarantoolOpsImpl
RootBeanDefinition tarantoolOpsImplDefinition = new RootBeanDefinition(TarantoolOpsImpl.class);
ConstructorArgumentValues constructorArgumentValuesForTarantoolOpsImpl = new ConstructorArgumentValues();
if (StringUtils.hasText(tarantolSyncOpsRef)) {
constructorArgumentValuesForTarantoolOpsImpl.addIndexedArgumentValue(0,
new RuntimeBeanReference(tarantolSyncOpsRef));
}
tarantoolOpsImplDefinition.setConstructorArgumentValues(constructorArgumentValuesForTarantoolOpsImpl);
registerIfNotAlreadyRegistered(tarantoolOpsImplDefinition, registry, TARANTOOL_OPS_IMPL_BEAN_NAME,
configurationSource);
super.registerBeansForRoot(registry, configurationSource);
}
开发者ID:saladinkzn,项目名称:spring-data-tarantool,代码行数:32,代码来源:TarantoolRepositoryConfigurationExtension.java
示例10: createTarantoolConverterDefinition
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
private RootBeanDefinition createTarantoolConverterDefinition() {
RootBeanDefinition beanDef = new RootBeanDefinition(MappingTarantoolConverter.class);
ConstructorArgumentValues args = new ConstructorArgumentValues();
args.addIndexedArgumentValue(0, new RuntimeBeanReference(MAPPING_CONTEXT_BEAN_NAME));
beanDef.setConstructorArgumentValues(args);
return beanDef;
}
开发者ID:saladinkzn,项目名称:spring-data-tarantool,代码行数:10,代码来源:TarantoolRepositoryConfigurationExtension.java
示例11: parseResourceCache
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
private void parseResourceCache(ManagedList<? super Object> resourceResolvers,
ManagedList<? super Object> resourceTransformers, Element element, Object source) {
String resourceCache = element.getAttribute("resource-cache");
if ("true".equals(resourceCache)) {
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
RootBeanDefinition cachingResolverDef = new RootBeanDefinition(CachingResourceResolver.class);
cachingResolverDef.setSource(source);
cachingResolverDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
cachingResolverDef.setConstructorArgumentValues(cavs);
RootBeanDefinition cachingTransformerDef = new RootBeanDefinition(CachingResourceTransformer.class);
cachingTransformerDef.setSource(source);
cachingTransformerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
cachingTransformerDef.setConstructorArgumentValues(cavs);
String cacheManagerName = element.getAttribute("cache-manager");
String cacheName = element.getAttribute("cache-name");
if (StringUtils.hasText(cacheManagerName) && StringUtils.hasText(cacheName)) {
RuntimeBeanReference cacheManagerRef = new RuntimeBeanReference(cacheManagerName);
cavs.addIndexedArgumentValue(0, cacheManagerRef);
cavs.addIndexedArgumentValue(1, cacheName);
}
else {
ConstructorArgumentValues cacheCavs = new ConstructorArgumentValues();
cacheCavs.addIndexedArgumentValue(0, RESOURCE_CHAIN_CACHE);
RootBeanDefinition cacheDef = new RootBeanDefinition(ConcurrentMapCache.class);
cacheDef.setSource(source);
cacheDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
cacheDef.setConstructorArgumentValues(cacheCavs);
cavs.addIndexedArgumentValue(0, cacheDef);
}
resourceResolvers.add(cachingResolverDef);
resourceTransformers.add(cachingTransformerDef);
}
}
示例12: registerMessageConverter
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
private RuntimeBeanReference registerMessageConverter(Element element, ParserContext context, Object source) {
Element convertersElement = DomUtils.getChildElementByTagName(element, "message-converters");
ManagedList<? super Object> converters = new ManagedList<Object>();
if (convertersElement != null) {
converters.setSource(source);
for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, "bean", "ref")) {
Object object = context.getDelegate().parsePropertySubElement(beanElement, null);
converters.add(object);
}
}
if (convertersElement == null || Boolean.valueOf(convertersElement.getAttribute("register-defaults"))) {
converters.setSource(source);
converters.add(new RootBeanDefinition(StringMessageConverter.class));
converters.add(new RootBeanDefinition(ByteArrayMessageConverter.class));
if (jackson2Present) {
RootBeanDefinition jacksonConverterDef = new RootBeanDefinition(MappingJackson2MessageConverter.class);
RootBeanDefinition resolverDef = new RootBeanDefinition(DefaultContentTypeResolver.class);
resolverDef.getPropertyValues().add("defaultMimeType", MimeTypeUtils.APPLICATION_JSON);
jacksonConverterDef.getPropertyValues().add("contentTypeResolver", resolverDef);
// Use Jackson factory in order to have JSR-310 and Joda-Time modules registered automatically
GenericBeanDefinition jacksonFactoryDef = new GenericBeanDefinition();
jacksonFactoryDef.setBeanClass(Jackson2ObjectMapperFactoryBean.class);
jacksonFactoryDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
jacksonFactoryDef.setSource(source);
jacksonConverterDef.getPropertyValues().add("objectMapper", jacksonFactoryDef);
converters.add(jacksonConverterDef);
}
}
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addIndexedArgumentValue(0, converters);
RootBeanDefinition messageConverterDef = new RootBeanDefinition(CompositeMessageConverter.class, cavs, null);
return new RuntimeBeanReference(registerBeanDef(messageConverterDef, context, source));
}
示例13: registerMessagingTemplate
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
private RuntimeBeanReference registerMessagingTemplate(Element element, RuntimeBeanReference brokerChannel,
RuntimeBeanReference messageConverter, ParserContext context, Object source) {
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addIndexedArgumentValue(0, brokerChannel);
RootBeanDefinition beanDef = new RootBeanDefinition(SimpMessagingTemplate.class,cavs, null);
if (element.hasAttribute("user-destination-prefix")) {
beanDef.getPropertyValues().add("userDestinationPrefix", element.getAttribute("user-destination-prefix"));
}
beanDef.getPropertyValues().add("messageConverter", messageConverter);
return new RuntimeBeanReference(registerBeanDef(beanDef,context, source));
}
示例14: registerAnnotationMethodMessageHandler
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
private void registerAnnotationMethodMessageHandler(Element messageBrokerElement,
RuntimeBeanReference inChannel, RuntimeBeanReference outChannel,
RuntimeBeanReference converter, RuntimeBeanReference messagingTemplate,
ParserContext context, Object source) {
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addIndexedArgumentValue(0, inChannel);
cavs.addIndexedArgumentValue(1, outChannel);
cavs.addIndexedArgumentValue(2, messagingTemplate);
MutablePropertyValues values = new MutablePropertyValues();
String prefixAttribute = messageBrokerElement.getAttribute("application-destination-prefix");
values.add("destinationPrefixes", Arrays.asList(StringUtils.tokenizeToStringArray(prefixAttribute, ",")));
values.add("messageConverter", converter);
RootBeanDefinition beanDef = new RootBeanDefinition(WebSocketAnnotationMethodMessageHandler.class, cavs, values);
if (messageBrokerElement.hasAttribute("path-matcher")) {
String pathMatcherRef = messageBrokerElement.getAttribute("path-matcher");
beanDef.getPropertyValues().add("pathMatcher", new RuntimeBeanReference(pathMatcherRef));
}
Element resolversElement = DomUtils.getChildElementByTagName(messageBrokerElement, "argument-resolvers");
if (resolversElement != null) {
values.add("customArgumentResolvers", extractBeanSubElements(resolversElement, context));
}
Element handlersElement = DomUtils.getChildElementByTagName(messageBrokerElement, "return-value-handlers");
if (handlersElement != null) {
values.add("customReturnValueHandlers", extractBeanSubElements(handlersElement, context));
}
registerBeanDef(beanDef, context, source);
}
示例15: noArgFactoryMethodInvokedWithTwoArgsAndTypesSpecified
import org.springframework.beans.factory.config.ConstructorArgumentValues; //导入方法依赖的package包/类
@Test
public void noArgFactoryMethodInvokedWithTwoArgsAndTypesSpecified() {
RootBeanDefinition def = new RootBeanDefinition(Foo.class);
def.setFactoryMethodName("noArgFactory");
ConstructorArgumentValues cav = new ConstructorArgumentValues();
cav.addIndexedArgumentValue(0, "bogusArg1", CharSequence.class.getName());
cav.addIndexedArgumentValue(1, "bogusArg2".getBytes());
def.setConstructorArgumentValues(cav);
assertExceptionMessageForMisconfiguredFactoryMethod(
def,
"Error creating bean with name 'foo': No matching factory method found: factory method 'noArgFactory(CharSequence,byte[])'. " +
"Check that a method with the specified name and arguments exists and that it is static.");
}