本文整理匯總了Java中org.springframework.beans.factory.support.RootBeanDefinition.setConstructorArgumentValues方法的典型用法代碼示例。如果您正苦於以下問題:Java RootBeanDefinition.setConstructorArgumentValues方法的具體用法?Java RootBeanDefinition.setConstructorArgumentValues怎麽用?Java RootBeanDefinition.setConstructorArgumentValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.beans.factory.support.RootBeanDefinition
的用法示例。
在下文中一共展示了RootBeanDefinition.setConstructorArgumentValues方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDefaultKeyValueTemplateBeanDefinition
import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的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: getDefaultKeyValueTemplateBeanDefinition
import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的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;
}
示例3: registerByteCodeLoadingProxy
import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的package包/類
private void registerByteCodeLoadingProxy(String name, String type, Resource resource,
DefaultListableBeanFactory beanFactory) {
Class<?> proxyClass = null;
if ("supplier".equals(type.toLowerCase())) {
proxyClass = ByteCodeLoadingSupplier.class;
}
else if ("consumer".equals(type.toLowerCase())) {
proxyClass = ByteCodeLoadingConsumer.class;
}
else {
proxyClass = ByteCodeLoadingFunction.class;
}
RootBeanDefinition beanDefinition = new RootBeanDefinition(proxyClass);
ConstructorArgumentValues args = new ConstructorArgumentValues();
args.addGenericArgumentValue(resource);
beanDefinition.setConstructorArgumentValues(args);
beanFactory.registerBeanDefinition(name, beanDefinition);
}
示例4: registerBeansForRoot
import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的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
示例5: createTarantoolConverterDefinition
import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的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
示例6: parseResourceCache
import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的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);
}
}
示例7: noArgFactoryMethodInvokedWithTwoArgsAndTypesSpecified
import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的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.");
}
示例8: createVaultMappingContext
import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的package包/類
private RootBeanDefinition createVaultMappingContext(
RepositoryConfigurationSource configurationSource) {
ConstructorArgumentValues mappingContextArgs = new ConstructorArgumentValues();
RootBeanDefinition mappingContextBeanDef = new RootBeanDefinition(
VaultMappingContext.class);
mappingContextBeanDef.setConstructorArgumentValues(mappingContextArgs);
mappingContextBeanDef.setSource(configurationSource.getSource());
return mappingContextBeanDef;
}
示例9: registerLambdaCompilingProxy
import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的package包/類
private void registerLambdaCompilingProxy(String name, String type, String inputType,
String outputType, String lambda, DefaultListableBeanFactory beanFactory) {
Resource resource = new ByteArrayResource(lambda.getBytes());
ConstructorArgumentValues args = new ConstructorArgumentValues();
MutablePropertyValues props = new MutablePropertyValues();
args.addGenericArgumentValue(resource);
Class<?> proxyClass = null;
if ("supplier".equals(type.toLowerCase())) {
proxyClass = LambdaCompilingSupplier.class;
args.addGenericArgumentValue(this.supplierCompiler);
if (outputType != null) {
props.add("typeParameterizations", outputType);
}
}
else if ("consumer".equals(type.toLowerCase())) {
proxyClass = LambdaCompilingConsumer.class;
args.addGenericArgumentValue(this.consumerCompiler);
if (inputType != null) {
props.add("typeParameterizations", inputType);
}
}
else {
proxyClass = LambdaCompilingFunction.class;
args.addGenericArgumentValue(this.functionCompiler);
if ((inputType == null && outputType != null)
|| (outputType == null && inputType != null)) {
throw new IllegalArgumentException(
"if either input or output type is set, the other is also required");
}
if (inputType != null) {
props.add("typeParameterizations",
new String[] { inputType, outputType });
}
}
RootBeanDefinition beanDefinition = new RootBeanDefinition(proxyClass);
beanDefinition.setConstructorArgumentValues(args);
beanDefinition.setPropertyValues(props);
beanFactory.registerBeanDefinition(name, beanDefinition);
}
示例10: registerBeansForRoot
import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的package包/類
@Override
public void registerBeansForRoot(BeanDefinitionRegistry registry,
RepositoryConfigurationSource configurationSource) {
Optional<String> vaultTemplateRef = configurationSource
.getAttribute("vaultTemplateRef");
RootBeanDefinition mappingContextDefinition = createVaultMappingContext(configurationSource);
mappingContextDefinition.setSource(configurationSource.getSource());
registerIfNotAlreadyRegistered(mappingContextDefinition, registry,
VAULT_MAPPING_CONTEXT_BEAN_NAME, configurationSource);
// register Adapter
RootBeanDefinition vaultKeyValueAdapterDefinition = new RootBeanDefinition(
VaultKeyValueAdapter.class);
ConstructorArgumentValues constructorArgumentValuesForVaultKeyValueAdapter = new ConstructorArgumentValues();
constructorArgumentValuesForVaultKeyValueAdapter.addIndexedArgumentValue(0,
new RuntimeBeanReference(vaultTemplateRef.orElse("vaultTemplate")));
vaultKeyValueAdapterDefinition
.setConstructorArgumentValues(constructorArgumentValuesForVaultKeyValueAdapter);
registerIfNotAlreadyRegistered(vaultKeyValueAdapterDefinition, registry,
VAULT_ADAPTER_BEAN_NAME, configurationSource);
Optional<String> keyValueTemplateName = configurationSource
.getAttribute(KEY_VALUE_TEMPLATE_BEAN_REF_ATTRIBUTE);
// No custom template reference configured and no matching bean definition found
if (keyValueTemplateName.isPresent()
&& getDefaultKeyValueTemplateRef().equals(keyValueTemplateName.get())
&& !registry.containsBeanDefinition(keyValueTemplateName.get())) {
AbstractBeanDefinition beanDefinition = getDefaultKeyValueTemplateBeanDefinition(configurationSource);
registerIfNotAlreadyRegistered(beanDefinition, registry,
keyValueTemplateName.get(), configurationSource.getSource());
}
super.registerBeansForRoot(registry, configurationSource);
}
示例11: inject
import org.springframework.beans.factory.support.RootBeanDefinition; //導入方法依賴的package包/類
@Override
protected void inject(Object bean, String beanName, PropertyValues pvs) throws Throwable {
Field field = (Field) this.member;
//find consumer field
//auto initialize dubbo Remote Caller
DefaultListableBeanFactory factory = (DefaultListableBeanFactory) beanFactory;
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setBeanClass(ConsumerBean.class);
beanDefinition.setLazyInit(false);
beanDefinition.setBeanClassName(ConsumerBean.class.getName());
ConstructorArgumentValues values = new ConstructorArgumentValues();
values.addIndexedArgumentValue(0, field.getType().getName());
beanDefinition.setConstructorArgumentValues(values);
factory.registerBeanDefinition(field.getName(), beanDefinition);
try {
Object value;
if (this.cached) {
value = resolvedCachedArgument(beanName, this.cachedFieldValue);
}
else {
DependencyDescriptor descriptor = new DependencyDescriptor(field, this.required);
Set<String> autowiredBeanNames = new LinkedHashSet<String>(1);
TypeConverter typeConverter = beanFactory.getTypeConverter();
value = beanFactory.resolveDependency(descriptor, beanName, autowiredBeanNames, typeConverter);
synchronized (this) {
if (!this.cached) {
if (value != null || this.required) {
this.cachedFieldValue = descriptor;
registerDependentBeans(beanName, autowiredBeanNames);
if (autowiredBeanNames.size() == 1) {
String autowiredBeanName = autowiredBeanNames.iterator().next();
if (beanFactory.containsBean(autowiredBeanName)) {
if (beanFactory.isTypeMatch(autowiredBeanName, field.getType())) {
this.cachedFieldValue = new RuntimeBeanReference(autowiredBeanName);
}
}
}
}
else {
this.cachedFieldValue = null;
}
this.cached = true;
}
}
}
if (value != null) {
ReflectionUtils.makeAccessible(field);
field.set(bean, value);
}
}
catch (Throwable ex) {
throw new BeanCreationException("Could not autowire field: " + field, ex);
}
}