Java Code Examples for org.springframework.beans.factory.config.ConstructorArgumentValues#ValueHolder

The following examples show how to use org.springframework.beans.factory.config.ConstructorArgumentValues#ValueHolder . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FunctionContextUtils.java    From spring-cloud-function with Apache License 2.0 6 votes vote down vote up
public static Class<?>[] getParamTypesFromBeanDefinitionFactory(Class<?> factory,
		AbstractBeanDefinition definition) {
	if (definition instanceof RootBeanDefinition) {
		RootBeanDefinition root = (RootBeanDefinition) definition;
		for (Method method : getCandidateMethods(factory, root)) {
			if (root.isFactoryMethod(method)) {
				return method.getParameterTypes();
			}
		}
	}
	List<Class<?>> params = new ArrayList<>();
	for (ConstructorArgumentValues.ValueHolder holder : definition
			.getConstructorArgumentValues().getIndexedArgumentValues().values()) {
		params.add(ClassUtils.resolveClassName(holder.getType(), null));
	}
	return params.toArray(new Class<?>[0]);
}
 
Example 2
Source File: DeployerContextUtils.java    From spring-cloud-function with Apache License 2.0 6 votes vote down vote up
private static Class<?>[] getParamTypes(Class<?> factory,
		AbstractBeanDefinition definition) {
	if (definition instanceof RootBeanDefinition) {
		RootBeanDefinition root = (RootBeanDefinition) definition;
		for (Method method : getCandidateMethods(factory, root)) {
			if (root.isFactoryMethod(method)) {
				return method.getParameterTypes();
			}
		}
	}
	List<Class<?>> params = new ArrayList<>();
	for (ConstructorArgumentValues.ValueHolder holder : definition
			.getConstructorArgumentValues().getIndexedArgumentValues().values()) {
		params.add(ClassUtils.resolveClassName(holder.getType(), null));
	}
	return params.toArray(new Class<?>[0]);
}
 
Example 3
Source File: RedissonNamespaceParserSupport.java    From redisson with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 4
Source File: WebAdminComponentScanRegistrar.java    From wallride with Apache License 2.0 5 votes vote down vote up
private void updateWebAdminComponentScanBeanPostProcessor(BeanDefinitionRegistry registry, Set<String> packagesToScan) {
	BeanDefinition definition = registry.getBeanDefinition(BEAN_NAME);
	ConstructorArgumentValues.ValueHolder constructorArguments = definition.getConstructorArgumentValues()
			.getGenericArgumentValue(String[].class);
	Set<String> mergedPackages = new LinkedHashSet<>();
	mergedPackages.addAll(Arrays.asList((String[]) constructorArguments.getValue()));
	mergedPackages.addAll(packagesToScan);
	constructorArguments.setValue(toArray(mergedPackages));
}
 
Example 5
Source File: WebGuestComponentScanRegistrar.java    From wallride with Apache License 2.0 5 votes vote down vote up
private void updateWebGuestComponentScanBeanPostProcessor(BeanDefinitionRegistry registry, Set<String> packagesToScan) {
	BeanDefinition definition = registry.getBeanDefinition(BEAN_NAME);
	ConstructorArgumentValues.ValueHolder constructorArguments = definition.getConstructorArgumentValues()
			.getGenericArgumentValue(String[].class);
	Set<String> mergedPackages = new LinkedHashSet<>();
	mergedPackages.addAll(Arrays.asList((String[]) constructorArguments.getValue()));
	mergedPackages.addAll(packagesToScan);
	constructorArguments.setValue(toArray(mergedPackages));
}