Skip to content

Commit 00a3afc

Browse files
Jay Bryantbclozel
authored andcommitted
Edit the Web chapter of the reference documentation
I edited for spelling, punctuation, grammar, usage, and corporate voice. I also added links and cross-references.
1 parent b29a278 commit 00a3afc

17 files changed

+4849
-4028
lines changed

src/docs/asciidoc/web-reactive.adoc

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
:tabsize: 4
88
:docinfo1:
99

10-
This part of the documentation covers support for reactive stack, web applications built on a
10+
This part of the documentation covers support for reactive-stack web applications built on a
1111
http://www.reactive-streams.org/[Reactive Streams] API to run on non-blocking
12-
servers such as Netty, Undertow, and Servlet 3.1+ containers. Individual chapters cover
12+
servers, such as Netty, Undertow, and Servlet 3.1+ containers. Individual chapters cover
1313
the <<webflux,Spring WebFlux>> framework,
14-
the reactive <<webflux-client,WebClient>>, support for <<webflux-test>>,
15-
and <<webflux-reactive-libraries>>. For Servlet stack, web applications, please see
14+
the reactive <<webflux-client,`WebClient`>>, support for <<webflux-test, testing>>,
15+
and <<webflux-reactive-libraries, reactive libraries>>. For Servlet-stack web applications, see
1616
<<web.adoc#spring-web,Web on Servlet Stack>>.
1717

1818
include::web/webflux.adoc[leveloffset=+1]
@@ -29,50 +29,46 @@ include::web/webflux-websocket.adoc[leveloffset=+1]
2929

3030
The `spring-test` module provides mock implementations of `ServerHttpRequest`,
3131
`ServerHttpResponse`, and `ServerWebExchange`.
32-
See <<testing.adoc#mock-objects-web-reactive,Spring Web Reactive>> mock objects.
32+
See <<testing.adoc#mock-objects-web-reactive,Spring Web Reactive>> for a discussion of mock objects.
3333

34-
The <<testing.adoc#webtestclient,WebTestClient>> builds on these mock request and
35-
response objects to provide support for testing WebFlux applications without and HTTP
36-
server. The `WebTestClient` can be used for end-to-end integration tests too.
34+
<<testing.adoc#webtestclient,`WebTestClient`>> builds on these mock request and
35+
response objects to provide support for testing WebFlux applications without an HTTP
36+
server. You can use the `WebTestClient` for end-to-end integration tests, too.
3737

3838

3939

40-
41-
[[webflux-threading-model]]
42-
=== Threading model
43-
44-
40+
//[[webflux-threading-model]]
41+
//=== Threading model
42+
// TODO Once we have content for this heading, we should un-comment the heading and
43+
// anchor. Until then, we should leave it commented.
4544

4645

4746

4847
[[webflux-reactive-libraries]]
4948
== Reactive Libraries
5049

5150
`spring-webflux` depends on `reactor-core` and uses it internally to compose asynchronous
52-
logic and to provide Reactive Streams support. Generally WebFlux APIs return `Flux` or
53-
`Mono` -- since that's what's used internally, and leniently accept any Reactive Streams
54-
`Publisher` implementation as input. The use of `Flux` vs `Mono` is important because it
55-
helps to express cardinality -- e.g. whether a single or multiple async values are
56-
expected, and that can be essential for making decisions, for example when encoding or
57-
decoding HTTP messages.
51+
logic and to provide Reactive Streams support. Generally, WebFlux APIs return `Flux` or
52+
`Mono` (since those are used internally) and leniently accept any Reactive Streams
53+
`Publisher` implementation as input. The use of `Flux` versus `Mono` is important, because it
54+
helps to express cardinality -- for example, whether a single or multiple asynchronous values are
55+
expected, and that can be essential for making decisions (for example, when encoding or
56+
decoding HTTP messages).
5857

5958
For annotated controllers, WebFlux transparently adapts to the reactive library chosen by
6059
the application. This is done with the help of the
61-
{api-spring-framework}/core/ReactiveAdapterRegistry.html[ReactiveAdapterRegistry] which
60+
{api-spring-framework}/core/ReactiveAdapterRegistry.html[`ReactiveAdapterRegistry`], which
6261
provides pluggable support for reactive library and other asynchronous types. The registry
63-
has built-in support for RxJava and `CompletableFuture`, but others can be registered too.
62+
has built-in support for RxJava and `CompletableFuture`, but you can register others, too.
6463

