Skip to content

Commit d96738d

Browse files
committed
Revised indexer implementation
Issue: SPR-11890
1 parent c42d44a commit d96738d

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

spring-context/src/main/java/org/springframework/stereotype/Indexed.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 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,21 +24,21 @@
2424

2525
/**
2626
* Indicate that the annotated element represents a stereotype for the index.
27-
* <p>
28-
* The {@code CandidateComponentsIndex} is an alternative to classpath
27+
*
28+
* <p>The {@code CandidateComponentsIndex} is an alternative to classpath
2929
* scanning that uses a metadata file generated at compilation time. The
3030
* index allows retrieving the candidate components (i.e. fully qualified
3131
* name) based on a stereotype. This annotation instructs the generator to
3232
* index the element on which the annotated element is present or if it
3333
* implements or extends from the annotated element. The stereotype is the
3434
* fully qualified name of the annotated element.
35-
* <p>
36-
* Consider the default {@link Component} annotation that is meta-annotated
35+
*
36+
* <p>Consider the default {@link Component} annotation that is meta-annotated
3737
* with this annotation. If a component is annotated with {@link Component},
3838
* an entry for that component will be added to the index using the
3939
* {@code org.springframework.stereotype.Component} stereotype.
40-
* <p>
41-
* This annotation is also honored on meta-annotations. Consider this
40+
*
41+
* <p>This annotation is also honored on meta-annotations. Consider this
4242
* custom annotation:
4343
* <pre class="code">
4444
* package com.example;
@@ -50,20 +50,23 @@
5050
* &#064;Service
5151
* public @interface PrivilegedService { ... }
5252
* </pre>
53-
* If this annotation is present on an type, it will be indexed with two
53+
*
54+
* If the above annotation is present on a type, it will be indexed with two
5455
* stereotypes: {@code org.springframework.stereotype.Component} and
5556
* {@code com.example.PrivilegedService}. While {@link Service} isn't directly
5657
* annotated with {@code Indexed}, it is meta-annotated with {@link Component}.
57-
* <p>
58-
* It is also possible to index all implementations of a certain interface or
59-
* all the sub-classes of a given class by adding {@code @Indexed} on it.
58+
*
59+
* <p>It is also possible to index all implementations of a certain interface or
60+
* all the subclasses of a given class by adding {@code @Indexed} on it.
61+
*
6062
* Consider this base interface:
6163
* <pre class="code">
6264
* package com.example;
6365
*
6466
* &#064;Indexed
6567
* public interface AdminService { ... }
6668
* </pre>
69+
*
6770
* Now, consider an implementation of this {@code AdminService} somewhere:
6871
* <pre class="code">
6972
* package com.example.foo;
@@ -72,13 +75,14 @@
7275
*
7376
* public class ConfigurationAdminService implements AdminService { ... }
7477
* </pre>
78+
*
7579
* Because this class implements an interface that is indexed, it will be
7680
* automatically included with the {@code com.example.AdminService} stereotype.
77-
* If there are more {@code @Indexed} interfaces and/or super classes in the
81+
* If there are more {@code @Indexed} interfaces and/or superclasses in the
7882
* hierarchy, the class will map to all their stereotypes.
7983
*
8084
* @author Stephane Nicoll
81-
* @since 4.3.3
85+
* @since 5.0
8286
*/
8387
@Target(ElementType.TYPE)
8488
@Retention(RetentionPolicy.RUNTIME)

spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -38,6 +38,7 @@ public class CandidateComponentsIndexLoaderTests {
3838
@Rule
3939
public final ExpectedException thrown = ExpectedException.none();
4040

41+
4142
@Test
4243
public void validateIndexIsDisabledByDefault() {
4344
CandidateComponentsIndex index = CandidateComponentsIndexLoader.loadIndex(null);
@@ -101,7 +102,7 @@ public void loadIndexNoEntry() throws IOException {
101102
@Test
102103
public void loadIndexWithException() throws IOException {
103104
final IOException cause = new IOException("test exception");
104-
this.thrown.expect(IllegalArgumentException.class);
105+
this.thrown.expect(IllegalStateException.class);
105106
this.thrown.expectMessage("Unable to load indexes");
106107
this.thrown.expectCause(is(cause));
107108
CandidateComponentsIndexLoader.loadIndex(new CandidateComponentsTestClassLoader(

0 commit comments

Comments
 (0)