Skip to content

Commit 6804aad

Browse files
committed
Update reference manual regarding supported web scopes
1 parent e281090 commit 6804aad

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

src/asciidoc/core-beans.adoc

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,7 @@ the __scope__ of the objects created from a particular bean definition. This app
22742274
powerful and flexible in that you can __choose__ the scope of the objects you create
22752275
through configuration instead of having to bake in the scope of an object at the Java
22762276
class level. Beans can be defined to be deployed in one of a number of scopes: out of
2277-
the box, the Spring Framework supports five scopes, three of which are available only if
2277+
the box, the Spring Framework supports seven scopes, five of which are available only if
22782278
you use a web-aware `ApplicationContext`.
22792279

22802280
The following scopes are supported out of the box. You can also create
@@ -2301,14 +2301,18 @@ The following scopes are supported out of the box. You can also create
23012301
| Scopes a single bean definition to the lifecycle of an HTTP `Session`. Only valid in
23022302
the context of a web-aware Spring `ApplicationContext`.
23032303

2304-
| <<beans-factory-scopes-global-session,global session>>
2304+
| <<beans-factory-scopes-global-session,globalSession>>
23052305
| Scopes a single bean definition to the lifecycle of a global HTTP `Session`. Typically
2306-
only valid when used in a portlet context. Only valid in the context of a web-aware
2306+
only valid when used in a Portlet context. Only valid in the context of a web-aware
23072307
Spring `ApplicationContext`.
23082308

23092309
| <<beans-factory-scopes-application,application>>
23102310
| Scopes a single bean definition to the lifecycle of a `ServletContext`. Only valid in
23112311
the context of a web-aware Spring `ApplicationContext`.
2312+
2313+
| <<websocket-stomp-websocket-scope,websocket>>
2314+
| Scopes a single bean definition to the lifecycle of a `WebSocket`. Only valid in
2315+
the context of a web-aware Spring `ApplicationContext`.
23122316
|===
23132317

23142318
[NOTE]
@@ -2418,22 +2422,22 @@ runtime more than once, see <<beans-factory-method-injection>>
24182422

24192423

24202424
[[beans-factory-scopes-other]]
2421-
=== Request, session, and global session scopes
2425+
=== request, session, globalSession, application, and websocket scopes
24222426

2423-
The `request`, `session`, and `global session` scopes are __only__ available if you use
2424-
a web-aware Spring `ApplicationContext` implementation (such as
2425-
`XmlWebApplicationContext`). If you use these scopes with regular Spring IoC containers
2426-
such as the `ClassPathXmlApplicationContext`, you get an `IllegalStateException`
2427-
complaining about an unknown bean scope.
2427+
The `request`, `session`, `globalSession`, `application`, and `websocket` scopes are
2428+
__only__ available if you use a web-aware Spring `ApplicationContext` implementation
2429+
(such as `XmlWebApplicationContext`). If you use these scopes with regular Spring IoC
2430+
containers such as the `ClassPathXmlApplicationContext`, an `IllegalStateException` will
2431+
be thrown complaining about an unknown bean scope.
24282432

24292433

24302434
[[beans-factory-scopes-other-web-configuration]]
24312435
==== Initial web configuration
24322436

2433-
To support the scoping of beans at the `request`, `session`, and `global session` levels
2434-
(web-scoped beans), some minor initial configuration is required before you define your
2435-
beans. (This initial setup is __not__ required for the standard scopes, `singleton` and
2436-
`prototype`.)
2437+
To support the scoping of beans at the `request`, `session`, `globalSession`,
2438+
`application`, and `websocket` levels (web-scoped beans), some minor initial
2439+
configuration is required before you define your beans. (This initial setup is __not__
2440+
required for the standard scopes, `singleton` and `prototype`.)
24372441

24382442
How you accomplish this initial setup depends on your particular Servlet environment.
24392443

@@ -2543,15 +2547,15 @@ Consider the following bean definition:
25432547
<bean id="userPreferences" class="com.foo.UserPreferences" scope="globalSession"/>
25442548
----
25452549

2546-
The `global session` scope is similar to the standard HTTP `Session` scope
2550+
The `globalSession` scope is similar to the standard HTTP `Session` scope
25472551
(<<beans-factory-scopes-session,described above>>), and applies only in the context of
25482552
portlet-based web applications. The portlet specification defines the notion of a global
25492553
`Session` that is shared among all portlets that make up a single portlet web
2550-
application. Beans defined at the `global session` scope are scoped (or bound) to the
2554+
application. Beans defined at the `globalSession` scope are scoped (or bound) to the
25512555
lifetime of the global portlet `Session`.
25522556

25532557
If you write a standard Servlet-based web application and you define one or more beans
2554-
as having `global session` scope, the standard HTTP `Session` scope is used, and no
2558+
as having `globalSession` scope, the standard HTTP `Session` scope is used, and no
25552559
error is raised.
25562560

25572561

src/asciidoc/web-websocket.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,7 @@ public class MyController {
20102010
}
20112011
----
20122012

2013-
It is also possible to declare a Spring-managed bean in the `"websocket"` scope.
2013+
It is also possible to declare a Spring-managed bean in the `websocket` scope.
20142014
WebSocket-scoped beans can be injected into controllers and any channel interceptors
20152015
registered on the "clientInboundChannel". Those are typically singletons and live
20162016
longer than any individual WebSocket session. Therefore you will need to use a
@@ -2020,7 +2020,7 @@ scope proxy mode for WebSocket-scoped beans:
20202020
[subs="verbatim,quotes"]
20212021
----
20222022
@Component
2023-
@Scope(name = "websocket", proxyMode = ScopedProxyMode.TARGET_CLASS)
2023+
@Scope(scopeName = "websocket", proxyMode = ScopedProxyMode.TARGET_CLASS)
20242024
public class MyBean {
20252025
20262026
@PostConstruct

0 commit comments

Comments
 (0)