diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AliasFor.java b/spring-core/src/main/java/org/springframework/core/annotation/AliasFor.java index c116695245..afde3cded2 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AliasFor.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AliasFor.java @@ -41,10 +41,11 @@ import java.lang.annotation.Target; * hierarchy. In fact, with {@code @AliasFor} it is even possible to declare * an alias for the {@code value} attribute of a meta-annotation. *
In {@code @ContextConfiguration}, {@code value} and {@code locations} + * are explicit aliases for each other. + * *
public @interface ContextConfiguration { * * @AliasFor("locations") @@ -112,14 +118,24 @@ import java.lang.annotation.Target; * }* *
In {@code @XmlTestConfig}, {@code xmlFiles} is an explicit alias for + * {@code locations} in {@code @ContextConfiguration}. In other words, + * {@code xmlFiles} overrides the {@code locations} attribute in + * {@code @ContextConfiguration}. + * *
@ContextConfiguration - * public @interface MyTestConfig { + * public @interface XmlTestConfig { * * @AliasFor(annotation = ContextConfiguration.class, attribute = "locations") * String[] xmlFiles(); * }* *
In {@code @MyTestConfig}, {@code value}, {@code groovyScripts}, and + * {@code xmlFiles} are all explicit meta-annotation attribute overrides for + * the {@code locations} attribute in {@code @ContextConfiguration}. These + * three attributes are therefore also implicit aliases for each other. + * *
@ContextConfiguration * public @interface MyTestConfig { * @@ -133,6 +149,25 @@ import java.lang.annotation.Target; * String[] xmlFiles() default {}; * }* + *
In {@code @GroovyOrXmlTestConfig}, {@code groovy} is an explicit + * override for the {@code groovyScripts} attribute in {@code @MyTestConfig}; + * whereas, {@code xml} is an explicit override for the {@code locations} + * attribute in {@code @ContextConfiguration}. Furthermore, {@code groovy} + * and {@code xml} are transitive implicit aliases for each other, since they + * both effectively override the {@code locations} attribute in + * {@code @ContextConfiguration}. + * + *
@MyTestConfig + * public @interface GroovyOrXmlTestConfig { + * + * @AliasFor(annotation = MyTestConfig.class, attribute = "groovyScripts") + * String[] groovy() default {}; + * + * @AliasFor(annotation = ContextConfiguration.class, attribute = "locations") + * String[] xml() default {}; + * }+ * *
As of Spring Framework 4.2, several annotations within core Spring * have been updated to use {@code @AliasFor} to configure their internal