Introduce 'value' alias for 'attribute' in @AliasFor

SPR-11512 introduced support for annotation attribute aliases via
@AliasFor, requiring the explicit declaration of the 'attribute'
attribute. However, for aliases within an annotation, this explicit
declaration is unnecessary.

This commit improves the readability of alias pairs declared within an
annotation by introducing a 'value' attribute in @AliasFor that is an
alias for the existing 'attribute' attribute. This allows annotations
such as @ContextConfiguration from the spring-test module to declare
aliases as follows.

public @interface ContextConfiguration {

     @AliasFor("locations")
     String[] value() default {};

     @AliasFor("value")
     String[] locations() default {};

    // ...
}

Issue: SPR-13289
This commit is contained in:
Sam Brannen
2015-07-29 15:27:06 +02:00
parent 90493f49e6
commit 725292081e
35 changed files with 170 additions and 84 deletions

View File

@@ -60,7 +60,7 @@ public @interface Transactional {
* Alias for {@link #transactionManager}.
* @see #transactionManager
*/
@AliasFor(attribute = "transactionManager")
@AliasFor("transactionManager")
String value() default "";
/**
@@ -72,7 +72,7 @@ public @interface Transactional {
* @since 4.2
* @see #value
*/
@AliasFor(attribute = "value")
@AliasFor("value")
String transactionManager() default "";
/**

View File

@@ -59,7 +59,7 @@ public @interface TransactionalEventListener {
/**
* Alias for {@link #classes}.
*/
@AliasFor(attribute = "classes")
@AliasFor("classes")
Class<?>[] value() default {};
/**
@@ -68,7 +68,7 @@ public @interface TransactionalEventListener {
* may or may not be specified. When this attribute is specified with more
* than one value, the method must not have a parameter.
*/
@AliasFor(attribute = "value")
@AliasFor("value")
Class<?>[] classes() default {};
/**