65-
For functional APIs such as <<webflux-fn>>, the `WebClient`, and others, the general rules
66-
for WebFlux APIs apply -- `Flux` and `Mono` as return values, and Reactive Streams
64+
For functional APIs (such as <<webflux-fn>>, the `WebClient`, and others), the general rules
65+
for WebFlux APIs apply -- `Flux` and `Mono` as return values and a Reactive Streams
6766
`Publisher` as input. When a `Publisher`, whether custom or from another reactive library,
68-
is provided, it can only be treated as a stream with unknown semantics (0..N). If however
67+
is provided, it can be treated only as a stream with unknown semantics (0..N). If, however,
6968
the semantics are known, you can wrap it with `Flux` or `Mono.from(Publisher)` instead
7069
of passing the raw `Publisher`.
7170

72-
[NOTE]
73-
====
7471
For example, given a `Publisher` that is not a `Mono`, the Jackson JSON message writer
75-
expects multiple values. If the media type implies an infinite stream -- e.g.
76-
`"application/json+stream"`, values are written and flushed individually; otherwise
72+
expects multiple values. If the media type implies an infinite stream (for example,
73+
`application/json+stream`), values are written and flushed individually. Otherwise,
7774
values are buffered into a list and rendered as a JSON array.
78-
====

src/docs/asciidoc/web.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
:tabsize: 4
88
:docinfo1:
99

10-
This part of the documentation covers support for Servlet stack, web applications built on the
10+
This part of the documentation covers support for Servlet-stack web applications built on the
1111
Servlet API and deployed to Servlet containers. Individual chapters include <<mvc,Spring MVC>>,
1212
<<mvc-view,View Technologies>>, <<mvc-cors,CORS Support>>, and <<websocket,WebSocket Support>>.
13-
For reactive stack, web applications, go to <<web-reactive.adoc#spring-web-reactive,Web on Reactive Stack>>.
13+
For reactive-stack web applications, see <<web-reactive.adoc#spring-web-reactive,Web on Reactive Stack>>.
1414

1515
include::web/webmvc.adoc[leveloffset=+1]
1616

@@ -21,4 +21,3 @@ include::web/webmvc-test.adoc[leveloffset=+1]
2121
include::web/websocket.adoc[leveloffset=+1]
2222

2323
include::web/integration.adoc[leveloffset=+1]
24-

src/docs/asciidoc/web/integration.adoc

Lines changed: 66 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,59 @@
11
[[web-integration]]
22
= Other Web Frameworks
33

4-
5-
6-
7-
[[intro]]
8-
== Introduction
9-
104
This chapter details Spring's integration with third party web frameworks.
115

126
One of the core value propositions of the Spring Framework is that of enabling
13-
__choice__. In a general sense, Spring does not force one to use or buy into any
7+
_choice_. In a general sense, Spring does not force you to use or buy into any
148
particular architecture, technology, or methodology (although it certainly recommends
159
some over others). This freedom to pick and choose the architecture, technology, or
1610
methodology that is most relevant to a developer and their development team is
1711
arguably most evident in the web area, where Spring provides its own web framework
18-
(<<mvc,Spring MVC>>), while at the same time providing integration with a number of
12+
(<<mvc,Spring MVC>>) while, at the same time, providing integration with a number of
1913
popular third party web frameworks.
2014

2115

2216

23-
2417
[[web-integration-common]]
25-
== Common config
18+
== Common Configuration
2619
Before diving into the integration specifics of each supported web framework, let us
27-
first take a look at the Spring configuration that is __not__ specific to any one web
20+
first take a look at the Spring configuration that is not specific to any one web
2821
framework. (This section is equally applicable to Spring's own web framework, Spring
2922
MVC.)
3023

