Skip to content

Commit da12481

Browse files
committed
Polish ref docs
- stop referring to Java Config as new - stop referring to Struts 2.x as if it were new - polish AOT documentation - etc.
1 parent c45f8b7 commit da12481

File tree

7 files changed

+53
-59
lines changed

7 files changed

+53
-59
lines changed

framework-docs/src/docs/asciidoc/core/core-aot.adoc

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This chapter covers Spring's Ahead of Time (AOT) optimizations.
55

66
For AOT support specific to integration tests, see <<testing.adoc#testcontext-aot, Ahead of Time Support for Tests>>.
77

8-
[[aot-introduction]]
8+
[[core.aot.introduction]]
99
== Introduction to Ahead of Time Optimizations
1010

1111
Spring's support for AOT optimizations is meant to inspect an `ApplicationContext` at build time and apply decisions and discovery logic that usually happens at runtime.
@@ -263,30 +263,29 @@ The following example registers `Account` for serialization.
263263
[[core.aot.hints.testing]]
264264
=== Testing Runtime Hints
265265

266-
Spring Core also ships `RuntimeHintsPredicates`, an utility for checking that existing hints match a particular use case.
267-
This can be used in your own tests, for validating that a `RuntimeHintsRegistrar` has the expected result.
268-
We can write a test for our `SpellCheckService` and ensure that we can load a dictionary at runtime:
266+
Spring Core also ships `RuntimeHintsPredicates`, a utility for checking that existing hints match a particular use case.
267+
This can be used in your own tests to validate that a `RuntimeHintsRegistrar` contains the expected results.
268+
We can write a test for our `SpellCheckService` and ensure that we will be able to load a dictionary at runtime:
269269

270270
include::code:SpellCheckServiceTests[tag=hintspredicates]
271271

272-
With `RuntimeHintsPredicates`, we can check for reflection, resource, serialization or proxy generation hints.
272+
With `RuntimeHintsPredicates`, we can check for reflection, resource, serialization, or proxy generation hints.
273273
This approach works well for unit tests but implies that the runtime behavior of a component is well known.
274274

275275
You can learn more about the global runtime behavior of an application by running its test suite (or the app itself) with the {docs-graalvm}/native-image/metadata/AutomaticMetadataCollection/[GraalVM tracing agent].
276276
This agent will record all relevant calls requiring GraalVM hints at runtime and write them out as JSON configuration files.
277277

278278
For more targeted discovery and testing, Spring Framework ships a dedicated module with core AOT testing utilities, `"org.springframework:spring-core-test"`.
279-
This module contains the RuntimeHints Agent, a Java agent that all method invocations that are related to runtime hints and helps you to assert that a given `RuntimeHints` instance covers all recorded invocations.
280-
Let's consider a piece of infrastructure for which we'd like to test the hints we're contributing during the AOT phase.
281-
279+
This module contains the RuntimeHints Agent, a Java agent that records all method invocations that are related to runtime hints and helps you to assert that a given `RuntimeHints` instance covers all recorded invocations.
280+
Let's consider a piece of infrastructure for which we'd like to test the hints we're contributing during the AOT processing phase.
282281

283282
include::code:SampleReflection[]
284283

285-
We can then write a Java test (no native compilation required!) that checks our contributed hints:
284+
We can then write a unit test (no native compilation required) that checks our contributed hints:
286285

287286
include::code:SampleReflectionRuntimeHintsTests[]
288287

289-
If you forgot to contribute a hint, the test will fail and give some details on the invocation:
288+
If you forgot to contribute a hint, the test will fail and provide some details about the invocation:
290289

291290
[source,txt,indent=0,subs="verbatim,quotes"]
292291
----
@@ -303,6 +302,6 @@ io.spring.runtimehintstesting.SampleReflection#performReflection, Line 19
303302
io.spring.runtimehintstesting.SampleReflectionRuntimeHintsTests#lambda$shouldRegisterReflectionHints$0, Line 25
304303
----
305304

306-
There are various ways to configure this Java agent into your build, please refer to your build tool and test execution plugin documentation.
307-
The agent itself can be configured to instrument some packages (by default, only `org.springframework` is instrumented).
308-
You'll find more details in the https://github.com/spring-projects/spring-framework/blob/main/buildSrc/README.md[Spring Framework buildSrc README].
305+
There are various ways to configure this Java agent in your build, so please refer to the documentation of your build tool and test execution plugin.
306+
The agent itself can be configured to instrument specific packages (by default, only `org.springframework` is instrumented).
307+
You'll find more details in the {spring-framework-main-code}/buildSrc/README.md[Spring Framework `buildSrc` README] file.

framework-docs/src/docs/asciidoc/core/core-beans.adoc

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,10 @@ configuration metadata is actually written. These days, many developers choose
107107

108108
For information about using other forms of metadata with the Spring container, see:
109109

