Class AbstractInjectionPointDependencyResolver

java.lang.Object
io.microsphere.spring.beans.factory.AbstractInjectionPointDependencyResolver
All Implemented Interfaces:
InjectionPointDependencyResolver, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware
Direct Known Subclasses:
AnnotatedInjectionPointDependencyResolver, BeanMethodInjectionPointDependencyResolver, ConstructionInjectionPointDependencyResolver

public abstract class AbstractInjectionPointDependencyResolver extends Object implements InjectionPointDependencyResolver, org.springframework.beans.factory.BeanFactoryAware
Abstract base class for implementing InjectionPointDependencyResolver.

This class provides a foundation for resolving dependencies at injection points within Spring-managed beans. It handles common tasks such as bean factory awareness, dependency type resolution, and logging using the Logger interface.

Key Responsibilities

  • Tracking and resolving dependencies based on injection points (fields, methods, constructors).
  • Filtering resolvable dependency types via the configured ResolvableDependencyTypeFilter.
  • Providing consistent logging capabilities through the injected logger.
  • Supporting custom resolution logic by allowing subclasses to implement specific strategies.

Example Usage

Basic Implementation


 public class MyDependencyResolver extends AbstractInjectionPointDependencyResolver {
     // Custom implementation details here
 }
 

Resolving Dependencies from a Field


 public void resolve(Field field, ConfigurableListableBeanFactory beanFactory, Set<String> dependentBeanNames) {
     String dependentBeanName = resolveDependentBeanNameByName(field, beanFactory);
     if (dependentBeanName == null) {
         resolveDependentBeanNamesByType(field::getGenericType, beanFactory, dependentBeanNames);
     } else {
         dependentBeanNames.add(dependentBeanName);
     }
 }
 

Resolving Dependencies from a Method Parameter


 public void resolve(Parameter parameter, ConfigurableListableBeanFactory beanFactory, Set<String> dependentBeanNames) {
     String dependentBeanName = resolveDependentBeanNameByName(parameter, beanFactory);
     if (dependentBeanName == null) {
         resolveDependentBeanNamesByType(parameter::getParameterizedType, beanFactory, dependentBeanNames);
     } else {
         dependentBeanNames.add(dependentBeanName);
     }
 }
 
Since:
1.0.0
Author:
Mercy
  • Field Details

    • logger

      protected final io.microsphere.logging.Logger logger
    • resolvableDependencyTypeFilter

      @Nonnull protected ResolvableDependencyTypeFilter resolvableDependencyTypeFilter
    • autowireCandidateResolver

      @Nonnull protected org.springframework.beans.factory.support.AutowireCandidateResolver autowireCandidateResolver
  • Constructor Details

    • AbstractInjectionPointDependencyResolver

      public AbstractInjectionPointDependencyResolver()
  • Method Details

    • resolve

      public void resolve(Field field, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> dependentBeanNames)
      Description copied from interface: InjectionPointDependencyResolver
      Resolve the bean names as the dependencies from the specified field
      Specified by:
      resolve in interface InjectionPointDependencyResolver
      Parameters:
      field - the field may be an injection point
      beanFactory - ConfigurableListableBeanFactory
      dependentBeanNames - the dependent bean names to be manipulated
    • resolve

      public void resolve(Method method, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> dependentBeanNames)
      Description copied from interface: InjectionPointDependencyResolver
      Resolve the bean names as the dependencies from the specified method
      Specified by:
      resolve in interface InjectionPointDependencyResolver
      Parameters:
      method - the method may be an injection point
      beanFactory - ConfigurableListableBeanFactory
      dependentBeanNames - the dependent bean names to be manipulated
    • resolve

      public void resolve(Constructor constructor, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> dependentBeanNames)
      Description copied from interface: InjectionPointDependencyResolver
      Resolve the bean names as the dependencies from the specified constructor
      Specified by:
      resolve in interface InjectionPointDependencyResolver
      Parameters:
      constructor - the constructor may be an injection point
      beanFactory - ConfigurableListableBeanFactory
      dependentBeanNames - the dependent bean names to be manipulated
    • resolve

      public void resolve(Parameter parameter, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> dependentBeanNames)
      Description copied from interface: InjectionPointDependencyResolver
      Resolve the bean names as the dependencies from the specified parameter
      Specified by:
      resolve in interface InjectionPointDependencyResolver
      Parameters:
      parameter - the specified parameter of a method or constructor was annotated by the annotation
      beanFactory - ConfigurableListableBeanFactory
      dependentBeanNames - the dependent bean names to be manipulated
    • setBeanFactory

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
      Throws:
      org.springframework.beans.BeansException
    • resolveDependentBeanNameByName

      protected String resolveDependentBeanNameByName(Field field, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
    • resolveDependentBeanNameByName

      protected String resolveDependentBeanNameByName(Parameter parameter, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
    • resolveDependentBeanNameByName

      protected String resolveDependentBeanNameByName(org.springframework.beans.factory.config.DependencyDescriptor dependencyDescriptor)
    • resolveDependentBeanNamesByType

      protected void resolveDependentBeanNamesByType(Supplier<Type> typeSupplier, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> dependentBeanNames)
    • resolveDependentType

      protected Class<?> resolveDependentType(Type type)