31-
One of the concepts (for want of a better word) espoused by (Spring's) lightweight
32-
application model is that of a layered architecture. Remember that in a 'classic'
33-
layered architecture, the web layer is but one of many layers; it serves as one of the
34-
entry points into a server side application and it delegates to service objects
35-
(facades) defined in a service layer to satisfy business specific (and
24+
One of the concepts (for want of a better word) espoused by Spring's lightweight
25+
application model is that of a layered architecture. Remember that in a "`classic`"
26+
layered architecture, the web layer is but one of many layers. It serves as one of the
27+
entry points into a server-side application, and it delegates to service objects
28+
(facades) that are defined in a service layer to satisfy business-specific (and
3629
presentation-technology agnostic) use cases. In Spring, these service objects, any other
37-
business-specific objects, data access objects, etc. exist in a distinct 'business
38-
context', which contains __no__ web or presentation layer objects (presentation objects
39-
such as Spring MVC controllers are typically configured in a distinct 'presentation
40-
context'). This section details how one configures a Spring container (a
41-
`WebApplicationContext`) that contains all of the 'business beans' in one's application.
30+
business-specific objects, data-access objects, and others exist in a distinct "`business
31+
context`", which contains no web or presentation layer objects (presentation objects
32+
,such as Spring MVC controllers, are typically configured in a distinct "`presentation
33+
context`"). This section details how you can configure a Spring container (a
34+
`WebApplicationContext`) that contains all of the 'business beans' in your application.
4235

43-
On to specifics: all that one need do is to declare a
36+
Moving on to specifics, all you one need to do is declare a
4437
{api-spring-framework}/web/context/ContextLoaderListener.html[`ContextLoaderListener`]
45-
in the standard Java EE servlet `web.xml` file of one's web application, and add a
38+
in the standard Java EE servlet `web.xml` file of your web application and add a
4639
`contextConfigLocation`<context-param/> section (in the same file) that defines which
4740
set of Spring XML configuration files to load.
4841

49-
Find below the <listener/> configuration:
42+
Consider the following `<listener/>` configuration:
5043

44+
====
5145
[source,xml,indent=0]
5246
[subs="verbatim,quotes"]
5347
----
5448
<listener>
5549
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
5650
</listener>
5751
----
52+
====
5853

59-
Find below the <context-param/> configuration:
54+
Further consider the following `<context-param/>` configuration:
6055

56+
====
6157
[source,xml,indent=0]
6258
[subs="verbatim,quotes"]
6359
----
@@ -66,30 +62,35 @@ Find below the <context-param/> configuration:
6662
<param-value>/WEB-INF/applicationContext*.xml</param-value>
6763
</context-param>
6864
----
65+
====
6966

70-
If you don't specify the `contextConfigLocation` context parameter, the
71-
`ContextLoaderListener` will look for a file called `/WEB-INF/applicationContext.xml` to
67+
If you do not specify the `contextConfigLocation` context parameter, the
68+
`ContextLoaderListener` looks for a file called `/WEB-INF/applicationContext.xml` to
7269
load. Once the context files are loaded, Spring creates a
7370
{api-spring-framework}/web/context/WebApplicationContext.html[`WebApplicationContext`]
7471
object based on the bean definitions and stores it in the `ServletContext` of the web
7572
application.
7673

77-
All Java web frameworks are built on top of the Servlet API, and so one can use the
78-
following code snippet to get access to this 'business context' `ApplicationContext`
74+
All Java web frameworks are built on top of the Servlet API, so you can use the
75+
following code snippet to get access to this "`business context`" `ApplicationContext`
7976
created by the `ContextLoaderListener`.
8077

78+
The following example shows how to get the `WebApplicationContext`:
79+
80+
====
8181
[source,java,indent=0]
8282
[subs="verbatim,quotes"]
8383
----
8484
WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);
8585
----
86+
====
8687

8788
The
8889
{api-spring-framework}/web/context/support/WebApplicationContextUtils.html[`WebApplicationContextUtils`]
89-
class is for convenience, so you don't have to remember the name of the `ServletContext`
90-
attribute. Its __getWebApplicationContext()__ method will return `null` if an object
91-
doesn't exist under the `WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE`
92-
key. Rather than risk getting `NullPointerExceptions` in your application, it's better
90+
class is for convenience, so you need not remember the name of the `ServletContext`
91+
attribute. Its `getWebApplicationContext()` method returns `null` if an object
92+
does not exist under the `WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE`
93+
key. Rather than risk getting `NullPointerExceptions` in your application, it is better
9394
to use the `getRequiredWebApplicationContext()` method. This method throws an exception
9495
when the `ApplicationContext` is missing.
9596

@@ -99,45 +100,44 @@ their implemented interfaces.
99100

100101
Fortunately, most of the frameworks in this section have simpler ways of looking up
101102
beans. Not only do they make it easy to get beans from a Spring container, but they also
102-
allow you to use dependency injection on their controllers. Each web framework section
103+
let you use dependency injection on their controllers. Each web framework section
103104
has more detail on its specific integration strategies.
104105

105106

106107

107-
108108
[[jsf]]
109109
== JSF
110+
110111
JavaServer Faces (JSF) is the JCP's standard component-based, event-driven web user
111112
interface framework. As of Java EE 5, it is an official part of the Java EE umbrella.
112113

113114
For a popular JSF runtime as well as for popular JSF component libraries, check out the
114115
http://myfaces.apache.org/[Apache MyFaces project]. The MyFaces project also provides
115-
common JSF extensions such as http://myfaces.apache.org/orchestra/[MyFaces Orchestra]:
116-
a Spring-based JSF extension that provides rich conversation scope support.
116+
common JSF extensions, such as http://myfaces.apache.org/orchestra/[MyFaces Orchestra]
117+
(a Spring-based JSF extension that provides rich conversation scope support).
117118

118-
[NOTE]
119-
====
120-
Spring Web Flow 2.0 provides rich JSF support through its newly established Spring Faces
119+
NOTE: Spring Web Flow 2.0 provides rich JSF support through its newly established Spring Faces
121120
module, both for JSF-centric usage (as described in this section) and for Spring-centric
122-
usage (using JSF views within a Spring MVC dispatcher). Check out the
123-
http://projects.spring.io/spring-webflow[Spring Web Flow website] for details!
124-
====
121+
usage (using JSF views within a Spring MVC dispatcher). See the
122+
http://projects.spring.io/spring-webflow[Spring Web Flow website] for details.
125123

126124
The key element in Spring's JSF integration is the JSF `ELResolver` mechanism.
127125

128126

129127

130128
[[jsf-springbeanfaceselresolver]]
131129
=== Spring Bean Resolver
130+
132131
`SpringBeanFacesELResolver` is a JSF 1.2+ compliant `ELResolver` implementation,
133-
integrating with the standard Unified EL as used by JSF 1.2 and JSP 2.1. Like
134-
`SpringBeanVariableResolver`, it delegates to the Spring's 'business context'
135-
`WebApplicationContext` __first__, then to the default resolver of the underlying JSF
132+
integrating with the standard Unified EL as used by JSF 1.2 and JSP 2.1. As
133+
`SpringBeanVariableResolver`, it delegates to Spring's "`business context`"
134+
`WebApplicationContext` first and then to the default resolver of the underlying JSF
136135
implementation.
137136

138-
Configuration-wise, simply define `SpringBeanFacesELResolver` in your JSF
139-
__faces-context.xml__ file:
137+
Configuration-wise, you can define `SpringBeanFacesELResolver` in your JSF
138+
`faces-context.xml` file, as the following example shows:
140139

140+
====
141141
[source,xml,indent=0]
142142
[subs="verbatim,quotes"]
143143
----
@@ -148,33 +148,39 @@ __faces-context.xml__ file:
148148
</application>
149149
</faces-config>
150150
----
151+
====
151152

152153

153154

154155
[[jsf-facescontextutils]]
155-
=== FacesContextUtils
156-
A custom `VariableResolver` works well when mapping one's properties to beans
157-
in __faces-config.xml__, but at times one may need to grab a bean explicitly. The
156+
=== Using `FacesContextUtils`
157+
158+
A custom `VariableResolver` works well when mapping your properties to beans
159+
in `faces-config.xml`, but, at times, you may need to explicitly grab a bean. The
158160
{api-spring-framework}/web/jsf/FacesContextUtils.html[`FacesContextUtils`]
159161
class makes this easy. It is similar to `WebApplicationContextUtils`, except that it
160162
takes a `FacesContext` parameter rather than a `ServletContext` parameter.
161163

164+
The following example shows how to use `FacesContextUtils`:
165+
166+
====
162167
[source,java,indent=0]
163168
[subs="verbatim,quotes"]
164169
----
165170
ApplicationContext ctx = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
166171
----
167-
172+
====
168173

169174

170175

171176
[[struts]]
172177
== Apache Struts 2.x
173-
Invented by Craig McClanahan, http://struts.apache.org[Struts] is an open source project
178+
179+
Invented by Craig McClanahan, http://struts.apache.org[Struts] is an open-source project
174180
hosted by the Apache Software Foundation. At the time, it greatly simplified the
175181
JSP/Servlet programming paradigm and won over many developers who were using proprietary
176-
frameworks. It simplified the programming model, it was open source (and thus free as in
177-
beer), and it had a large community, which allowed the project to grow and become popular
182+
frameworks. It simplified the programming model, it was open source (and thus free, as in
183+
beer), and it had a large community, which let the project grow and become popular
178184
among Java web developers.
179185

180186
Check out the Struts
@@ -183,28 +189,25 @@ built-in Spring integration shipped with Struts.
183189

184190

185191

186-
187192
[[tapestry]]
188193
== Tapestry 5.x
189-
From the http://tapestry.apache.org/[Tapestry homepage]:
190194

191-
Tapestry is a "__Component oriented framework for creating dynamic, robust,
192-
highly scalable web applications in Java.__"
195+
http://tapestry.apache.org/[Tapestry] is a ""Component oriented framework for creating dynamic, robust,
196+
highly scalable web applications in Java.""
193197

194198
While Spring has its own <<mvc,powerful web layer>>, there are a number of unique
195-
advantages to building an enterprise Java application using a combination of Tapestry
199+
advantages to building an enterprise Java application by using a combination of Tapestry
196200
for the web user interface and the Spring container for the lower layers.
197201

198-
For more information, check out Tapestry's dedicated
202+
For more information, see Tapestry's dedicated
199203
https://tapestry.apache.org/integrating-with-spring-framework.html[integration module for
200204
Spring].
201205

202206

203207

204-
205208
[[web-integration-resources]]
206209
== Further Resources
207-
Find below links to further resources about the various web frameworks described in this
210+
The following links go to further resources about the various web frameworks described in this
208211
chapter.
209212

210213
* The http://www.oracle.com/technetwork/java/javaee/javaserverfaces-139869.html[JSF] homepage

0 commit comments

Comments
 (0)