Java Code Examples for org.springframework.beans.factory.config.DependencyDescriptor#increaseNestingLevel()

The following examples show how to use org.springframework.beans.factory.config.DependencyDescriptor#increaseNestingLevel() . 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: ProviderAwareListableBeanFactory.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
@Override
protected Map<String, Object> findAutowireCandidates(String beanName, Class<?> requiredType,
                                                     DependencyDescriptor descriptor) {

    if (!requiredType.equals(Provider.class)) {
        return super.findAutowireCandidates(beanName, requiredType, descriptor);
    }

    DependencyDescriptor providedDescriptor = new DependencyDescriptor(descriptor);
    providedDescriptor.increaseNestingLevel();
    Class<?> type = providedDescriptor.getDependencyType();
    Set<String> candidates = findAutowireCandidates(beanName, type, providedDescriptor).keySet();
    return candidates.stream()
            .collect(toMap(Function.identity(), name -> new DependencyProvider(this, descriptor, name)));

}
 
Example 2
Source File: ProviderAwareListableBeanFactory.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
DependencyProvider(ProviderAwareListableBeanFactory beanFactory,
                   DependencyDescriptor descriptor, String beanName) {
    this.beanFactory = beanFactory;
    DependencyDescriptor d = new DependencyDescriptor(descriptor);
    d.increaseNestingLevel();
    this.optional = d.getDependencyType().equals(Optional.class);
    this.descriptor = this.optional ? new OptionalDependencyDescriptor(d) : d;
    this.beanName = beanName;
}
 
Example 3
Source File: DefaultListableBeanFactory.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public Object createOptionalDependency(DependencyDescriptor descriptor, String beanName) {
	DependencyDescriptor descriptorToUse = new DependencyDescriptor(descriptor) {
		@Override
		public boolean isRequired() {
			return false;
		}
	};
	descriptorToUse.increaseNestingLevel();
	return Optional.ofNullable(doResolveDependency(descriptorToUse, beanName, null, null));
}