diff --git a/spring-context/src/main/java/org/springframework/stereotype/Indexed.java b/spring-context/src/main/java/org/springframework/stereotype/Indexed.java index 17d2512e791..892f48a75ed 100644 --- a/spring-context/src/main/java/org/springframework/stereotype/Indexed.java +++ b/spring-context/src/main/java/org/springframework/stereotype/Indexed.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,21 +24,21 @@ import java.lang.annotation.Target; /** * Indicate that the annotated element represents a stereotype for the index. - *
- * The {@code CandidateComponentsIndex} is an alternative to classpath + * + *
The {@code CandidateComponentsIndex} is an alternative to classpath * scanning that uses a metadata file generated at compilation time. The * index allows retrieving the candidate components (i.e. fully qualified * name) based on a stereotype. This annotation instructs the generator to * index the element on which the annotated element is present or if it * implements or extends from the annotated element. The stereotype is the * fully qualified name of the annotated element. - *
- * Consider the default {@link Component} annotation that is meta-annotated + * + *
Consider the default {@link Component} annotation that is meta-annotated * with this annotation. If a component is annotated with {@link Component}, * an entry for that component will be added to the index using the * {@code org.springframework.stereotype.Component} stereotype. - *
- * This annotation is also honored on meta-annotations. Consider this + * + *
This annotation is also honored on meta-annotations. Consider this * custom annotation: *
* package com.example;
@@ -50,13 +50,15 @@ import java.lang.annotation.Target;
* @Service
* public @interface PrivilegedService { ... }
*
- * If this annotation is present on an type, it will be indexed with two
+ *
+ * If the above annotation is present on a type, it will be indexed with two
* stereotypes: {@code org.springframework.stereotype.Component} and
* {@code com.example.PrivilegedService}. While {@link Service} isn't directly
* annotated with {@code Indexed}, it is meta-annotated with {@link Component}.
- * - * It is also possible to index all implementations of a certain interface or - * all the sub-classes of a given class by adding {@code @Indexed} on it. + * + *
It is also possible to index all implementations of a certain interface or + * all the subclasses of a given class by adding {@code @Indexed} on it. + * * Consider this base interface: *
* package com.example;
@@ -64,6 +66,7 @@ import java.lang.annotation.Target;
* @Indexed
* public interface AdminService { ... }
*
+ *
* Now, consider an implementation of this {@code AdminService} somewhere:
*
* package com.example.foo;
@@ -72,13 +75,14 @@ import java.lang.annotation.Target;
*
* public class ConfigurationAdminService implements AdminService { ... }
*
+ *
* Because this class implements an interface that is indexed, it will be
* automatically included with the {@code com.example.AdminService} stereotype.
- * If there are more {@code @Indexed} interfaces and/or super classes in the
+ * If there are more {@code @Indexed} interfaces and/or superclasses in the
* hierarchy, the class will map to all their stereotypes.
*
* @author Stephane Nicoll
- * @since 4.3.3
+ * @since 5.0
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
diff --git a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java
index 674c3c94811..3cf4ed38b11 100644
--- a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java
+++ b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ public class CandidateComponentsIndexLoaderTests {
@Rule
public final ExpectedException thrown = ExpectedException.none();
+
@Test
public void validateIndexIsDisabledByDefault() {
CandidateComponentsIndex index = CandidateComponentsIndexLoader.loadIndex(null);
@@ -101,7 +102,7 @@ public class CandidateComponentsIndexLoaderTests {
@Test
public void loadIndexWithException() throws IOException {
final IOException cause = new IOException("test exception");
- this.thrown.expect(IllegalArgumentException.class);
+ this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage("Unable to load indexes");
this.thrown.expectCause(is(cause));
CandidateComponentsIndexLoader.loadIndex(new CandidateComponentsTestClassLoader(