@@ -2422,7 +2422,7 @@ runtime more than once, see <<beans-factory-method-injection>>
24222422
24232423
24242424[[beans-factory-scopes-other]]
2425- === request , session, globalSession , application, and websocket scopes
2425+ === Request , session, global session , application, and WebSocket scopes
24262426
24272427The `request`, `session`, `globalSession`, `application`, and `websocket` scopes are
24282428__only__ available if you use a web-aware Spring `ApplicationContext` implementation
@@ -2497,7 +2497,7 @@ down the call chain.
24972497[[beans-factory-scopes-request]]
24982498==== Request scope
24992499
2500- Consider the following bean definition:
2500+ Consider the following XML configuration for a bean definition:
25012501
25022502[source,xml,indent=0]
25032503[subs="verbatim,quotes"]
@@ -2513,11 +2513,24 @@ created from the same `loginAction` bean definition will not see these changes i
25132513they are particular to an individual request. When the request completes processing, the
25142514bean that is scoped to the request is discarded.
25152515
2516+ When using Java Config, the `@RequestScope` annotation can be used to assign a component
2517+ to the `request` scope.
2518+
2519+ [source,java,indent=0]
2520+ [subs="verbatim,quotes"]
2521+ ----
2522+ @RequestScope
2523+ @Component
2524+ public class LoginAction {
2525+ // ...
2526+ }
2527+ ----
2528+
25162529
25172530[[beans-factory-scopes-session]]
25182531==== Session scope
25192532
2520- Consider the following bean definition:
2533+ Consider the following XML configuration for a bean definition:
25212534
25222535[source,xml,indent=0]
25232536[subs="verbatim,quotes"]
@@ -2535,6 +2548,19 @@ changes in state, because they are particular to an individual HTTP `Session`. W
25352548HTTP `Session` is eventually discarded, the bean that is scoped to that particular HTTP
25362549`Session` is also discarded.
25372550
2551+ When using Java Config, the `@SessionScope` annotation can be used to assign a component
2552+ to the `session` scope.
2553+
2554+ [source,java,indent=0]
2555+ [subs="verbatim,quotes"]
2556+ ----
2557+ @SessionScope
2558+ @Component
2559+ public class UserPreferences {
2560+ // ...
2561+ }
2562+ ----
2563+
25382564
25392565[[beans-factory-scopes-global-session]]
25402566==== Global session scope
@@ -2562,7 +2588,7 @@ error is raised.
25622588[[beans-factory-scopes-application]]
25632589==== Application scope
25642590
2565- Consider the following bean definition:
2591+ Consider the following XML configuration for a bean definition:
25662592
25672593[source,xml,indent=0]
25682594[subs="verbatim,quotes"]
@@ -2578,6 +2604,19 @@ differs in two important ways: It is a singleton per `ServletContext`, not per S
25782604'ApplicationContext' (for which there may be several in any given web application),
25792605and it is actually exposed and therefore visible as a `ServletContext` attribute.
25802606
2607+ When using Java Config, the `@ApplicationScope` annotation can be used to assign a
2608+ component to the `application` scope.
2609+
2610+ [source,java,indent=0]
2611+ [subs="verbatim,quotes"]
2612+ ----
2613+ @ApplicationScope
2614+ @Component
2615+ public class AppPreferences {
2616+ // ...
2617+ }
2618+ ----
2619+
25812620
25822621[[beans-factory-scopes-other-injection]]
25832622==== Scoped beans as dependencies
0 commit comments