001/*
002 * Copyright 2002-2020 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;
021import org.springframework.lang.Nullable;
022
023/**
024 * {@link AutowireCandidateResolver} implementation to use when no annotation
025 * support is available. This implementation checks the bean definition only.
026 *
027 * @author Mark Fisher
028 * @author Juergen Hoeller
029 * @since 2.5
030 */
031public class SimpleAutowireCandidateResolver implements AutowireCandidateResolver {
032
033        /**
034         * Shared instance of {@code SimpleAutowireCandidateResolver}.
035         * @since 5.2.7
036         */
037        public static final SimpleAutowireCandidateResolver INSTANCE = new SimpleAutowireCandidateResolver();
038
039
040        @Override
041        public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) {
042                return bdHolder.getBeanDefinition().isAutowireCandidate();
043        }
044
045        @Override
046        public boolean isRequired(DependencyDescriptor descriptor) {
047                return descriptor.isRequired();
048        }
049
050        @Override
051        public boolean hasQualifier(DependencyDescriptor descriptor) {
052                return false;
053        }
054
055        @Override
056        @Nullable
057        public Object getSuggestedValue(DependencyDescriptor descriptor) {
058                return null;
059        }
060
061        @Override
062        @Nullable
063        public Object getLazyResolutionProxyIfNecessary(DependencyDescriptor descriptor, @Nullable String beanName) {
064                return null;
065        }
066
067        /**
068         * This implementation returns {@code this} as-is.
069         * @see #INSTANCE
070         */
071        @Override
072        public AutowireCandidateResolver cloneIfNecessary() {
073                return this;
074        }
075
076}