Skip to content

Commit a220326

Browse files
committed
Merge pull request #14681 from rweisleder
* pr/14681: Clarify Javadoc of ConditionalOn annotations
2 parents b4c5aea + d2a063b commit a220326

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnBean.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,13 +24,14 @@
2424
import java.lang.annotation.Target;
2525

2626
import org.springframework.beans.factory.BeanFactory;
27-
import org.springframework.context.ApplicationContext;
2827
import org.springframework.context.annotation.Conditional;
2928

3029
/**
31-
* {@link Conditional} that only matches when the specified bean classes and/or names are
32-
* already contained in the {@link BeanFactory}. When placed on a {@code @Bean} method,
33-
* the bean class defaults to the return type of the factory method:
30+
* {@link Conditional} that only matches when beans of the specified classes and/or with
31+
* the specified names are already contained in the {@link BeanFactory}.
32+
* <p>
33+
* When placed on a {@code @Bean} method, the bean class defaults to the return type of
34+
* the factory method:
3435
*
3536
* <pre class="code">
3637
* &#064;Configuration
@@ -61,31 +62,31 @@
6162
public @interface ConditionalOnBean {
6263

6364
/**
64-
* The class type of bean that should be checked. The condition matches when all of
65-
* the classes specified are contained in the {@link ApplicationContext}.
65+
* The class types of beans that should be checked. The condition matches when beans
66+
* of all classes specified are contained in the {@link BeanFactory}.
6667
* @return the class types of beans to check
6768
*/
6869
Class<?>[] value() default {};
6970

7071
/**
71-
* The class type names of bean that should be checked. The condition matches when all
72-
* of the classes specified are contained in the {@link ApplicationContext}.
72+
* The class type names of beans that should be checked. The condition matches when
73+
* beans of all classes specified are contained in the {@link BeanFactory}.
7374
* @return the class type names of beans to check
7475
*/
7576
String[] type() default {};
7677

7778
/**
7879
* The annotation type decorating a bean that should be checked. The condition matches
7980
* when all of the annotations specified are defined on beans in the
80-
* {@link ApplicationContext}.
81+
* {@link BeanFactory}.
8182
* @return the class-level annotation types to check
8283
*/
8384
Class<? extends Annotation>[] annotation() default {};
8485

8586
/**
8687
* The names of beans to check. The condition matches when all of the bean names
87-
* specified are contained in the {@link ApplicationContext}.
88-
* @return the name of beans to check
88+
* specified are contained in the {@link BeanFactory}.
89+
* @return the names of beans to check
8990
*/
9091
String[] name() default {};
9192

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingBean.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,12 +24,11 @@
2424
import java.lang.annotation.Target;
2525

2626
import org.springframework.beans.factory.BeanFactory;
27-
import org.springframework.context.ApplicationContext;
2827
import org.springframework.context.annotation.Conditional;
2928

3029
/**
31-
* {@link Conditional} that only matches when the specified bean classes and/or names are
32-
* not already contained in the {@link BeanFactory}.
30+
* {@link Conditional} that only matches when no beans of the specified classes and/or
31+
* with the specified names are already contained in the {@link BeanFactory}.
3332
* <p>
3433
* When placed on a {@code @Bean} method, the bean class defaults to the return type of
3534
* the factory method:
@@ -64,21 +63,21 @@
6463
public @interface ConditionalOnMissingBean {
6564

6665
/**
67-
* The class type of bean that should be checked. The condition matches when each
68-
* class specified is missing in the {@link ApplicationContext}.
66+
* The class types of beans that should be checked. The condition matches when no bean
67+
* of each class specified is contained in the {@link BeanFactory}.
6968
* @return the class types of beans to check
7069
*/
7170
Class<?>[] value() default {};
7271

7372
/**
74-
* The class type names of bean that should be checked. The condition matches when
75-
* each class specified is missing in the {@link ApplicationContext}.
73+
* The class type names of beans that should be checked. The condition matches when no
74+
* bean of each class specified is contained in the {@link BeanFactory}.
7675
* @return the class type names of beans to check
7776
*/
7877
String[] type() default {};
7978

8079
/**
81-
* The class type of beans that should be ignored when identifying matching beans.
80+
* The class types of beans that should be ignored when identifying matching beans.
8281
* @return the class types of beans to ignore
8382
* @since 1.2.5
8483
*/
@@ -95,15 +94,15 @@
9594
/**
9695
* The annotation type decorating a bean that should be checked. The condition matches
9796
* when each annotation specified is missing from all beans in the
98-
* {@link ApplicationContext}.
97+
* {@link BeanFactory}.
9998
* @return the class-level annotation types to check
10099
*/
101100
Class<? extends Annotation>[] annotation() default {};
102101

103102
/**
104103
* The names of beans to check. The condition matches when each bean name specified is
105-
* missing in the {@link ApplicationContext}.
106-
* @return the name of beans to check
104+
* missing in the {@link BeanFactory}.
105+
* @return the names of beans to check
107106
*/
108107
String[] name() default {};
109108

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnSingleCandidate.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,11 +23,10 @@
2323
import java.lang.annotation.Target;
2424

2525
import org.springframework.beans.factory.BeanFactory;
26-
import org.springframework.context.ApplicationContext;
2726
import org.springframework.context.annotation.Conditional;
2827

2928
/**
30-
* {@link Conditional} that only matches when the specified bean class is already
29+
* {@link Conditional} that only matches when a bean of the specified class is already
3130
* contained in the {@link BeanFactory} and a single candidate can be determined.
3231
* <p>
3332
* The condition will also match if multiple matching bean instances are already contained
@@ -49,8 +48,8 @@
4948
public @interface ConditionalOnSingleCandidate {
5049

5150
/**
52-
* The class type of bean that should be checked. The condition match if the class
53-
* specified is contained in the {@link ApplicationContext} and a primary candidate
51+
* The class type of bean that should be checked. The condition matches if a bean of
52+
* the class specified is contained in the {@link BeanFactory} and a primary candidate
5453
* exists in case of multiple instances.
5554
* <p>
5655
* This attribute may <strong>not</strong> be used in conjunction with
@@ -60,8 +59,8 @@
6059
Class<?> value() default Object.class;
6160

6261
/**
63-
* The class type name of bean that should be checked. The condition matches if the
64-
* class specified is contained in the {@link ApplicationContext} and a primary
62+
* The class type name of bean that should be checked. The condition matches if a bean
63+
* of the class specified is contained in the {@link BeanFactory} and a primary
6564
* candidate exists in case of multiple instances.
6665
* <p>
6766
* This attribute may <strong>not</strong> be used in conjunction with

0 commit comments

Comments
 (0)