Skip to content

Commit 43b5e21

Browse files
committed
Consistent alias declarations for value attribute on stereotypes
Issue: SPR-16066
1 parent 24ca8cc commit 43b5e21

File tree

7 files changed

+19
-24
lines changed

7 files changed

+19
-24
lines changed

spring-context/src/main/java/org/springframework/context/annotation/Configuration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import org.springframework.beans.factory.annotation.Autowired;
2626
import org.springframework.beans.factory.annotation.Value;
27+
import org.springframework.core.annotation.AliasFor;
2728
import org.springframework.stereotype.Component;
2829

2930
/**
@@ -412,9 +413,10 @@
412413
* component scanning or supplied directly to a {@link AnnotationConfigApplicationContext}.
413414
* If the Configuration class is registered as a traditional XML bean definition,
414415
* the name/id of the bean element will take precedence.
415-
* @return the specified bean name, if any
416+
* @return the suggested component name, if any (or empty String otherwise)
416417
* @see org.springframework.beans.factory.support.DefaultBeanNameGenerator
417418
*/
419+
@AliasFor(annotation = Component.class)
418420
String value() default "";
419421

420422
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 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.
@@ -48,7 +48,7 @@
4848
/**
4949
* The value may indicate a suggestion for a logical component name,
5050
* to be turned into a Spring bean in case of an autodetected component.
51-
* @return the suggested component name, if any
51+
* @return the suggested component name, if any (or empty String otherwise)
5252
*/
5353
String value() default "";
5454

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 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.
@@ -48,7 +48,7 @@
4848
/**
4949
* The value may indicate a suggestion for a logical component name,
5050
* to be turned into a Spring bean in case of an autodetected component.
51-
* @return the suggested component name, if any
51+
* @return the suggested component name, if any (or empty String otherwise)
5252
*/
5353
@AliasFor(annotation = Component.class)
5454
String value() default "";

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

Lines changed: 2 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.
@@ -64,7 +64,7 @@
6464
/**
6565
* The value may indicate a suggestion for a logical component name,
6666
* to be turned into a Spring bean in case of an autodetected component.
67-
* @return the suggested component name, if any
67+
* @return the suggested component name, if any (or empty String otherwise)
6868
*/
6969
@AliasFor(annotation = Component.class)
7070
String value() default "";

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 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.
@@ -50,7 +50,7 @@
5050
/**
5151
* The value may indicate a suggestion for a logical component name,
5252
* to be turned into a Spring bean in case of an autodetected component.
53-
* @return the suggested component name, if any
53+
* @return the suggested component name, if any (or empty String otherwise)
5454
*/
5555
@AliasFor(annotation = Component.class)
5656
String value() default "";

spring-core/src/test/java/org/springframework/stereotype/Component.java

Lines changed: 4 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.
@@ -27,17 +27,8 @@
2727
* Such classes are considered as candidates for auto-detection
2828
* when using annotation-based configuration and classpath scanning.
2929
*
30-
* <p>Other class-level annotations may be considered as identifying
31-
* a component as well, typically a special kind of component:
32-
* e.g. the {@link Repository @Repository} annotation or AspectJ's
33-
* {@link org.aspectj.lang.annotation.Aspect @Aspect} annotation.
34-
*
3530
* @author Mark Fisher
3631
* @since 2.5
37-
* @see Repository
38-
* @see Service
39-
* @see Controller
40-
* @see org.springframework.context.annotation.ClassPathBeanDefinitionScanner
4132
*/
4233
@Target(ElementType.TYPE)
4334
@Retention(RetentionPolicy.RUNTIME)
@@ -48,8 +39,8 @@
4839
/**
4940
* The value may indicate a suggestion for a logical component name,
5041
* to be turned into a Spring bean in case of an autodetected component.
51-
* @return the suggested component name, if any
42+
* @return the suggested component name, if any (or empty String otherwise)
5243
*/
53-
public abstract String value() default "";
44+
String value() default "";
5445

55-
}
46+
}

spring-web/src/main/java/org/springframework/web/bind/annotation/RestController.java

Lines changed: 4 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.
@@ -22,6 +22,7 @@
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
2424

25+
import org.springframework.core.annotation.AliasFor;
2526
import org.springframework.stereotype.Controller;
2627

2728
/**
@@ -51,9 +52,10 @@
5152
/**
5253
* The value may indicate a suggestion for a logical component name,
5354
* to be turned into a Spring bean in case of an autodetected component.
54-
* @return the suggested component name, if any
55+
* @return the suggested component name, if any (or empty String otherwise)
5556
* @since 4.0.1
5657
*/
58+
@AliasFor(annotation = Controller.class)
5759
String value() default "";
5860

5961
}

0 commit comments

Comments
 (0)