001/* 002 * Copyright 2002-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.beans.factory.support; 018 019import org.springframework.beans.factory.config.BeanDefinitionHolder; 020import org.springframework.beans.factory.config.DependencyDescriptor; 021 022/** 023 * {@link AutowireCandidateResolver} implementation to use when no annotation 024 * support is available. This implementation checks the bean definition only. 025 * 026 * @author Mark Fisher 027 * @author Juergen Hoeller 028 * @since 2.5 029 */ 030public class SimpleAutowireCandidateResolver implements AutowireCandidateResolver { 031 032 @Override 033 public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) { 034 return bdHolder.getBeanDefinition().isAutowireCandidate(); 035 } 036 037 /** 038 * Determine whether the given descriptor is effectively required. 039 * <p>The default implementation checks {@link DependencyDescriptor#isRequired()}. 040 * @param descriptor the descriptor for the target method parameter or field 041 * @return whether the descriptor is marked as required or possibly indicating 042 * non-required status some other way (e.g. through a parameter annotation) 043 * @since 4.3.9 044 * @see DependencyDescriptor#isRequired() 045 */ 046 public boolean isRequired(DependencyDescriptor descriptor) { 047 return descriptor.isRequired(); 048 } 049 050 @Override 051 public Object getSuggestedValue(DependencyDescriptor descriptor) { 052 return null; 053 } 054 055 @Override 056 public Object getLazyResolutionProxyIfNecessary(DependencyDescriptor descriptor, String beanName) { 057 return null; 058 } 059 060}