Introduce value attribute in @RestController

Stereotype annotations should support a 'value' attribute for
specifying the name of the Spring-managed component; however,
@RestController currently does not provide such an attribute.

This commit introduces a 'value' attribute in @RestController so that
developers can provide custom names for components annotated with
@RestController.

Issue: SPR-11360
This commit is contained in:
Sam Brannen
2014-01-27 12:04:35 +01:00
parent bb28d198f5
commit 78542777d6
2 changed files with 86 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@@ -28,11 +28,12 @@ import org.springframework.stereotype.Controller;
* A convenience annotation that is itself annotated with {@link Controller @Controller}
* and {@link ResponseBody @ResponseBody}.
* <p>
* Types that carry this annotation are treated as
* controllers where {@link RequestMapping @RequestMapping} methods assume
* Types that carry this annotation are treated as controllers where
* {@link RequestMapping @RequestMapping} methods assume
* {@link ResponseBody @ResponseBody} semantics by default.
*
* @author Rossen Stoyanchev
* @author Sam Brannen
* @since 4.0
*/
@Target(ElementType.TYPE)
@@ -42,4 +43,12 @@ import org.springframework.stereotype.Controller;
@ResponseBody
public @interface RestController {
/**
* The value may indicate a suggestion for a logical component name,
* to be turned into a Spring bean in case of an autodetected component.
* @return the suggested component name, if any
* @since 4.0.1
*/
String value() default "";
}