Document web scope annotations in the reference manual
Issue: SPR-13994
This commit is contained in:
parent
6804aad06f
commit
47d77252d3
|
@ -2422,7 +2422,7 @@ runtime more than once, see <<beans-factory-method-injection>>
|
|||
|
||||
|
||||
[[beans-factory-scopes-other]]
|
||||
=== request, session, globalSession, application, and websocket scopes
|
||||
=== Request, session, global session, application, and WebSocket scopes
|
||||
|
||||
The `request`, `session`, `globalSession`, `application`, and `websocket` scopes are
|
||||
__only__ available if you use a web-aware Spring `ApplicationContext` implementation
|
||||
|
@ -2497,7 +2497,7 @@ down the call chain.
|
|||
[[beans-factory-scopes-request]]
|
||||
==== Request scope
|
||||
|
||||
Consider the following bean definition:
|
||||
Consider the following XML configuration for a bean definition:
|
||||
|
||||
[source,xml,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
|
@ -2513,11 +2513,24 @@ created from the same `loginAction` bean definition will not see these changes i
|
|||
they are particular to an individual request. When the request completes processing, the
|
||||
bean that is scoped to the request is discarded.
|
||||
|
||||
When using Java Config, the `@RequestScope` annotation can be used to assign a component
|
||||
to the `request` scope.
|
||||
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@RequestScope
|
||||
@Component
|
||||
public class LoginAction {
|
||||
// ...
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
[[beans-factory-scopes-session]]
|
||||
==== Session scope
|
||||
|
||||
Consider the following bean definition:
|
||||
Consider the following XML configuration for a bean definition:
|
||||
|
||||
[source,xml,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
|
@ -2535,6 +2548,19 @@ changes in state, because they are particular to an individual HTTP `Session`. W
|
|||
HTTP `Session` is eventually discarded, the bean that is scoped to that particular HTTP
|
||||
`Session` is also discarded.
|
||||
|
||||
When using Java Config, the `@SessionScope` annotation can be used to assign a component
|
||||
to the `session` scope.
|
||||
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@SessionScope
|
||||
@Component
|
||||
public class UserPreferences {
|
||||
// ...
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
[[beans-factory-scopes-global-session]]
|
||||
==== Global session scope
|
||||
|
@ -2562,7 +2588,7 @@ error is raised.
|
|||
[[beans-factory-scopes-application]]
|
||||
==== Application scope
|
||||
|
||||
Consider the following bean definition:
|
||||
Consider the following XML configuration for a bean definition:
|
||||
|
||||
[source,xml,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
|
@ -2578,6 +2604,19 @@ differs in two important ways: It is a singleton per `ServletContext`, not per S
|
|||
'ApplicationContext' (for which there may be several in any given web application),
|
||||
and it is actually exposed and therefore visible as a `ServletContext` attribute.
|
||||
|
||||
When using Java Config, the `@ApplicationScope` annotation can be used to assign a
|
||||
component to the `application` scope.
|
||||
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@ApplicationScope
|
||||
@Component
|
||||
public class AppPreferences {
|
||||
// ...
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
[[beans-factory-scopes-other-injection]]
|
||||
==== Scoped beans as dependencies
|
||||
|
|
|
@ -674,8 +674,12 @@ Spring 4.3 also improves the caching abstraction as follows:
|
|||
* Built-in support for <<mvc-ann-requestmapping-head-options,HTTP HEAD and HTTP OPTIONS>>.
|
||||
* New `@GetMapping`, `@PostMapping`, `@PutMapping`, `@DeleteMapping`, and `@PatchMapping`
|
||||
_composed annotations_ for `@RequestMapping`.
|
||||
** See <<mvc-ann-requestmapping-composed>> for details.
|
||||
* New `@RequestScope`, `@SessionScope`, and `@ApplicationScope` _composed annotations_ for web scopes.
|
||||
** See <<mvc-ann-requestmapping-composed,Composed @RequestMapping Variants>> for details.
|
||||
* New `@RequestScope`, `@SessionScope`, and `@ApplicationScope` _composed annotations_
|
||||
for web scopes.
|
||||
** See <<beans-factory-scopes-request,Request scope>>,
|
||||
<<beans-factory-scopes-session,Session scope>>, and
|
||||
<<beans-factory-scopes-application,Application scope>> for details.
|
||||
* New `@RestControllerAdvice` annotation with combined `@ControllerAdvice` with `@ResponseBody` semantics.
|
||||
* `@ResponseStatus` is now supported at the class level and inherited by all methods.
|
||||
* New `@SessionAttribute` annotation for access to session attributes (see <<mvc-ann-sessionattrib-global, example>>).
|
||||
|
|
Loading…
Reference in New Issue