110-
* <<beans-annotation-config,Annotation-based configuration>>: Spring 2.5 introduced
111-
support for annotation-based configuration metadata.
112-
* <<beans-java, Java-based configuration>>: Starting with Spring 3.0, many features
113-
provided by the Spring JavaConfig project became part of the core Spring Framework.
114-
Thus, you can define beans external to your application classes by using Java rather
115-
than XML files. To use these new features, see the
110+
* <<beans-annotation-config,Annotation-based configuration>>: define beans using
111+
annotation-based configuration metadata.
112+
* <<beans-java, Java-based configuration>>: define beans external to your application
113+
classes by using Java rather than XML files. To use these features, see the
116114
{api-spring-framework}/context/annotation/Configuration.html[`@Configuration`],
117115
{api-spring-framework}/context/annotation/Bean.html[`@Bean`],
118116
{api-spring-framework}/context/annotation/Import.html[`@Import`],
@@ -124,14 +122,12 @@ beans as `<bean/>` elements inside a top-level `<beans/>` element. Java
124122
configuration typically uses `@Bean`-annotated methods within a `@Configuration` class.
125123

126124
These bean definitions correspond to the actual objects that make up your application.
127-
Typically, you define service layer objects, data access objects (DAOs), presentation
128-
objects such as Struts `Action` instances, infrastructure objects such as Hibernate
129-
`SessionFactories`, JMS `Queues`, and so forth. Typically, one does not configure
130-
fine-grained domain objects in the container, because it is usually the responsibility
131-
of DAOs and business logic to create and load domain objects. However, you can use
132-
Spring's integration with AspectJ to configure objects that have been created outside
133-
the control of an IoC container. See <<aop-atconfigurable,Using AspectJ to
134-
dependency-inject domain objects with Spring>>.
125+
Typically, you define service layer objects, persistence layer objects such as
126+
repositories or data access objects (DAOs), presentation objects such as Web controllers,
127+
infrastructure objects such as a JPA `EntityManagerFactory`, JMS queues, and so forth.
128+
Typically, one does not configure fine-grained domain objects in the container, because
129+
it is usually the responsibility of repositories and business logic to create and load
130+
domain objects.
135131

136132
The following example shows the basic structure of XML-based configuration metadata:
137133

@@ -157,12 +153,11 @@ The following example shows the basic structure of XML-based configuration metad
157153
----
158154

159155
<1> The `id` attribute is a string that identifies the individual bean definition.
160-
161156
<2> The `class` attribute defines the type of the bean and uses the fully qualified
162-
classname.
157+
class name.
163158

164-
The value of the `id` attribute refers to collaborating objects. The XML for
165-
referring to collaborating objects is not shown in this example. See
159+
The value of the `id` attribute can be used to refer to collaborating objects. The XML
160+
for referring to collaborating objects is not shown in this example. See
166161
<<beans-dependencies,Dependencies>> for more information.
167162

168163

@@ -2839,7 +2834,7 @@ processed by the Spring `DispatcherServlet`, no special setup is necessary.
28392834
`DispatcherServlet` already exposes all relevant state.
28402835

28412836
If you use a Servlet web container, with requests processed outside of Spring's
2842-
`DispatcherServlet` (for example, when using JSF or Struts), you need to register the
2837+
`DispatcherServlet` (for example, when using JSF), you need to register the
28432838
`org.springframework.web.context.request.RequestContextListener` `ServletRequestListener`.
28442839
This can be done programmatically by using the `WebApplicationInitializer` interface.
28452840
Alternatively, add the following declaration to your web application's `web.xml` file:
@@ -7515,7 +7510,7 @@ container. It includes the following topics:
75157510
[[beans-java-basic-concepts]]
75167511
=== Basic Concepts: `@Bean` and `@Configuration`
75177512

7518-
The central artifacts in Spring's new Java-configuration support are
7513+
The central artifacts in Spring's Java configuration support are
75197514
`@Configuration`-annotated classes and `@Bean`-annotated methods.
75207515

75217516
The `@Bean` annotation is used to indicate that a method instantiates, configures, and

