Home / Function/ getMatchingBeans() — spring-boot Function Reference

getMatchingBeans() — spring-boot Function Reference

Architecture documentation for the getMatchingBeans() function in OnBeanCondition.java from the spring-boot codebase.

Function java GradlePlugin RunTasks calls 20 called by 5

Entity Profile

Dependency Diagram

graph TD
  e8d44fa6_45ad_6d14_6468_53ed18c907e0["getMatchingBeans()"]
  88a0bf69_b168_32a6_18fa_f66414a06bbd["evaluateConditionalOnBean()"]
  88a0bf69_b168_32a6_18fa_f66414a06bbd -->|calls| e8d44fa6_45ad_6d14_6468_53ed18c907e0
  fd603d49_4269_fbde_174b_b296c20d4b2d["evaluateConditionalOnSingleCandidate()"]
  fd603d49_4269_fbde_174b_b296c20d4b2d -->|calls| e8d44fa6_45ad_6d14_6468_53ed18c907e0
  0728734f_676c_32d6_80e4_1a420d5d6239["evaluateConditionalOnMissingBean()"]
  0728734f_676c_32d6_80e4_1a420d5d6239 -->|calls| e8d44fa6_45ad_6d14_6468_53ed18c907e0
  17f95dc1_d315_25e2_bf40_feeb29f31dfa["getPrimaryBeans()"]
  17f95dc1_d315_25e2_bf40_feeb29f31dfa -->|calls| e8d44fa6_45ad_6d14_6468_53ed18c907e0
  c0607bbd_e1af_01e3_85d4_a6fb09a3e424["getNonFallbackBeans()"]
  c0607bbd_e1af_01e3_85d4_a6fb09a3e424 -->|calls| e8d44fa6_45ad_6d14_6468_53ed18c907e0
  8f1f8954_51c8_a466_9ffb_38ba46644698["getSearchBeanFactory()"]
  e8d44fa6_45ad_6d14_6468_53ed18c907e0 -->|calls| 8f1f8954_51c8_a466_9ffb_38ba46644698
  3f8c59d2_e032_b018_de26_f8360730651b["getContext()"]
  e8d44fa6_45ad_6d14_6468_53ed18c907e0 -->|calls| 3f8c59d2_e032_b018_de26_f8360730651b
  1ac703ed_372f_03eb_304a_f76d7a096ee5["getStrategy()"]
  e8d44fa6_45ad_6d14_6468_53ed18c907e0 -->|calls| 1ac703ed_372f_03eb_304a_f76d7a096ee5
  390076ed_d800_5da8_6dad_6e19456f1f16["getParameterizedContainers()"]
  e8d44fa6_45ad_6d14_6468_53ed18c907e0 -->|calls| 390076ed_d800_5da8_6dad_6e19456f1f16
  a8777dcb_6175_c7a5_a8f5_e58c30b2081d["getNamesOfBeansIgnoredByType()"]
  e8d44fa6_45ad_6d14_6468_53ed18c907e0 -->|calls| a8777dcb_6175_c7a5_a8f5_e58c30b2081d
  6ed0b559_b6aa_7fb9_4aa1_52cb098af785["getIgnoredTypes()"]
  e8d44fa6_45ad_6d14_6468_53ed18c907e0 -->|calls| 6ed0b559_b6aa_7fb9_4aa1_52cb098af785
  2ba0e534_4c88_5921_5926_322818e3ae20["getTypes()"]
  e8d44fa6_45ad_6d14_6468_53ed18c907e0 -->|calls| 2ba0e534_4c88_5921_5926_322818e3ae20
  8361880d_08d6_782b_4fbe_15d5a4ea3680["getBeanDefinitionsForType()"]
  e8d44fa6_45ad_6d14_6468_53ed18c907e0 -->|calls| 8361880d_08d6_782b_4fbe_15d5a4ea3680
  b3cc6bdd_7170_3273_2d18_9e3622e1a4c4["matchedNamesFrom()"]
  e8d44fa6_45ad_6d14_6468_53ed18c907e0 -->|calls| b3cc6bdd_7170_3273_2d18_9e3622e1a4c4
  style e8d44fa6_45ad_6d14_6468_53ed18c907e0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java lines 212–255

	protected final MatchResult getMatchingBeans(Spec<?> spec) {
		ConfigurableListableBeanFactory beanFactory = getSearchBeanFactory(spec);
		ClassLoader classLoader = spec.getContext().getClassLoader();
		boolean considerHierarchy = spec.getStrategy() != SearchStrategy.CURRENT;
		Set<BeanType> parameterizedContainers = spec.getParameterizedContainers();
		MatchResult result = new MatchResult();
		Set<String> beansIgnoredByType = getNamesOfBeansIgnoredByType(beanFactory, considerHierarchy,
				spec.getIgnoredTypes(), parameterizedContainers);
		for (BeanType type : spec.getTypes()) {
			Map<String, @Nullable BeanDefinition> typeMatchedDefinitions = getBeanDefinitionsForType(beanFactory,
					considerHierarchy, type, parameterizedContainers);
			Set<String> typeMatchedNames = matchedNamesFrom(typeMatchedDefinitions,
					(name, definition) -> !ScopedProxyUtils.isScopedTarget(name)
							&& isCandidate(beanFactory, name, definition, beansIgnoredByType));
			if (typeMatchedNames.isEmpty()) {
				result.recordUnmatchedType(type);
			}
			else {
				result.recordMatchedType(type, typeMatchedNames);
			}
		}
		for (String annotation : spec.getAnnotations()) {
			Map<String, @Nullable BeanDefinition> annotationMatchedDefinitions = getBeanDefinitionsForAnnotation(
					classLoader, beanFactory, annotation, considerHierarchy);
			Set<String> annotationMatchedNames = matchedNamesFrom(annotationMatchedDefinitions,
					(name, definition) -> isCandidate(beanFactory, name, definition, beansIgnoredByType));
			if (annotationMatchedNames.isEmpty()) {
				result.recordUnmatchedAnnotation(annotation);
			}
			else {
				result.recordMatchedAnnotation(annotation, annotationMatchedNames);

			}
		}
		for (String beanName : spec.getNames()) {
			if (!beansIgnoredByType.contains(beanName) && containsBean(beanFactory, beanName, considerHierarchy)) {
				result.recordMatchedName(beanName);
			}
			else {
				result.recordUnmatchedName(beanName);
			}
		}
		return result;
	}

Domain

Subdomains

Calls

Frequently Asked Questions

What does getMatchingBeans() do?
getMatchingBeans() is a function in the spring-boot codebase.
What does getMatchingBeans() call?
getMatchingBeans() calls 20 function(s): containsBean, getAnnotations, getBeanDefinitionsForAnnotation, getBeanDefinitionsForType, getContext, getIgnoredTypes, getNames, getNamesOfBeansIgnoredByType, and 12 more.
What calls getMatchingBeans()?
getMatchingBeans() is called by 5 function(s): evaluateConditionalOnBean, evaluateConditionalOnMissingBean, evaluateConditionalOnSingleCandidate, getNonFallbackBeans, getPrimaryBeans.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free