Skip to content

io microsphere spring beans factory annotation AutowiredInjectionPointDependencyResolver

github-actions[bot] edited this page Jun 18, 2026 · 18 revisions

AutowiredInjectionPointDependencyResolver

Type: Class | Module: microsphere-spring-context | Package: io.microsphere.spring.beans.factory.annotation | Since: 1.0.0

Source: microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/annotation/AutowiredInjectionPointDependencyResolver.java

Overview

AnnotatedInjectionPointDependencyResolver for Autowired

Declaration

public class AutowiredInjectionPointDependencyResolver extends AnnotatedInjectionPointDependencyResolver<Autowired>

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.27-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

Method Examples

getAnnotation

AutowiredInjectionPointDependencyResolver resolver = new AutowiredInjectionPointDependencyResolver();
  // Given: @Bean public User user(@Autowired MyDependency[] deps) { ... }
  Method method = MethodUtils.findMethod(Config.class, "user", MyDependency[].class);
  Parameter parameter = method.getParameters()[0];
  Autowired autowired = resolver.getAnnotation(parameter);
  // autowired is non-null since @Autowired is present on the parameter

resolve

AutowiredInjectionPointDependencyResolver resolver = new AutowiredInjectionPointDependencyResolver();
  resolver.setBeanFactory(beanFactory);
  // Given: @Autowired private Optional<List<MyDependency>> test;
  Field field = ReflectionUtils.findField(Config.class, "test");
  Set<String> dependentBeanNames = new LinkedHashSet<>();
  resolver.resolve(field, beanFactory, dependentBeanNames);
  // dependentBeanNames contains bean names matching the field type

resolve

AutowiredInjectionPointDependencyResolver resolver = new AutowiredInjectionPointDependencyResolver();
  resolver.setBeanFactory(beanFactory);
  // Given: @Autowired public Config(Map<String, MyDependency> test) { }
  Constructor<?> constructor = ConstructorUtils.findConstructor(Config.class, Map.class);
  Parameter parameter = constructor.getParameters()[0];
  Set<String> dependentBeanNames = new LinkedHashSet<>();
  resolver.resolve(parameter, beanFactory, dependentBeanNames);
  // dependentBeanNames contains bean names matching the parameter type

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-spring-context</artifactId>
    <version>${microsphere-spring.version}</version>
</dependency>

Tip: Use the BOM (microsphere-spring-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.spring.beans.factory.annotation.AutowiredInjectionPointDependencyResolver;

API Reference

Public Methods

Method Description
getAnnotation Get the Autowired annotation from the given Parameter.
resolve Resolve the dependent bean names from the given Field if it is annotated
resolve Resolve the dependent bean names from the given Parameter if it or its

Method Details

getAnnotation

public Autowired getAnnotation(Parameter parameter)

Get the Autowired annotation from the given Parameter.

First looks for @Autowired directly on the parameter. If not found, falls back to looking for @Autowired on the declaring method or constructor.

Example Usage

`AutowiredInjectionPointDependencyResolver resolver = new AutowiredInjectionPointDependencyResolver();
  // Given: @Bean public User user(@Autowired MyDependency[] deps) { ... `
  Method method = MethodUtils.findMethod(Config.class, "user", MyDependency[].class);
  Parameter parameter = method.getParameters()[0];
  Autowired autowired = resolver.getAnnotation(parameter);
  // autowired is non-null since @Autowired is present on the parameter
}

resolve

public void resolve(Field field, ConfigurableListableBeanFactory beanFactory, Set<String> dependentBeanNames)

Resolve the dependent bean names from the given Field if it is annotated with Autowired. Fields without the annotation are silently skipped.

Example Usage

`AutowiredInjectionPointDependencyResolver resolver = new AutowiredInjectionPointDependencyResolver();
  resolver.setBeanFactory(beanFactory);
  // Given: @Autowired private Optional> test;
  Field field = ReflectionUtils.findField(Config.class, "test");
  Set dependentBeanNames = new LinkedHashSet<>();
  resolver.resolve(field, beanFactory, dependentBeanNames);
  // dependentBeanNames contains bean names matching the field type
`

resolve

public void resolve(Parameter parameter, ConfigurableListableBeanFactory beanFactory, Set<String> dependentBeanNames)

Resolve the dependent bean names from the given Parameter if it or its declaring method/constructor is annotated with Autowired. Parameters without the annotation are silently skipped.

Example Usage

`AutowiredInjectionPointDependencyResolver resolver = new AutowiredInjectionPointDependencyResolver();
  resolver.setBeanFactory(beanFactory);
  // Given: @Autowired public Config(Map test) { `
  Constructor constructor = ConstructorUtils.findConstructor(Config.class, Map.class);
  Parameter parameter = constructor.getParameters()[0];
  Set dependentBeanNames = new LinkedHashSet<>();
  resolver.resolve(parameter, beanFactory, dependentBeanNames);
  // dependentBeanNames contains bean names matching the parameter type
}

This documentation was auto-generated from the source code of microsphere-spring.

Home

spring-context

spring-guice

spring-jdbc

spring-test

spring-web

spring-webflux

spring-webmvc

Clone this wiki locally