framework-docs/src/docs/asciidoc/web/integration.adoc

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ first take a look at common Spring configuration that is not specific to any one
2323
framework. (This section is equally applicable to Spring's own web framework variants.)
2424

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

3737
Moving on to specifics, all you need to do is declare a
3838
{api-spring-framework}/web/context/ContextLoaderListener.html[`ContextLoaderListener`]
3939
in the standard Jakarta EE servlet `web.xml` file of your web application and add a
40-
`contextConfigLocation`<context-param/> section (in the same file) that defines which
40+
`contextConfigLocation` `<context-param/>` section (in the same file) that defines which
4141
set of Spring XML configuration files to load.
4242

4343
Consider the following `<listener/>` configuration:
@@ -67,7 +67,7 @@ object based on the bean definitions and stores it in the `ServletContext` of th
6767
application.
6868

6969
All Java web frameworks are built on top of the Servlet API, so you can use the
70-
following code snippet to get access to this "`business context`" `ApplicationContext`
70+
following code snippet to get access to this "business context" `ApplicationContext`
7171
created by the `ContextLoaderListener`.
7272

7373
The following example shows how to get the `WebApplicationContext`:
@@ -119,7 +119,7 @@ The key element in Spring's JSF integration is the JSF `ELResolver` mechanism.
119119

120120
`SpringBeanFacesELResolver` is a JSF compliant `ELResolver` implementation,
121121
integrating with the standard Unified EL as used by JSF and JSP. It delegates to
122-
Spring's "`business context`" `WebApplicationContext` first and then to the
122+
Spring's "business context" `WebApplicationContext` first and then to the
123123
default resolver of the underlying JSF implementation.
124124

125125
Configuration-wise, you can define `SpringBeanFacesELResolver` in your JSF
@@ -157,27 +157,26 @@ The following example shows how to use `FacesContextUtils`:
157157

158158

159159
[[struts]]
160-
== Apache Struts 2.x
160+
== Apache Struts
161161

162162
Invented by Craig McClanahan, https://struts.apache.org[Struts] is an open-source project
163-
hosted by the Apache Software Foundation. At the time, it greatly simplified the
163+
hosted by the Apache Software Foundation. Struts 1.x greatly simplified the
164164
JSP/Servlet programming paradigm and won over many developers who were using proprietary
165-
frameworks. It simplified the programming model, it was open source (and thus free as in
166-
beer), and it had a large community, which let the project grow and become popular among
167-
Java web developers.
165+
frameworks. It simplified the programming model; it was open source; and it had a large
166+
community, which let the project grow and become popular among Java web developers.
168167

169-
As a successor to the original Struts 1.x, check out Struts 2.x and the Struts-provided
170-
https://struts.apache.org/release/2.3.x/docs/spring-plugin.html[Spring Plugin] for the
171-
built-in Spring integration.
168+
As a successor to the original Struts 1.x, check out Struts 2.x or more recent versions
169+
as well as the Struts-provided
170+
https://struts.apache.org/plugins/spring/[Spring Plugin] for built-in Spring integration.
172171

173172

174173

175174

176175
[[tapestry]]
177-
== Apache Tapestry 5.x
176+
== Apache Tapestry
178177

179-
https://tapestry.apache.org/[Tapestry] is a ""Component oriented framework for creating
180-
dynamic, robust, highly scalable web applications in Java.""
178+
https://tapestry.apache.org/[Tapestry] is a "Component oriented framework for creating
179+
dynamic, robust, highly scalable web applications in Java."
181180

182181
While Spring has its own <<mvc, powerful web layer>>, there are a number of unique
183182
advantages to building an enterprise Java application by using a combination of Tapestry
@@ -195,6 +194,6 @@ https://tapestry.apache.org/integrating-with-spring-framework.html[integration m
195194
The following links go to further resources about the various web frameworks described in
196195
this chapter.
197196

198-
* The https://www.oracle.com/technetwork/java/javaee/javaserverfaces-139869.html[JSF] homepage
197+
* The https://www.oracle.com/java/technologies/javaserverfaces.html[JSF] homepage
199198
* The https://struts.apache.org/[Struts] homepage
200199
* The https://tapestry.apache.org/[Tapestry] homepage

framework-docs/src/main/java/org/springframework/docs/core/aot/hints/testing/SampleReflection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ public void performReflection() {
3838
logger.error("reflection failed", exc);
3939
}
4040
}
41-
}
41+
42+
}

framework-docs/src/main/java/org/springframework/docs/core/aot/hints/testing/SampleReflectionRuntimeHintsTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929

3030
import static org.assertj.core.api.Assertions.assertThat;
3131

32-
// This annotation conditions the execution of tests only if the agent is loaded in the current JVM
33-
// it also tags tests with the "RuntimeHints" JUnit tag
32+
// @EnabledIfRuntimeHintsAgent signals that the annotated test class or test
33+
// method is only enabled if the RuntimeHintsAgent is loaded on the current JVM.
34+
// It also tags tests with the "RuntimeHints" JUnit tag.
3435
@EnabledIfRuntimeHintsAgent
3536
class SampleReflectionRuntimeHintsTests {
3637

framework-docs/src/main/java/org/springframework/docs/core/aot/hints/testing/SpellCheckServiceTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
4444
hints.resources().registerPattern("dicts/*");
4545
}
4646
}
47+
4748
}

framework-docs/src/main/java/org/springframework/docs/core/aot/refresh/AotProcessingSample.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@ public void createAotContext() {
3838
@ComponentScan
3939
@Import({DataSourceConfiguration.class, ContainerConfiguration.class})
4040
public class MyApplication {
41-
4241
}
4342
// end::myapplication[]
4443

4544
class DataSourceConfiguration {
46-
4745
}
4846

4947
class ContainerConfiguration {
50-
5148
}
49+
5250
}

0 commit comments

Comments
 (0)