Skip to content

Commit 0fc7c41

Browse files
committed
Improve Javadoc for CandidateComponentsIndex
1 parent 8f29c71 commit 0fc7c41

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndex.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
import org.springframework.util.MultiValueMap;
3030

3131
/**
32-
* Provide access to the candidates that are defined in {@code META-INF/spring.components}.
32+
* Provide access to the candidates that are defined in {@code META-INF/spring.components}
33+
* component index files (see {@link #CandidateComponentsIndex(List)}) or registered
34+
* programmatically (see {@link #CandidateComponentsIndex()}).
3335
*
3436
* <p>An arbitrary number of stereotypes can be registered (and queried) on the index: a
3537
* typical example is the fully qualified name of an annotation that flags the class for
@@ -42,7 +44,7 @@
4244
*
4345
* <p>The {@code type} is usually the fully qualified name of a class, though this is
4446
* not a rule. Similarly, the {@code stereotype} is usually the fully qualified name of
45-
* a target type but it can be any marker really.
47+
* an annotation type, but it can be any marker really.
4648
*
4749
* @author Stephane Nicoll
4850
* @author Juergen Hoeller
@@ -60,7 +62,7 @@ public class CandidateComponentsIndex {
6062

6163

6264
/**
63-
* Create a new index instance from parsed components index files.
65+
* Create a new index instance from parsed component index files.
6466
*/
6567
CandidateComponentsIndex(List<Properties> content) {
6668
for (Properties entry : content) {
@@ -77,15 +79,19 @@ public class CandidateComponentsIndex {
7779
/**
7880
* Create a new index instance for programmatic population.
7981
* @since 7.0
82+
* @see #registerScan(String...)
83+
* @see #registerCandidateType(String, String...)
8084
*/
8185
public CandidateComponentsIndex() {
8286
this.complete = false;
8387
}
8488

8589

8690
/**
87-
* Register the given base packages (or base package patterns) as scanned.
91+
* Programmatically register the given base packages (or base package patterns)
92+
* as scanned.
8893
* @since 7.0
94+
* @see #registerCandidateType(String, String...)
8995
*/
9096
public void registerScan(String... basePackages) {
9197
Collections.addAll(this.registeredScans, basePackages);
@@ -94,13 +100,14 @@ public void registerScan(String... basePackages) {
94100
/**
95101
* Return the registered base packages (or base package patterns).
96102
* @since 7.0
103+
* @see #registerScan(String...)
97104
*/
98105
public Set<String> getRegisteredScans() {
99106
return this.registeredScans;
100107
}
101108

102109
/**
103-
* Determine whether this index contains entries for the given base package
110+
* Determine whether this index contains an entry for the given base package
104111
* (or base package pattern).
105112
* @since 7.0
106113
*/
@@ -111,7 +118,11 @@ public boolean hasScannedPackage(String packageName) {
111118

112119
/**
113120
* Programmatically register one or more stereotypes for the given candidate type.
121+
* <p>Note that the containing packages for candidates are not automatically
122+
* considered scanned packages. Make sure to call {@link #registerScan(String...)}
123+
* with the scan-specific base package accordingly.
114124
* @since 7.0
125+
* @see #registerScan(String...)
115126
*/
116127
public void registerCandidateType(String type, String... stereotypes) {
117128
for (String stereotype : stereotypes) {
@@ -120,7 +131,7 @@ public void registerCandidateType(String type, String... stereotypes) {
120131
}
121132

122133
/**
123-
* Return the registered stereotypes packages (or base package patterns).
134+
* Return the registered stereotype packages (or base package patterns).
124135
* @since 7.0
125136
*/
126137
public Set<String> getRegisteredStereotypes() {
@@ -145,6 +156,7 @@ public Set<String> getCandidateTypes(String basePackage, String stereotype) {
145156
return Collections.emptySet();
146157
}
147158

159+
148160
private static boolean matchPackage(String basePackage, String packageName) {
149161
if (pathMatcher.isPattern(basePackage)) {
150162
return pathMatcher.match(basePackage, packageName);

0 commit comments

Comments
 (0)