提交 a61d1076 编写于 作者: J Juergen Hoeller

Asciidoc revision (chapter declarations, javadoc references, etc)

上级 67bd3f67
[[aop-api]] [[aop-api]]
= Spring AOP APIs = Spring AOP APIs
The previous chapter described the Spring's support for AOP with The previous chapter described the Spring's support for AOP with
@AspectJ and schema-based aspect definitions. In this chapter, we discuss the lower-level @AspectJ and schema-based aspect definitions. In this chapter, we discuss the lower-level
Spring AOP APIs and the AOP support typically used in Spring 1.2 applications. For new Spring AOP APIs and the AOP support typically used in Spring 1.2 applications. For new
...@@ -14,6 +12,7 @@ in Spring 5. ...@@ -14,6 +12,7 @@ in Spring 5.
[[aop-api-pointcuts]] [[aop-api-pointcuts]]
== Pointcut API in Spring == Pointcut API in Spring
...@@ -129,7 +128,6 @@ Spring provides several convenient pointcut implementations. You can use some of ...@@ -129,7 +128,6 @@ Spring provides several convenient pointcut implementations. You can use some of
Others are intended to be subclassed in application-specific pointcuts. Others are intended to be subclassed in application-specific pointcuts.
[[aop-api-pointcuts-static]] [[aop-api-pointcuts-static]]
==== Static Pointcuts ==== Static Pointcuts
...@@ -198,8 +196,6 @@ pointcut and advice, as the following example shows: ...@@ -198,8 +196,6 @@ pointcut and advice, as the following example shows:
You can use `RegexpMethodPointcutAdvisor` with any `Advice` type. You can use `RegexpMethodPointcutAdvisor` with any `Advice` type.
[[aop-api-pointcuts-attribute-driven]] [[aop-api-pointcuts-attribute-driven]]
===== Attribute-driven Pointcuts ===== Attribute-driven Pointcuts
...@@ -207,7 +203,6 @@ An important type of static pointcut is a metadata-driven pointcut. This uses th ...@@ -207,7 +203,6 @@ An important type of static pointcut is a metadata-driven pointcut. This uses th
values of metadata attributes (typically, source-level metadata). values of metadata attributes (typically, source-level metadata).
[[aop-api-pointcuts-dynamic]] [[aop-api-pointcuts-dynamic]]
==== Dynamic pointcuts ==== Dynamic pointcuts
...@@ -276,6 +271,7 @@ for example, "`all methods that change instance variables in the target object.` ...@@ -276,6 +271,7 @@ for example, "`all methods that change instance variables in the target object.`
[[aop-api-advice]] [[aop-api-advice]]
== Advice API in Spring == Advice API in Spring
...@@ -366,7 +362,6 @@ are not currently interoperable between frameworks, and the AOP Alliance does no ...@@ -366,7 +362,6 @@ are not currently interoperable between frameworks, and the AOP Alliance does no
currently define pointcut interfaces. currently define pointcut interfaces.
[[aop-api-advice-before]] [[aop-api-advice-before]]
==== Before Advice ==== Before Advice
...@@ -425,7 +420,6 @@ The following example shows a before advice in Spring, which counts all method i ...@@ -425,7 +420,6 @@ The following example shows a before advice in Spring, which counts all method i
TIP: Before advice can be used with any pointcut. TIP: Before advice can be used with any pointcut.
[[aop-api-advice-throws]] [[aop-api-advice-throws]]
==== Throws Advice ==== Throws Advice
...@@ -511,7 +505,6 @@ exception that is incompatible with the target method's signature!_ ...@@ -511,7 +505,6 @@ exception that is incompatible with the target method's signature!_
TIP: Throws advice can be used with any pointcut. TIP: Throws advice can be used with any pointcut.
[[aop-api-advice-after-returning]] [[aop-api-advice-after-returning]]
==== After Returning Advice ==== After Returning Advice
...@@ -562,7 +555,6 @@ thrown up the interceptor chain instead of the return value. ...@@ -562,7 +555,6 @@ thrown up the interceptor chain instead of the return value.
TIP: After returning advice can be used with any pointcut. TIP: After returning advice can be used with any pointcut.
[[aop-api-advice-introduction]] [[aop-api-advice-introduction]]
==== Introduction Advice ==== Introduction Advice
...@@ -738,6 +730,8 @@ and stateful mixins. ...@@ -738,6 +730,8 @@ and stateful mixins.
[[aop-api-advisor]] [[aop-api-advisor]]
== The Advisor API in Spring == The Advisor API in Spring
...@@ -756,6 +750,7 @@ chain. ...@@ -756,6 +750,7 @@ chain.
[[aop-pfb]] [[aop-pfb]]
== Using the `ProxyFactoryBean` to Create AOP Proxies == Using the `ProxyFactoryBean` to Create AOP Proxies
...@@ -1085,6 +1080,7 @@ two global advisors: ...@@ -1085,6 +1080,7 @@ two global advisors:
[[aop-concise-proxy]] [[aop-concise-proxy]]
== Concise Proxy Definitions == Concise Proxy Definitions
...@@ -1164,6 +1160,7 @@ pre-instantiate it. ...@@ -1164,6 +1160,7 @@ pre-instantiate it.
[[aop-prog]] [[aop-prog]]
== Creating AOP Proxies Programmatically with the `ProxyFactory` == Creating AOP Proxies Programmatically with the `ProxyFactory`
...@@ -1205,6 +1202,7 @@ as you should in general. ...@@ -1205,6 +1202,7 @@ as you should in general.
[[aop-api-advised]] [[aop-api-advised]]
== Manipulating Advised Objects == Manipulating Advised Objects
...@@ -1298,6 +1296,7 @@ required. ...@@ -1298,6 +1296,7 @@ required.
[[aop-autoproxy]] [[aop-autoproxy]]
== Using the "auto-proxy" facility == Using the "auto-proxy" facility
...@@ -1327,7 +1326,6 @@ This section covers the auto-proxy creators provided by the ...@@ -1327,7 +1326,6 @@ This section covers the auto-proxy creators provided by the
`org.springframework.aop.framework.autoproxy` package. `org.springframework.aop.framework.autoproxy` package.
[[aop-api-autoproxy]] [[aop-api-autoproxy]]
==== `BeanNameAutoProxyCreator` ==== `BeanNameAutoProxyCreator`
...@@ -1435,6 +1433,7 @@ preceding example has a configurable order value. The default setting is unorder ...@@ -1435,6 +1433,7 @@ preceding example has a configurable order value. The default setting is unorder
[[aop-targetsource]] [[aop-targetsource]]
== Using `TargetSource` Implementations == Using `TargetSource` Implementations
...@@ -1552,7 +1551,7 @@ The following listig shows an example configuration: ...@@ -1552,7 +1551,7 @@ The following listig shows an example configuration:
Note that the target object (`businessObjectTarget` in the preceding example) must be a Note that the target object (`businessObjectTarget` in the preceding example) must be a
prototype. This lets the `PoolingTargetSource` implementation create new instances prototype. This lets the `PoolingTargetSource` implementation create new instances
of the target to grow the pool as necessary. See the {api-spring-framework}aop/target/AbstractPoolingTargetSource.html[Javadoc of of the target to grow the pool as necessary. See the {api-spring-framework}aop/target/AbstractPoolingTargetSource.html[javadoc of
`AbstractPoolingTargetSource`] and the concrete subclass you wish to use for information `AbstractPoolingTargetSource`] and the concrete subclass you wish to use for information
about its properties. `maxSize` is the most basic and is always guaranteed to be present. about its properties. `maxSize` is the most basic and is always guaranteed to be present.
...@@ -1661,6 +1660,7 @@ any case, since not unsetting it might result in problematic behavior. Spring's ...@@ -1661,6 +1660,7 @@ any case, since not unsetting it might result in problematic behavior. Spring's
[[aop-extensibility]] [[aop-extensibility]]
== Defining New Advice Types == Defining New Advice Types
...@@ -1674,5 +1674,5 @@ support for new custom advice types be added without changing the core framework ...@@ -1674,5 +1674,5 @@ support for new custom advice types be added without changing the core framework
The only constraint on a custom `Advice` type is that it must implement the The only constraint on a custom `Advice` type is that it must implement the
`org.aopalliance.aop.Advice` marker interface. `org.aopalliance.aop.Advice` marker interface.
See the {api-spring-framework}/aop/framework/adapter/package-frame.html[`org.springframework.aop.framework.adapter` Javadoc] for further See the {api-spring-framework}/aop/framework/adapter/package-frame.html[`org.springframework.aop.framework.adapter`]
information. javadoc for further information.
...@@ -37,6 +37,7 @@ Spring AOP, and can skip most of this chapter. ...@@ -37,6 +37,7 @@ Spring AOP, and can skip most of this chapter.
[[aop-introduction-defn]] [[aop-introduction-defn]]
== AOP Concepts == AOP Concepts
...@@ -115,6 +116,7 @@ multiple objects (such as all business operations in the service layer). ...@@ -115,6 +116,7 @@ multiple objects (such as all business operations in the service layer).
[[aop-introduction-spring-defn]] [[aop-introduction-spring-defn]]
== Spring AOP Capabilities and Goals == Spring AOP Capabilities and Goals
...@@ -175,6 +177,7 @@ style. ...@@ -175,6 +177,7 @@ style.
[[aop-introduction-proxies]] [[aop-introduction-proxies]]
== AOP Proxies == AOP Proxies
...@@ -195,6 +198,7 @@ implementation detail actually means. ...@@ -195,6 +198,7 @@ implementation detail actually means.
[[aop-ataspectj]] [[aop-ataspectj]]
== @AspectJ support == @AspectJ support
...@@ -244,7 +248,6 @@ annotation, as the following example shows: ...@@ -244,7 +248,6 @@ annotation, as the following example shows:
==== ====
[[aop-enable-aspectj-xml]] [[aop-enable-aspectj-xml]]
==== Enabling @AspectJ Support with XML Configuration ==== Enabling @AspectJ Support with XML Configuration
...@@ -458,7 +461,6 @@ it is natural and straightforward to identify specific beans by name. ...@@ -458,7 +461,6 @@ it is natural and straightforward to identify specific beans by name.
==== ====
[[aop-pointcuts-combining]] [[aop-pointcuts-combining]]
==== Combining Pointcut Expressions ==== Combining Pointcut Expressions
...@@ -486,8 +488,6 @@ of any public method. ...@@ -486,8 +488,6 @@ of any public method.
trading module. trading module.
==== ====
It is a best practice to build more complex pointcut expressions out of smaller named It is a best practice to build more complex pointcut expressions out of smaller named
components, as shown earlier. When referring to pointcuts by name, normal Java visibility components, as shown earlier. When referring to pointcuts by name, normal Java visibility
rules apply (you can see private pointcuts in the same type, protected pointcuts in the rules apply (you can see private pointcuts in the same type, protected pointcuts in the
...@@ -824,7 +824,6 @@ match the wildcard expression `*Service`: ...@@ -824,7 +824,6 @@ match the wildcard expression `*Service`:
==== ====
[[writing-good-pointcuts]] [[writing-good-pointcuts]]
==== Writing Good Pointcuts ==== Writing Good Pointcuts
...@@ -918,7 +917,6 @@ following example: ...@@ -918,7 +917,6 @@ following example:
==== ====
[[aop-advice-after-returning]] [[aop-advice-after-returning]]
==== After Returning Advice ==== After Returning Advice
...@@ -983,7 +981,6 @@ Please note that it is not possible to return a totally different reference when ...@@ -983,7 +981,6 @@ Please note that it is not possible to return a totally different reference when
using after returning advice. using after returning advice.
[[aop-advice-after-throwing]] [[aop-advice-after-throwing]]
==== After Throwing Advice ==== After Throwing Advice
...@@ -1072,7 +1069,6 @@ The following example shows how to use after finally advice: ...@@ -1072,7 +1069,6 @@ The following example shows how to use after finally advice:
==== ====
[[aop-ataspectj-around-advice]] [[aop-ataspectj-around-advice]]
==== Around Advice ==== Around Advice
...@@ -1136,7 +1132,6 @@ many times, or not at all within the body of the around advice. All of these are ...@@ -1136,7 +1132,6 @@ many times, or not at all within the body of the around advice. All of these are
legal. legal.
[[aop-ataspectj-advice-params]] [[aop-ataspectj-advice-params]]
==== Advice Parameters ==== Advice Parameters
...@@ -1161,7 +1156,7 @@ a first parameter of type `ProceedingJoinPoint`, which is a subclass of `JoinPoi ...@@ -1161,7 +1156,7 @@ a first parameter of type `ProceedingJoinPoint`, which is a subclass of `JoinPoi
* `getSignature()`: Returns a description of the method that is being advised. * `getSignature()`: Returns a description of the method that is being advised.
* `toString()`: Prints a useful description of the method being advised. * `toString()`: Prints a useful description of the method being advised.
See the https://www.eclipse.org/aspectj/doc/released/runtime-api/org/aspectj/lang/JoinPoint.html[Javadoc] for more detail. See the https://www.eclipse.org/aspectj/doc/released/runtime-api/org/aspectj/lang/JoinPoint.html[javadoc] for more detail.
[[aop-ataspectj-advice-params-passing]] [[aop-ataspectj-advice-params-passing]]
===== Passing Parameters to Advice ===== Passing Parameters to Advice
...@@ -1646,6 +1641,7 @@ expression so that only `@Idempotent` operations match, as follows: ...@@ -1646,6 +1641,7 @@ expression so that only `@Idempotent` operations match, as follows:
[[aop-schema]] [[aop-schema]]
== Schema-based AOP Support == Schema-based AOP Support
...@@ -1846,7 +1842,6 @@ The schema-based AOP support uses the same five kinds of advice as the @AspectJ ...@@ -1846,7 +1842,6 @@ The schema-based AOP support uses the same five kinds of advice as the @AspectJ
exactly the same semantics. exactly the same semantics.
[[aop-schema-advice-before]] [[aop-schema-advice-before]]
==== Before Advice ==== Before Advice
...@@ -1899,7 +1894,6 @@ join point matched by the pointcut expression), the `doAccessCheck` method on th ...@@ -1899,7 +1894,6 @@ join point matched by the pointcut expression), the `doAccessCheck` method on th
bean is invoked. bean is invoked.
[[aop-schema-advice-after-returning]] [[aop-schema-advice-after-returning]]
==== After Returning Advice ==== After Returning Advice
...@@ -1957,7 +1951,6 @@ example, you can decleare the method signature as follows: ...@@ -1957,7 +1951,6 @@ example, you can decleare the method signature as follows:
==== ====
[[aop-schema-advice-after-throwing]] [[aop-schema-advice-after-throwing]]
==== After Throwing Advice ==== After Throwing Advice
...@@ -2015,7 +2008,6 @@ example, the method signature may be declared as follows: ...@@ -2015,7 +2008,6 @@ example, the method signature may be declared as follows:
==== ====
[[aop-schema-advice-after-finally]] [[aop-schema-advice-after-finally]]
==== After (Finally) Advice ==== After (Finally) Advice
...@@ -2039,7 +2031,6 @@ by using the `after` element, as the following example shows: ...@@ -2039,7 +2031,6 @@ by using the `after` element, as the following example shows:
==== ====
[[aop-schema-advice-around]] [[aop-schema-advice-around]]
==== Around Advice ==== Around Advice
...@@ -2092,7 +2083,6 @@ The implementation of the `doBasicProfiling` advice can be exactly the same as i ...@@ -2092,7 +2083,6 @@ The implementation of the `doBasicProfiling` advice can be exactly the same as i
==== ====
[[aop-schema-params]] [[aop-schema-params]]
==== Advice Parameters ==== Advice Parameters
...@@ -2244,7 +2234,6 @@ ms % Task name ...@@ -2244,7 +2234,6 @@ ms % Task name
==== ====
[[aop-ordering]] [[aop-ordering]]
==== Advice Ordering ==== Advice Ordering
...@@ -2502,6 +2491,7 @@ pointcut expression so that only `@Idempotent` operations match, as follows: ...@@ -2502,6 +2491,7 @@ pointcut expression so that only `@Idempotent` operations match, as follows:
[[aop-choosing]] [[aop-choosing]]
== Choosing which AOP Declaration Style to Use == Choosing which AOP Declaration Style to Use
...@@ -2613,6 +2603,7 @@ co-exist without any difficulty. ...@@ -2613,6 +2603,7 @@ co-exist without any difficulty.
[[aop-proxying]] [[aop-proxying]]
== Proxying Mechanisms == Proxying Mechanisms
...@@ -2823,6 +2814,7 @@ it is not a proxy-based AOP framework. ...@@ -2823,6 +2814,7 @@ it is not a proxy-based AOP framework.
[[aop-aspectj-programmatic]] [[aop-aspectj-programmatic]]
== Programmatic Creation of @AspectJ Proxies == Programmatic Creation of @AspectJ Proxies
...@@ -2855,7 +2847,8 @@ The basic usage for this class is very simple, as the following example shows: ...@@ -2855,7 +2847,8 @@ The basic usage for this class is very simple, as the following example shows:
---- ----
==== ====
See the {api-spring-framework}/aop/aspectj/annotation/AspectJProxyFactory.html[Javadoc] for more information. See the {api-spring-framework}/aop/aspectj/annotation/AspectJProxyFactory.html[javadoc] for more information.
...@@ -3058,7 +3051,6 @@ with the container. Doing so results in double initialization, once through the ...@@ -3058,7 +3051,6 @@ with the container. Doing so results in double initialization, once through the
container and once through the aspect. container and once through the aspect.
[[aop-configurable-testing]] [[aop-configurable-testing]]
==== Unit Testing `@Configurable` Objects ==== Unit Testing `@Configurable` Objects
...@@ -3072,7 +3064,6 @@ see a warning message each time that you construct an `@Configurable` object ind ...@@ -3072,7 +3064,6 @@ see a warning message each time that you construct an `@Configurable` object ind
that it has not been configured by Spring. that it has not been configured by Spring.
[[aop-configurable-container]] [[aop-configurable-container]]
==== Working with Multiple Application Contexts ==== Working with Multiple Application Contexts
...@@ -3474,7 +3465,6 @@ and then easily exclude from builds of the application being deployed ...@@ -3474,7 +3465,6 @@ and then easily exclude from builds of the application being deployed
into UAT or production. into UAT or production.
[[aop-aj-ltw-the-aspects]] [[aop-aj-ltw-the-aspects]]
==== Aspects ==== Aspects
...@@ -3484,7 +3474,6 @@ Your aspects are then both valid AspectJ and Spring AOP aspects. ...@@ -3484,7 +3474,6 @@ Your aspects are then both valid AspectJ and Spring AOP aspects.
Furthermore, the compiled aspect classes need to be available on the classpath. Furthermore, the compiled aspect classes need to be available on the classpath.
[[aop-aj-ltw-aop_dot_xml]] [[aop-aj-ltw-aop_dot_xml]]
==== 'META-INF/aop.xml' ==== 'META-INF/aop.xml'
...@@ -3520,10 +3509,10 @@ adding one or more `java.lang.instrument.ClassFileTransformers` to a `ClassLoade ...@@ -3520,10 +3509,10 @@ adding one or more `java.lang.instrument.ClassFileTransformers` to a `ClassLoade
runtime, which opens the door to all manner of interesting applications, one of which runtime, which opens the door to all manner of interesting applications, one of which
happens to be the LTW of aspects. happens to be the LTW of aspects.
TIP: If you are unfamiliar with the idea of runtime class file transformation, se TIP: If you are unfamiliar with the idea of runtime class file transformation, see the
the Javadoc API documentation for the `java.lang.instrument` package javadoc API documentation for the `java.lang.instrument` package before continuing.
before continuing. While that documentation is not comprehensive, at least you can see the While that documentation is not comprehensive, at least you can see the key interfaces
key interfaces and classes (for reference as you read through this section). and classes (for reference as you read through this section).
Configuring a `LoadTimeWeaver` for a particular `ApplicationContext` can be as easy as Configuring a `LoadTimeWeaver` for a particular `ApplicationContext` can be as easy as
adding one line. (Note that you almost certainly need to use an adding one line. (Note that you almost certainly need to use an
...@@ -3660,7 +3649,7 @@ retrieved from the Spring container by using the well known name, `loadTimeWeave ...@@ -3660,7 +3649,7 @@ retrieved from the Spring container by using the well known name, `loadTimeWeave
Remember that the `LoadTimeWeaver` exists only as a mechanism for Spring's LTW Remember that the `LoadTimeWeaver` exists only as a mechanism for Spring's LTW
infrastructure to add one or more `ClassFileTransformers`. The actual infrastructure to add one or more `ClassFileTransformers`. The actual
`ClassFileTransformer` that does the LTW is the `ClassPreProcessorAgentAdapter` (from `ClassFileTransformer` that does the LTW is the `ClassPreProcessorAgentAdapter` (from
the `org.aspectj.weaver.loadtime` package) class. See the class-level Javadoc of the the `org.aspectj.weaver.loadtime` package) class. See the class-level javadoc of the
`ClassPreProcessorAgentAdapter` class for further details, because the specifics of how `ClassPreProcessorAgentAdapter` class for further details, because the specifics of how
the weaving is actually effected is beyond the scope of this document. the weaving is actually effected is beyond the scope of this document.
...@@ -3774,8 +3763,6 @@ to your artifact a file named `WEB-INF/jboss-scanning.xml` with the following co ...@@ -3774,8 +3763,6 @@ to your artifact a file named `WEB-INF/jboss-scanning.xml` with the following co
---- ----
==== ====
[[aop-aj-ltw-environment-generic]] [[aop-aj-ltw-environment-generic]]
===== Generic Java Applications ===== Generic Java Applications
...@@ -3806,11 +3793,11 @@ support) a dedicated LTW. ...@@ -3806,11 +3793,11 @@ support) a dedicated LTW.
[[aop-resources]] [[aop-resources]]
== Further Resources == Further Resources
More information on AspectJ can be found on the http://www.eclipse.org/aspectj[AspectJ More information on AspectJ can be found on the http://www.eclipse.org/aspectj[AspectJ website].
website].
_Eclipse AspectJ_ by Adrian Colyer et. al. (Addison-Wesley, 2005) provides a _Eclipse AspectJ_ by Adrian Colyer et. al. (Addison-Wesley, 2005) provides a
comprehensive introduction and reference for the AspectJ language. comprehensive introduction and reference for the AspectJ language.
......
...@@ -30,8 +30,9 @@ correct schema so that the tags in the `util` namespace are available to you): ...@@ -30,8 +30,9 @@ correct schema so that the tags in the `util` namespace are available to you):
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
__xmlns:util="http://www.springframework.org/schema/util"__ xsi:schemaLocation=" __xmlns:util="http://www.springframework.org/schema/util"__ xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
__http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"__> <!-- bean definitions here --> __http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"__>
<!-- bean definitions here -->
</beans> </beans>
---- ----
==== ====
...@@ -322,7 +323,7 @@ bean, there is no need to refer to it at all, as the following example shows: ...@@ -322,7 +323,7 @@ bean, there is no need to refer to it at all, as the following example shows:
==== ====
You can specifically set the result type in the actual definition. This is not necessary You can specifically set the result type in the actual definition. This is not necessary
for most use cases, but it can sometimes be useful. See the Javadoc for more info on for most use cases, but it can sometimes be useful. See the javadoc for more info on
this feature. this feature.
...@@ -576,8 +577,9 @@ are available to you): ...@@ -576,8 +577,9 @@ are available to you):
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
__xmlns:aop="http://www.springframework.org/schema/aop"__ xsi:schemaLocation=" __xmlns:aop="http://www.springframework.org/schema/aop"__ xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
__http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"__> <!-- bean definitions here --> __http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"__>
<!-- bean definitions here -->
</beans> </beans>
---- ----
==== ====
...@@ -602,8 +604,9 @@ available to you: ...@@ -602,8 +604,9 @@ available to you:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
__xmlns:context="http://www.springframework.org/schema/context"__ xsi:schemaLocation=" __xmlns:context="http://www.springframework.org/schema/context"__ xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
__http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"__> <!-- bean definitions here --> __http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"__>
<!-- bean definitions here -->
</beans> </beans>
---- ----
==== ====
......
...@@ -5,6 +5,7 @@ This chapter covers Spring's Inversion of Control (IoC) container. ...@@ -5,6 +5,7 @@ This chapter covers Spring's Inversion of Control (IoC) container.
[[beans-introduction]] [[beans-introduction]]
== Introduction to the Spring IoC Container and Beans == Introduction to the Spring IoC Container and Beans
...@@ -3072,7 +3073,7 @@ To integrate your custom scopes into the Spring container, you need to implement ...@@ -3072,7 +3073,7 @@ To integrate your custom scopes into the Spring container, you need to implement
`org.springframework.beans.factory.config.Scope` interface, which is described in this `org.springframework.beans.factory.config.Scope` interface, which is described in this
section. For an idea of how to implement your own scopes, see the `Scope` section. For an idea of how to implement your own scopes, see the `Scope`
implementations that are supplied with the Spring Framework itself and the implementations that are supplied with the Spring Framework itself and the
{api-spring-framework}/beans/factory/config/Scope.html[`Scope` Javadoc], {api-spring-framework}/beans/factory/config/Scope.html[`Scope`] javadoc,
which explains the methods you need to implement in more detail. which explains the methods you need to implement in more detail.
The `Scope` interface has four methods to get objects from the scope, remove them from The `Scope` interface has four methods to get objects from the scope, remove them from
...@@ -3115,7 +3116,7 @@ destroyed or when the specified object in the scope is destroyed: ...@@ -3115,7 +3116,7 @@ destroyed or when the specified object in the scope is destroyed:
---- ----
==== ====
See the {api-spring-framework}/beans/factory/config/Scope.html#registerDestructionCallback[Javadoc] See the {api-spring-framework}/beans/factory/config/Scope.html#registerDestructionCallback[javadoc]
or a Spring scope implementation for more information on destruction callbacks. or a Spring scope implementation for more information on destruction callbacks.
The following method obtains the conversation identifier for the underlying scope: The following method obtains the conversation identifier for the underlying scope:
...@@ -3963,12 +3964,13 @@ after the Spring container finishes instantiating, configuring, and initializing ...@@ -3963,12 +3964,13 @@ after the Spring container finishes instantiating, configuring, and initializing
you can plug in one or more `BeanPostProcessor` implementations. you can plug in one or more `BeanPostProcessor` implementations.
You can configure multiple `BeanPostProcessor` instances, and you can control the order You can configure multiple `BeanPostProcessor` instances, and you can control the order
in which these `BeanPostProcessor` instances execute by setting the `order` property. You can in which these `BeanPostProcessor` instances execute by setting the `order` property.
set this property only if the `BeanPostProcessor` implements the `Ordered` interface. If You can set this property only if the `BeanPostProcessor` implements the `Ordered`
you write your own `BeanPostProcessor`, you should consider implementing the `Ordered` interface. If you write your own `BeanPostProcessor`, you should consider implementing
interface, too. For further details, see the Javadoc of the {api-spring-framework}/beans/factory/config/BeanPostProcessor.html[`BeanPostProcessor`] and the `Ordered` interface, too. For further details, see the javadoc of the
{api-spring-framework}/core/Ordered.html[`Ordered`] interfaces. See also the note on {api-spring-framework}/beans/factory/config/BeanPostProcessor.html[`BeanPostProcessor`]
<<beans-factory-programmatically-registering-beanpostprocessors, programmatic and {api-spring-framework}/core/Ordered.html[`Ordered`] interfaces. See also the note
on <<beans-factory-programmatically-registering-beanpostprocessors, programmatic
registration of `BeanPostProcessor` instances>>. registration of `BeanPostProcessor` instances>>.
[NOTE] [NOTE]
...@@ -4184,7 +4186,7 @@ You can configure multiple `BeanFactoryPostProcessor` instances, and you can con ...@@ -4184,7 +4186,7 @@ You can configure multiple `BeanFactoryPostProcessor` instances, and you can con
which these `BeanFactoryPostProcessor` instances run by setting the `order` property. which these `BeanFactoryPostProcessor` instances run by setting the `order` property.
However, you can only set this property if the `BeanFactoryPostProcessor` implements the However, you can only set this property if the `BeanFactoryPostProcessor` implements the
`Ordered` interface. If you write your own `BeanFactoryPostProcessor`, you should `Ordered` interface. If you write your own `BeanFactoryPostProcessor`, you should
consider implementing the `Ordered` interface, too. See the Javadoc of the consider implementing the `Ordered` interface, too. See the javadoc of the
{api-spring-framework}/beans/factory/config/BeanFactoryPostProcessor.html[`BeanFactoryPostProcessor`] and {api-spring-framework}/core/Ordered.html[`Ordered`] interfaces for more details. {api-spring-framework}/beans/factory/config/BeanFactoryPostProcessor.html[`BeanFactoryPostProcessor`] and {api-spring-framework}/core/Ordered.html[`Ordered`] interfaces for more details.
[NOTE] [NOTE]
...@@ -4302,7 +4304,7 @@ the following three supported integer values: ...@@ -4302,7 +4304,7 @@ the following three supported integer values:
* `override` (2): Check system properties first, before trying the specified * `override` (2): Check system properties first, before trying the specified
properties files. This lets system properties override any other property source. properties files. This lets system properties override any other property source.
See the {api-spring-framework}/beans/factory/config/PropertyPlaceholderConfigurer.html[`PropertyPlaceholderConfigurer`] Javadoc for more information. See the {api-spring-framework}/beans/factory/config/PropertyPlaceholderConfigurer.html[`PropertyPlaceholderConfigurer`] javadoc for more information.
[TIP] [TIP]
===== =====
...@@ -7778,8 +7780,8 @@ method that returns `true` or `false`. For example, the following listing shows ...@@ -7778,8 +7780,8 @@ method that returns `true` or `false`. For example, the following listing shows
---- ----
==== ====
See the {api-spring-framework}/context/annotation/Conditional.html[ See the {api-spring-framework}/context/annotation/Conditional.html[`@Conditional`]
`@Conditional` Javadoc] for more detail. javadoc for more detail.
[[beans-java-combining]] [[beans-java-combining]]
...@@ -8617,8 +8619,8 @@ may implement `LoadTimeWeaverAware`, thereby receiving a reference to the load-t ...@@ -8617,8 +8619,8 @@ may implement `LoadTimeWeaverAware`, thereby receiving a reference to the load-t
weaver instance. This is particularly useful in combination with weaver instance. This is particularly useful in combination with
<<data-access.adoc#orm-jpa,Spring's JPA support>> where load-time weaving may be necessary <<data-access.adoc#orm-jpa,Spring's JPA support>> where load-time weaving may be necessary
for JPA class transformation. for JPA class transformation.
Consult the {api-spring-framework}/orm/jpa/LocalContainerEntityManagerFactoryBean.html[`LocalContainerEntityManagerFactoryBean` javadoc] Consult the {api-spring-framework}/orm/jpa/LocalContainerEntityManagerFactoryBean.html[`LocalContainerEntityManagerFactoryBean`]
for more detail. For more on AspectJ load-time weaving, see <<aop-aj-ltw>>. javadoc for more detail. For more on AspectJ load-time weaving, see <<aop-aj-ltw>>.
...@@ -8863,8 +8865,8 @@ file format but is more flexible than the standard JDK based ...@@ -8863,8 +8865,8 @@ file format but is more flexible than the standard JDK based
`ResourceBundleMessageSource` implementation. In particular, it allows for reading `ResourceBundleMessageSource` implementation. In particular, it allows for reading
files from any Spring resource location (not only from the classpath) and supports hot files from any Spring resource location (not only from the classpath) and supports hot
reloading of bundle property files (while efficiently caching them in between). reloading of bundle property files (while efficiently caching them in between).
See the {api-spring-framework}/context/support/ReloadableResourceBundleMessageSource.html[`ReloadableResourceBundleMessageSource` javadoc] See the {api-spring-framework}/context/support/ReloadableResourceBundleMessageSource.html[`ReloadableResourceBundleMessageSource`]
for details. javadoc for details.
......
...@@ -9,6 +9,7 @@ platforms (that is, Servlet 3.1+). ...@@ -9,6 +9,7 @@ platforms (that is, Servlet 3.1+).
== `DataBufferFactory` == `DataBufferFactory`
The `DataBufferFactory` offers functionality to allocate new data buffers as well as to wrap The `DataBufferFactory` offers functionality to allocate new data buffers as well as to wrap
...@@ -21,9 +22,9 @@ Wrapping does not involve allocation. It decorates the given data with a `DataBu ...@@ -21,9 +22,9 @@ Wrapping does not involve allocation. It decorates the given data with a `DataBu
implementation. implementation.
There are two implementation of `DataBufferFactory`: the `NettyDataBufferFactory` There are two implementation of `DataBufferFactory`: the `NettyDataBufferFactory`
(for Netty platforms, such as Reactor Netty) and (for Netty platforms, such as Reactor Netty) and `DefaultDataBufferFactory`
`DefaultDataBufferFactory` (for other platforms, such as (for other platforms, such as Servlet 3.1+ servers).
Servlet 3.1+ servers).
...@@ -153,6 +154,7 @@ streaming solution would. ...@@ -153,6 +154,7 @@ streaming solution would.
[[codecs]] [[codecs]]
== Codecs == Codecs
......
...@@ -54,6 +54,7 @@ The expression language supports the following functionality: ...@@ -54,6 +54,7 @@ The expression language supports the following functionality:
[[expressions-evaluation]] [[expressions-evaluation]]
== Evaluation == Evaluation
...@@ -322,19 +323,18 @@ someArray[0].someProperty.someOtherProperty < 0.1 ...@@ -322,19 +323,18 @@ someArray[0].someProperty.someOtherProperty < 0.1
---- ----
==== ====
Because the preceding expression involves array access, some property de-referencing, and numeric operations, the performance Because the preceding expression involves array access, some property de-referencing,
gain can be very noticeable. In an example micro benchmark run of 50000 iterations, it and numeric operations, the performance gain can be very noticeable. In an example
took 75ms to evaluate by using the interpreter and only 3ms using the compiled version micro benchmark run of 50000 iterations, it took 75ms to evaluate by using the
of the expression. interpreter and only 3ms using the compiled version of the expression.
[[expressions-compiler-configuration]] [[expressions-compiler-configuration]]
==== Compiler Configuration ==== Compiler Configuration
The compiler is not turned on by default, but you can turn it on in either of two different The compiler is not turned on by default, but you can turn it on in either of two different ways.
ways. You can turn it on by using the parser configuration process (<<expressions-parser-configuration,discussed earlier>>) or You can turn it on by using the parser configuration process (<<expressions-parser-configuration,discussed earlier>>)
by using a system property when SpEL usage is embedded inside another component. This section or by using a system property when SpEL usage is embedded inside another component. This section
discusses both of these options. discusses both of these options.
The compiler can operate in one of three modes, which are captured The compiler can operate in one of three modes, which are captured
...@@ -409,6 +409,7 @@ More types of expression will be compilable in the future. ...@@ -409,6 +409,7 @@ More types of expression will be compilable in the future.
[[expressions-beandef]] [[expressions-beandef]]
== Expressions in Bean Definitions == Expressions in Bean Definitions
...@@ -574,6 +575,7 @@ examples show: ...@@ -574,6 +575,7 @@ examples show:
[[expressions-language-ref]] [[expressions-language-ref]]
== Language Reference == Language Reference
...@@ -596,6 +598,8 @@ topics: ...@@ -596,6 +598,8 @@ topics:
* <<expressions-operator-elvis>> * <<expressions-operator-elvis>>
* <<expressions-operator-safe-navigation>> * <<expressions-operator-safe-navigation>>
[[expressions-ref-literal]] [[expressions-ref-literal]]
=== Literal Expressions === Literal Expressions
...@@ -886,7 +890,6 @@ which the expression is embedded (such as in an XML document). The textual equiv ...@@ -886,7 +890,6 @@ which the expression is embedded (such as in an XML document). The textual equiv
All of the textual operators are case-insensitive. All of the textual operators are case-insensitive.
[[expressions-operators-logical]] [[expressions-operators-logical]]
==== Logical Operators ==== Logical Operators
...@@ -932,7 +935,6 @@ The following example shows how to use the logical operators ...@@ -932,7 +935,6 @@ The following example shows how to use the logical operators
==== ====
[[expressions-operators-mathematical]] [[expressions-operators-mathematical]]
==== Mathematical Operators ==== Mathematical Operators
...@@ -977,7 +979,6 @@ following example shows the mathematical operators in use: ...@@ -977,7 +979,6 @@ following example shows the mathematical operators in use:
==== ====
[[expressions-assignment]] [[expressions-assignment]]
==== The Assignment Operator ==== The Assignment Operator
...@@ -1075,7 +1076,6 @@ following example shows how to use variables: ...@@ -1075,7 +1076,6 @@ following example shows how to use variables:
==== ====
[[expressions-this-root]] [[expressions-this-root]]
==== The `#this` and `#root` Variables ==== The `#this` and `#root` Variables
...@@ -1457,6 +1457,7 @@ The definition of `TemplateParserContext` follows: ...@@ -1457,6 +1457,7 @@ The definition of `TemplateParserContext` follows:
[[expressions-example-classes]] [[expressions-example-classes]]
== Classes Used in the Examples == Classes Used in the Examples
......
...@@ -27,6 +27,7 @@ NOTE: Libraries like Reactor or Spring Data provide null-safe APIs that use this ...@@ -27,6 +27,7 @@ NOTE: Libraries like Reactor or Spring Data provide null-safe APIs that use this
== Use cases == Use cases
In addition to providing an explicit declaration for Spring Framework API nullability, In addition to providing an explicit declaration for Spring Framework API nullability,
...@@ -38,6 +39,9 @@ They are also used to make Spring API null-safe in Kotlin projects, since Kotlin ...@@ -38,6 +39,9 @@ They are also used to make Spring API null-safe in Kotlin projects, since Kotlin
supports https://kotlinlang.org/docs/reference/null-safety.html[null-safety]. More details supports https://kotlinlang.org/docs/reference/null-safety.html[null-safety]. More details
are available in the <<languages#kotlin-null-safety,Kotlin support documentation>>. are available in the <<languages#kotlin-null-safety,Kotlin support documentation>>.
== JSR 305 meta-annotations == JSR 305 meta-annotations
Spring annotations are meta-annotated with https://jcp.org/en/jsr/detail?id=305[JSR 305] Spring annotations are meta-annotated with https://jcp.org/en/jsr/detail?id=305[JSR 305]
......
...@@ -14,6 +14,7 @@ Spring. It includes the following topics: ...@@ -14,6 +14,7 @@ Spring. It includes the following topics:
[[resources-introduction]] [[resources-introduction]]
== Introduction == Introduction
...@@ -28,6 +29,7 @@ such as a method to check for the existence of the resource being pointed to. ...@@ -28,6 +29,7 @@ such as a method to check for the existence of the resource being pointed to.
[[resources-resource]] [[resources-resource]]
== The Resource Interface == The Resource Interface
...@@ -114,6 +116,7 @@ wrapped `URL` to do its work. ...@@ -114,6 +116,7 @@ wrapped `URL` to do its work.
[[resources-implementations]] [[resources-implementations]]
== Built-in Resource Implementations == Built-in Resource Implementations
...@@ -163,18 +166,18 @@ to the filesystem. To address this, the various `Resource` implementations alway ...@@ -163,18 +166,18 @@ to the filesystem. To address this, the various `Resource` implementations alway
resolution as a `java.net.URL`. resolution as a `java.net.URL`.
A `ClassPathResource` is created by Java code by explicitly using the `ClassPathResource` A `ClassPathResource` is created by Java code by explicitly using the `ClassPathResource`
constructor but is often created implicitly when you call an API method that constructor but is often created implicitly when you call an API method that takes a
takes a `String` argument meant to represent a path. For the latter case, a `String` argument meant to represent a path. For the latter case, a JavaBeans
JavaBeans `PropertyEditor` recognizes the special prefix, `classpath:`, on the string `PropertyEditor` recognizes the special prefix, `classpath:`, on the string path and
path and creates a `ClassPathResource` in that case. creates a `ClassPathResource` in that case.
[[resources-implementations-filesystemresource]] [[resources-implementations-filesystemresource]]
=== `FileSystemResource` === `FileSystemResource`
This is a `Resource` implementation for `java.io.File` handles. It supports This is a `Resource` implementation for `java.io.File` and `java.nio.file.Path` handles.
resolution as a `File` and as a `URL`. It supports resolution as a `File` and as a `URL`.
...@@ -316,6 +319,7 @@ The following table summarizes the strategy for converting `String` objects to ` ...@@ -316,6 +319,7 @@ The following table summarizes the strategy for converting `String` objects to `
[[resources-resourceloaderaware]] [[resources-resourceloaderaware]]
== The `ResourceLoaderAware` interface == The `ResourceLoaderAware` interface
...@@ -360,6 +364,7 @@ annotation. For more information, see <<beans-autowired-annotation>>. ...@@ -360,6 +364,7 @@ annotation. For more information, see <<beans-autowired-annotation>>.
[[resources-as-dependencies]] [[resources-as-dependencies]]
== Resources as Dependencies == Resources as Dependencies
...@@ -411,6 +416,7 @@ The following two examples show how to force a `ClassPathResource` and a ...@@ -411,6 +416,7 @@ The following two examples show how to force a `ClassPathResource` and a
[[resources-app-ctx]] [[resources-app-ctx]]
== Application Contexts and Resource Paths == Application Contexts and Resource Paths
...@@ -470,7 +476,6 @@ Using `FileSystemXmlApplicationContext` loads the bean definitions from the clas ...@@ -470,7 +476,6 @@ Using `FileSystemXmlApplicationContext` loads the bean definitions from the clas
unprefixed paths are still treated as filesystem paths. unprefixed paths are still treated as filesystem paths.
[[resources-app-ctx-classpathxml]] [[resources-app-ctx-classpathxml]]
==== Constructing `ClassPathXmlApplicationContext` Instances -- Shortcuts ==== Constructing `ClassPathXmlApplicationContext` Instances -- Shortcuts
...@@ -506,8 +511,8 @@ files named `services.xml` and `daos.xml` (which are on the classpath) can be in ...@@ -506,8 +511,8 @@ files named `services.xml` and `daos.xml` (which are on the classpath) can be in
---- ----
==== ====
See the {api-spring-framework}/jca/context/SpringContextResourceAdapter.html[`ClassPathXmlApplicationContext` Javadoc] for details See the {api-spring-framework}/jca/context/SpringContextResourceAdapter.html[`ClassPathXmlApplicationContext`]
on the various constructors. javadoc for details on the various constructors.
...@@ -532,7 +537,6 @@ You cannot use the `classpath*:` prefix to construct an actual `Resource`, as ...@@ -532,7 +537,6 @@ You cannot use the `classpath*:` prefix to construct an actual `Resource`, as
a resource points to just one resource at a time. a resource points to just one resource at a time.
[[resources-app-ctx-ant-patterns-in-paths]] [[resources-app-ctx-ant-patterns-in-paths]]
==== Ant-style Patterns ==== Ant-style Patterns
...@@ -561,26 +565,23 @@ the wildcards. ...@@ -561,26 +565,23 @@ the wildcards.
[[resources-app-ctx-portability]] [[resources-app-ctx-portability]]
===== Implications on Portability ===== Implications on Portability
If the specified path is already a file URL (either implicitly because If the specified path is already a file URL (either implicitly because the base
the base `ResourceLoader` is a filesystem one or explicitly), wildcarding is guaranteed to work in `ResourceLoader` is a filesystem one or explicitly), wildcarding is guaranteed to
a completely portable fashion. work in a completely portable fashion.
If the specified path is a classpath location, the resolver must obtain the last If the specified path is a classpath location, the resolver must obtain the last
non-wildcard path segment URL by making a `Classloader.getResource()` call. Since this is just non-wildcard path segment URL by making a `Classloader.getResource()` call. Since this
a node of the path (not the file at the end), it is actually undefined (in the is just a node of the path (not the file at the end), it is actually undefined (in the
`ClassLoader` Javadoc) exactly what sort of a URL is returned in this case. In `ClassLoader` javadoc) exactly what sort of a URL is returned in this case. In practice,
practice, it is always a `java.io.File` representing the directory (where the classpath it is always a `java.io.File` representing the directory (where the classpath resource
resource resolves to a filesystem location) or a jar URL of some sort w(here the resolves to a filesystem location) or a jar URL of some sort (where the classpath resource
classpath resource resolves to a jar location). Still, there is a portability concern on resolves to a jar location). Still, there is a portability concern on this operation.
this operation.
If a jar URL is obtained for the last non-wildcard segment, the resolver must be able to If a jar URL is obtained for the last non-wildcard segment, the resolver must be able to
get a `java.net.JarURLConnection` from it or manually parse the jar URL, to be able to get a `java.net.JarURLConnection` from it or manually parse the jar URL, to be able to
walk the contents of the jar and resolve the wildcard. This does work in most walk the contents of the jar and resolve the wildcard. This does work in most environments
environments but fails in others, and we strongly recommend that the wildcard but fails in others, and we strongly recommend that the wildcard resolution of resources
resolution of resources coming from jars be thoroughly tested in your specific coming from jars be thoroughly tested in your specific environment before you rely on it.
environment before you rely on it.
[[resources-classpath-wildcards]] [[resources-classpath-wildcards]]
...@@ -621,7 +622,6 @@ class loader hierarchy and then, off each resource, the same `PathMatcher` resol ...@@ -621,7 +622,6 @@ class loader hierarchy and then, off each resource, the same `PathMatcher` resol
strategy described earlier is used for the wildcard subpath. strategy described earlier is used for the wildcard subpath.
[[resources-wildcards-in-path-other-stuff]] [[resources-wildcards-in-path-other-stuff]]
==== Other Notes Relating to Wildcards ==== Other Notes Relating to Wildcards
...@@ -640,10 +640,10 @@ as well, but this is not guaranteed to lead to portable behavior. ...@@ -640,10 +640,10 @@ as well, but this is not guaranteed to lead to portable behavior.
[NOTE] [NOTE]
==== ====
The scanning of classpath packages requires the presence of corresponding directory The scanning of classpath packages requires the presence of corresponding directory
entries in the classpath. When you build JARs with Ant, do not entries in the classpath. When you build JARs with Ant, do not activate the files-only
activate the files-only switch of the JAR task. Also, classpath directories may not switch of the JAR task. Also, classpath directories may not get exposed based on security
get exposed based on security policies in some environments -- for example, stand-alone applications on policies in some environments -- for example, stand-alone applications on JDK 1.7.0_45
JDK 1.7.0_45 and higher (which requires 'Trusted-Library' to be set up in your manifests. See and higher (which requires 'Trusted-Library' to be set up in your manifests. See
http://stackoverflow.com/questions/19394570/java-jre-7u45-breaks-classloader-getresources). http://stackoverflow.com/questions/19394570/java-jre-7u45-breaks-classloader-getresources).
On JDK 9's module path (Jigsaw), Spring's classpath scanning generally works as expected. On JDK 9's module path (Jigsaw), Spring's classpath scanning generally works as expected.
......
[[validation]] [[validation]]
= Validation, Data Binding, and Type Conversion = Validation, Data Binding, and Type Conversion
There are pros and cons for considering validation as business logic, and Spring offers There are pros and cons for considering validation as business logic, and Spring offers
a design for validation (and data binding) that does not exclude either one of them. a design for validation (and data binding) that does not exclude either one of them.
Specifically, validation should not be tied to the web tier and should be easy to localize, Specifically, validation should not be tied to the web tier and should be easy to localize,
...@@ -45,6 +43,7 @@ plugging in validation logic without the use of annotations. ...@@ -45,6 +43,7 @@ plugging in validation logic without the use of annotations.
[[validator]] [[validator]]
== Validation by Using Spring's Validator Interface == Validation by Using Spring's Validator Interface
...@@ -105,10 +104,10 @@ example implements `Validator` for `Person` instances: ...@@ -105,10 +104,10 @@ example implements `Validator` for `Person` instances:
---- ----
==== ====
The `static` `rejectIfEmpty(..)` method on the `ValidationUtils` class The `static` `rejectIfEmpty(..)` method on the `ValidationUtils` class is used to
is used to reject the `name` property if it is `null` or the empty string. See reject the `name` property if it is `null` or the empty string. Have a look at the
at the {api-spring-framework}/validation/ValidationUtils.html[`ValidationUtils` Javadoc] to see what functionality it provides besides the {api-spring-framework}/validation/ValidationUtils.html[`ValidationUtils`] javadoc
example shown previously. to see what functionality it provides besides the example shown previously.
While it is certainly possible to implement a single `Validator` class to validate each While it is certainly possible to implement a single `Validator` class to validate each
of the nested objects in a rich object, it may be better to encapsulate the validation of the nested objects in a rich object, it may be better to encapsulate the validation
...@@ -166,7 +165,8 @@ as the following example shows: ...@@ -166,7 +165,8 @@ as the following example shows:
Validation errors are reported to the `Errors` object passed to the validator. In the case Validation errors are reported to the `Errors` object passed to the validator. In the case
of Spring Web MVC, you can use the `<spring:bind/>` tag to inspect the error messages, but of Spring Web MVC, you can use the `<spring:bind/>` tag to inspect the error messages, but
you can also inspect the `Errors` object yourself. More information about the you can also inspect the `Errors` object yourself. More information about the
methods it offers can be found in the {api-spring-framework}validation/Errors.html[Javadoc]. methods it offers can be found in the {api-spring-framework}validation/Errors.html[javadoc].
...@@ -191,14 +191,14 @@ the field name and the second includes the type of the field). This is done as a ...@@ -191,14 +191,14 @@ the field name and the second includes the type of the field). This is done as a
convenience to aid developers when targeting error messages. convenience to aid developers when targeting error messages.
More information on the `MessageCodesResolver` and the default strategy can be found More information on the `MessageCodesResolver` and the default strategy can be found
in the Javadoc of in the javadoc of
{api-spring-framework}/validation/MessageCodesResolver.html[`MessageCodesResolver`] {api-spring-framework}/validation/MessageCodesResolver.html[`MessageCodesResolver`] and
and
{api-spring-framework}/validation/DefaultMessageCodesResolver.html[`DefaultMessageCodesResolver`], {api-spring-framework}/validation/DefaultMessageCodesResolver.html[`DefaultMessageCodesResolver`],
respectively. respectively.
[[beans-beans]] [[beans-beans]]
== Bean Manipulation and the `BeanWrapper` == Bean Manipulation and the `BeanWrapper`
...@@ -210,16 +210,16 @@ more information about JavaBeans and the specification, see ...@@ -210,16 +210,16 @@ more information about JavaBeans and the specification, see
http://docs.oracle.com/javase/8/docs/api/java/beans/package-summary.html[javabeans]. http://docs.oracle.com/javase/8/docs/api/java/beans/package-summary.html[javabeans].
One quite important class in the beans package is the `BeanWrapper` interface and its One quite important class in the beans package is the `BeanWrapper` interface and its
corresponding implementation (`BeanWrapperImpl`). As quoted from the Javadoc, the corresponding implementation (`BeanWrapperImpl`). As quoted from the javadoc, the
`BeanWrapper` offers functionality to set and get property values (individually or in `BeanWrapper` offers functionality to set and get property values (individually or in
bulk), get property descriptors, and query properties to determine if they are bulk), get property descriptors, and query properties to determine if they are
readable or writable. Also, the `BeanWrapper` offers support for nested properties, readable or writable. Also, the `BeanWrapper` offers support for nested properties,
enabling the setting of properties on sub-properties to an unlimited depth. The enabling the setting of properties on sub-properties to an unlimited depth. The
`BeanWrapper` also supports the ability to add standard JavaBeans `PropertyChangeListeners` `BeanWrapper` also supports the ability to add standard JavaBeans `PropertyChangeListeners`
and `VetoableChangeListeners`, without the need for supporting code in the target class. and `VetoableChangeListeners`, without the need for supporting code in the target class.
Last but not least, the `BeanWrapper` provides support for setting indexed Last but not least, the `BeanWrapper` provides support for setting indexed properties.
properties. The `BeanWrapper` usually is not used by application code directly but is used by The `BeanWrapper` usually is not used by application code directly but is used by the
the `DataBinder` and the `BeanFactory`. `DataBinder` and the `BeanFactory`.
The way the `BeanWrapper` works is partly indicated by its name: it wraps a bean to The way the `BeanWrapper` works is partly indicated by its name: it wraps a bean to
perform actions on that bean, such as setting and retrieving properties. perform actions on that bean, such as setting and retrieving properties.
...@@ -229,9 +229,9 @@ perform actions on that bean, such as setting and retrieving properties. ...@@ -229,9 +229,9 @@ perform actions on that bean, such as setting and retrieving properties.
[[beans-beans-conventions]] [[beans-beans-conventions]]
=== Setting and Getting Basic and Nested Properties === Setting and Getting Basic and Nested Properties
Setting and getting properties is done by using the `setPropertyValue`, `setPropertyValues`, Setting and getting properties is done by using the `setPropertyValue`,
`getPropertyValue`, and `getPropertyValues` methods that both come with a couple of overloaded variants. `setPropertyValues`, `getPropertyValue`, and `getPropertyValues` methods which come
Springs Javadoc describes them all in more detail. with a couple of overloaded variants. Springs javadoc describes them in more detail.
The JavaBeans specification has conventions for indicating properties of an The JavaBeans specification has conventions for indicating properties of an
object. The following table shows some examples of these conventions: object. The following table shows some examples of these conventions:
...@@ -359,7 +359,7 @@ behavior can be achieved by registering custom editors of type ...@@ -359,7 +359,7 @@ behavior can be achieved by registering custom editors of type
`java.beans.PropertyEditor`. Registering custom editors on a `BeanWrapper` or, `java.beans.PropertyEditor`. Registering custom editors on a `BeanWrapper` or,
alternatively, in a specific IoC container (as mentioned in the previous chapter), gives it alternatively, in a specific IoC container (as mentioned in the previous chapter), gives it
the knowledge of how to convert properties to the desired type. For more about the knowledge of how to convert properties to the desired type. For more about
`PropertyEditor`, see https://docs.oracle.com/javase/8/docs/api/java/beans/package-summary.html[the Javadoc of the `java.beans` package from Oracle]. `PropertyEditor`, see https://docs.oracle.com/javase/8/docs/api/java/beans/package-summary.html[the javadoc of the `java.beans` package from Oracle].
A couple of examples where property editing is used in Spring: A couple of examples where property editing is used in Spring:
...@@ -431,8 +431,8 @@ the various `PropertyEditor` implementations that Spring provides: ...@@ -431,8 +431,8 @@ the various `PropertyEditor` implementations that Spring provides:
| Can resolve strings to `java.util.regex.Pattern` objects and vice-versa. | Can resolve strings to `java.util.regex.Pattern` objects and vice-versa.
| `PropertiesEditor` | `PropertiesEditor`
| Can convert strings (formatted with the format defined in the Javadoc | Can convert strings (formatted with the format defined in the javadoc of the
of the `java.util.Properties` class) to `Properties` objects. By default, registered `java.util.Properties` class) to `Properties` objects. By default, registered
by `BeanWrapperImpl`. by `BeanWrapperImpl`.
| `StringTrimmerEditor` | `StringTrimmerEditor`
...@@ -625,8 +625,6 @@ Finally, the following example shows how to use `CustomEditorConfigurer` to regi ...@@ -625,8 +625,6 @@ Finally, the following example shows how to use `CustomEditorConfigurer` to regi
---- ----
==== ====
[[beans-beans-conversion-customeditor-registration-per]] [[beans-beans-conversion-customeditor-registration-per]]
===== Using `PropertyEditorRegistrar` ===== Using `PropertyEditorRegistrar`
...@@ -724,6 +722,7 @@ registration code be encapsulated in a class and then shared amongst as many ...@@ -724,6 +722,7 @@ registration code be encapsulated in a class and then shared amongst as many
[[core-convert]] [[core-convert]]
== Spring Type Conversion == Spring Type Conversion
...@@ -881,9 +880,9 @@ the target collection type to resolve the collection's element type. This lets e ...@@ -881,9 +880,9 @@ the target collection type to resolve the collection's element type. This lets e
element in the source array be converted to the collection element type before the element in the source array be converted to the collection element type before the
collection is set on the target field. collection is set on the target field.
NOTE: Because `GenericConverter` is a more complex SPI interface, you should use it only when you need it. NOTE: Because `GenericConverter` is a more complex SPI interface, you should use
Favor `Converter` or `ConverterFactory` for basic type conversion needs. it only when you need it. Favor `Converter` or `ConverterFactory` for basic type
conversion needs.
[[core-convert-ConditionalGenericConverter-SPI]] [[core-convert-ConditionalGenericConverter-SPI]]
...@@ -1067,6 +1066,7 @@ no need to create a specific converter to convert from a `Collection` of `S` to ...@@ -1067,6 +1066,7 @@ no need to create a specific converter to convert from a `Collection` of `S` to
[[format]] [[format]]
== Spring Field Formatting == Spring Field Formatting
...@@ -1387,6 +1387,7 @@ See <<web.adoc#mvc-config-conversion, Conversion and Formatting>> in the Spring ...@@ -1387,6 +1387,7 @@ See <<web.adoc#mvc-config-conversion, Conversion and Formatting>> in the Spring
[[format-configuring-formatting-globaldatetimeformat]] [[format-configuring-formatting-globaldatetimeformat]]
== Configuring a Global Date and Time Format == Configuring a Global Date and Time Format
...@@ -1613,7 +1614,6 @@ the Spring Validation API, as the following example shows: ...@@ -1613,7 +1614,6 @@ the Spring Validation API, as the following example shows:
==== ====
[[validation-beanvalidation-spring-constraints]] [[validation-beanvalidation-spring-constraints]]
==== Configuring Custom Constraints ==== Configuring Custom Constraints
...@@ -1681,10 +1681,10 @@ through a `MethodValidationPostProcessor` bean definition, as follows: ...@@ -1681,10 +1681,10 @@ through a `MethodValidationPostProcessor` bean definition, as follows:
---- ----
==== ====
To be eligible for Spring-driven method validation, all target classes need To be eligible for Spring-driven method validation, all target classes need to be annotated with
to be annotated with Spring's `@Validated` annotation. (Optionally, you can also declare the Spring's `@Validated` annotation. (Optionally, you can also declare the validation groups to use.)
validation groups to use.) See the {api-spring-framework}/validation/beanvalidation/MethodValidationPostProcessor.html[`MethodValidationPostProcessor` Javadoc] See the {api-spring-framework}/validation/beanvalidation/MethodValidationPostProcessor.html[`MethodValidationPostProcessor`]
for setup details with the Hibernate Validator and Bean Validation 1.1 providers. javadoc for setup details with the Hibernate Validator and Bean Validation 1.1 providers.
[[validation-beanvalidation-spring-other]] [[validation-beanvalidation-spring-other]]
...@@ -1693,7 +1693,8 @@ for setup details with the Hibernate Validator and Bean Validation 1.1 providers ...@@ -1693,7 +1693,8 @@ for setup details with the Hibernate Validator and Bean Validation 1.1 providers
The default `LocalValidatorFactoryBean` configuration suffices for most The default `LocalValidatorFactoryBean` configuration suffices for most
cases. There are a number of configuration options for various Bean Validation cases. There are a number of configuration options for various Bean Validation
constructs, from message interpolation to traversal resolution. See the constructs, from message interpolation to traversal resolution. See the
{api-spring-framework}/validation/beanvalidation/LocalValidatorFactoryBean.html[`LocalValidatorFactoryBean` Javadoc] for more information on these options. {api-spring-framework}/validation/beanvalidation/LocalValidatorFactoryBean.html[`LocalValidatorFactoryBean`]
javadoc for more information on these options.
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
[[xsd-schemas]] [[xsd-schemas]]
== XML Schemas == XML Schemas
......
此差异已折叠。
= Appendix = Appendix
[[xsd-schemas]] [[xsd-schemas]]
== XML Schemas == XML Schemas
...@@ -28,8 +30,8 @@ correct schema so that the elements in the `jee` namespace are available to you: ...@@ -28,8 +30,8 @@ correct schema so that the elements in the `jee` namespace are available to you:
__xmlns:jee="http://www.springframework.org/schema/jee"__ xsi:schemaLocation=" __xmlns:jee="http://www.springframework.org/schema/jee"__ xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
__http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd"__> __http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd"__>
<!-- bean definitions here -->
<!-- bean definitions here -->
</beans> </beans>
---- ----
==== ====
...@@ -39,8 +41,7 @@ correct schema so that the elements in the `jee` namespace are available to you: ...@@ -39,8 +41,7 @@ correct schema so that the elements in the `jee` namespace are available to you:
[[xsd-schemas-jee-jndi-lookup]] [[xsd-schemas-jee-jndi-lookup]]
==== <jee:jndi-lookup/> (simple) ==== <jee:jndi-lookup/> (simple)
The following example shows how to use JNDI to look up a data source without the `jee` The following example shows how to use JNDI to look up a data source without the `jee` schema:
schema:
==== ====
[source,xml,indent=0] [source,xml,indent=0]
...@@ -329,8 +330,9 @@ are available to you: ...@@ -329,8 +330,9 @@ are available to you:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
__xmlns:jms="http://www.springframework.org/schema/jms"__ xsi:schemaLocation=" __xmlns:jms="http://www.springframework.org/schema/jms"__ xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
__http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd"__> <!-- bean definitions here --> __http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd"__>
<!-- bean definitions here -->
</beans> </beans>
---- ----
==== ====
...@@ -366,8 +368,9 @@ the correct schema so that the elements in the `cache` namespace are available t ...@@ -366,8 +368,9 @@ the correct schema so that the elements in the `cache` namespace are available t
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
__xmlns:cache="http://www.springframework.org/schema/cache"__ xsi:schemaLocation=" __xmlns:cache="http://www.springframework.org/schema/cache"__ xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
__http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"__> <!-- bean definitions here --> __http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"__>
<!-- bean definitions here -->
</beans> </beans>
---- ----
==== ====
此差异已折叠。
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
:tabsize: 4 :tabsize: 4
:docinfo1: :docinfo1:
include::languages/kotlin.adoc[leveloffset=+1] include::languages/kotlin.adoc[leveloffset=+1]
include::languages/groovy.adoc[leveloffset=+1] include::languages/groovy.adoc[leveloffset=+1]
......
...@@ -952,7 +952,9 @@ are available to you: ...@@ -952,7 +952,9 @@ are available to you:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
__xmlns:lang="http://www.springframework.org/schema/lang"__ xsi:schemaLocation=" __xmlns:lang="http://www.springframework.org/schema/lang"__ xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
__http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd"__> <!-- bean definitions here --> __http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd"__>
<!-- bean definitions here -->
</beans> </beans>
---- ----
......
...@@ -113,7 +113,7 @@ libraries that depend on Spring. ...@@ -113,7 +113,7 @@ libraries that depend on Spring.
* Care about API design. The Spring team puts a lot of thought and time into making APIs * Care about API design. The Spring team puts a lot of thought and time into making APIs
that are intuitive and that hold up across many versions and many years. that are intuitive and that hold up across many versions and many years.
* Set high standards for code quality. The Spring Framework puts a strong emphasis on * Set high standards for code quality. The Spring Framework puts a strong emphasis on
meaningful, current, and accurate Javadoc. It is one of very few projects that can claim meaningful, current, and accurate javadoc. It is one of very few projects that can claim
clean code structure with no circular dependencies between packages. clean code structure with no circular dependencies between packages.
......
...@@ -12,6 +12,7 @@ related to use of the `WebTestClient`. ...@@ -12,6 +12,7 @@ related to use of the `WebTestClient`.
[[webtestclient-setup]] [[webtestclient-setup]]
== Setup == Setup
...@@ -137,6 +138,7 @@ are readily available following `bindToServer`. For all others, you need to use ...@@ -137,6 +138,7 @@ are readily available following `bindToServer`. For all others, you need to use
[[webtestclient-tests]] [[webtestclient-tests]]
== Writing Tests == Writing Tests
......
此差异已折叠。
...@@ -23,6 +23,7 @@ include::web/webflux-websocket.adoc[leveloffset=+1] ...@@ -23,6 +23,7 @@ include::web/webflux-websocket.adoc[leveloffset=+1]
[[webflux-test]] [[webflux-test]]
== Testing == Testing
[.small]#<<web.adoc#testing,Same in Spring MVC>># [.small]#<<web.adoc#testing,Same in Spring MVC>>#
...@@ -37,6 +38,7 @@ server. You can use the `WebTestClient` for end-to-end integration tests, too. ...@@ -37,6 +38,7 @@ server. You can use the `WebTestClient` for end-to-end integration tests, too.
//[[webflux-threading-model]] //[[webflux-threading-model]]
//=== Threading model //=== Threading model
// TODO Once we have content for this heading, we should un-comment the heading and // TODO Once we have content for this heading, we should un-comment the heading and
...@@ -44,6 +46,7 @@ server. You can use the `WebTestClient` for end-to-end integration tests, too. ...@@ -44,6 +46,7 @@ server. You can use the `WebTestClient` for end-to-end integration tests, too.
[[webflux-reactive-libraries]] [[webflux-reactive-libraries]]
== Reactive Libraries == Reactive Libraries
......
...@@ -14,8 +14,10 @@ popular third party web frameworks. ...@@ -14,8 +14,10 @@ popular third party web frameworks.
[[web-integration-common]] [[web-integration-common]]
== Common Configuration == Common Configuration
Before diving into the integration specifics of each supported web framework, let us Before diving into the integration specifics of each supported web framework, let us
first take a look at the Spring configuration that is not specific to any one web first take a look at the Spring configuration that is not specific to any one web
framework. (This section is equally applicable to Spring's own web framework, Spring framework. (This section is equally applicable to Spring's own web framework, Spring
...@@ -105,6 +107,7 @@ has more detail on its specific integration strategies. ...@@ -105,6 +107,7 @@ has more detail on its specific integration strategies.
[[jsf]] [[jsf]]
== JSF == JSF
...@@ -173,6 +176,7 @@ The following example shows how to use `FacesContextUtils`: ...@@ -173,6 +176,7 @@ The following example shows how to use `FacesContextUtils`:
[[struts]] [[struts]]
== Apache Struts 2.x == Apache Struts 2.x
...@@ -189,6 +193,7 @@ built-in Spring integration shipped with Struts. ...@@ -189,6 +193,7 @@ built-in Spring integration shipped with Struts.
[[tapestry]] [[tapestry]]
== Tapestry 5.x == Tapestry 5.x
...@@ -205,8 +210,10 @@ Spring]. ...@@ -205,8 +210,10 @@ Spring].
[[web-integration-resources]] [[web-integration-resources]]
== Further Resources == Further Resources
The following links go to further resources about the various web frameworks described in this The following links go to further resources about the various web frameworks described in this
chapter. chapter.
......
[[web-uricomponents]] [[web-uricomponents]]
= UriComponents = UriComponents
[.small]#Spring MVC and Spring WebFlux# [.small]#Spring MVC and Spring WebFlux#
......
...@@ -7,6 +7,7 @@ describes how to do so. ...@@ -7,6 +7,7 @@ describes how to do so.
[[webflux-cors-intro]] [[webflux-cors-intro]]
== Introduction == Introduction
[.small]#<<web.adoc#mvc-cors-intro,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-cors-intro,Same as in Spring MVC>>#
...@@ -23,6 +24,7 @@ powerful workarounds based on IFRAME or JSONP. ...@@ -23,6 +24,7 @@ powerful workarounds based on IFRAME or JSONP.
[[webflux-cors-processing]] [[webflux-cors-processing]]
== Processing == Processing
[.small]#<<web.adoc#mvc-cors-processing,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-cors-processing,Same as in Spring MVC>>#
...@@ -72,6 +74,7 @@ To learn more from the source or to make advanced customizations, see: ...@@ -72,6 +74,7 @@ To learn more from the source or to make advanced customizations, see:
[[webflux-cors-controller]] [[webflux-cors-controller]]
== `@CrossOrigin` == `@CrossOrigin`
[.small]#<<web.adoc#mvc-cors-controller,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-cors-controller,Same as in Spring MVC>>#
...@@ -170,6 +173,7 @@ public class AccountController { ...@@ -170,6 +173,7 @@ public class AccountController {
[[webflux-cors-global]] [[webflux-cors-global]]
== Global Configuration == Global Configuration
[.small]#<<web.adoc#mvc-cors-global,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-cors-global,Same as in Spring MVC>>#
...@@ -220,6 +224,7 @@ public class WebConfig implements WebFluxConfigurer { ...@@ -220,6 +224,7 @@ public class WebConfig implements WebFluxConfigurer {
[[webflux-cors-webfilter]] [[webflux-cors-webfilter]]
== CORS `WebFilter` == CORS `WebFilter`
[.small]#<<web.adoc#mvc-cors-filter,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-cors-filter,Same as in Spring MVC>>#
......
...@@ -8,6 +8,7 @@ the same <<web-reactive.adoc#webflux-reactive-spring-web>> foundation. ...@@ -8,6 +8,7 @@ the same <<web-reactive.adoc#webflux-reactive-spring-web>> foundation.
[[webflux-fn-overview]] [[webflux-fn-overview]]
== Overview == Overview
...@@ -71,6 +72,7 @@ Most applications can run through the WebFlux Java configuration, see <<webflux- ...@@ -71,6 +72,7 @@ Most applications can run through the WebFlux Java configuration, see <<webflux-
[[webflux-fn-handler-functions]] [[webflux-fn-handler-functions]]
== HandlerFunction == HandlerFunction
...@@ -245,6 +247,7 @@ found. If it is not found, we use `switchIfEmpty(Mono<T>)` to return a 404 Not F ...@@ -245,6 +247,7 @@ found. If it is not found, we use `switchIfEmpty(Mono<T>)` to return a 404 Not F
[[webflux-fn-router-functions]] [[webflux-fn-router-functions]]
== `RouterFunction` == `RouterFunction`
...@@ -320,6 +323,7 @@ RouterFunction<ServerResponse> personRoute = ...@@ -320,6 +323,7 @@ RouterFunction<ServerResponse> personRoute =
[[webflux-fn-running]] [[webflux-fn-running]]
== Running a Server == Running a Server
...@@ -394,6 +398,7 @@ public class WebConfig implements WebFluxConfigurer { ...@@ -394,6 +398,7 @@ public class WebConfig implements WebFluxConfigurer {
[[webflux-fn-handler-filter-function]] [[webflux-fn-handler-filter-function]]
== `HandlerFilterFunction` == `HandlerFilterFunction`
......
...@@ -3,9 +3,10 @@ ...@@ -3,9 +3,10 @@
[.small]#<<web.adoc#mvc-view,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-view,Same as in Spring MVC>>#
The use of view technologies in Spring WebFlux is pluggable. Whether you decide to The use of view technologies in Spring WebFlux is pluggable. Whether you decide to
use Thymeleaf, FreeMarker, or some other view technology is primarily a matter of a configuration change. use Thymeleaf, FreeMarker, or some other view technology is primarily a matter of a
This chapter covers the view technologies integrated with Spring WebFlux. We assume you are configuration change. This chapter covers the view technologies integrated with Spring
already familiar with <<webflux-viewresolution>>. WebFlux. We assume you are already familiar with <<webflux-viewresolution>>.
...@@ -29,6 +30,7 @@ http://forum.thymeleaf.org/Thymeleaf-3-0-8-JUST-PUBLISHED-td4030687.html[announc ...@@ -29,6 +30,7 @@ http://forum.thymeleaf.org/Thymeleaf-3-0-8-JUST-PUBLISHED-td4030687.html[announc
[[webflux-view-freemarker]] [[webflux-view-freemarker]]
== FreeMarker == FreeMarker
[.small]#<<web.adoc#mvc-view-freemarker,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-view-freemarker,Same as in Spring MVC>>#
...@@ -116,6 +118,7 @@ the `Configuration` object. ...@@ -116,6 +118,7 @@ the `Configuration` object.
[[webflux-view-script]] [[webflux-view-script]]
== Script Views == Script Views
[.small]#<<web.adoc#mvc-view-script,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-view-script,Same as in Spring MVC>>#
...@@ -280,6 +283,7 @@ for more configuration examples. ...@@ -280,6 +283,7 @@ for more configuration examples.
[[webflux-view-httpmessagewriter]] [[webflux-view-httpmessagewriter]]
== JSON and XML == JSON and XML
[.small]#<<web.adoc#mvc-view-jackson,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-view-jackson,Same as in Spring MVC>>#
......
...@@ -14,6 +14,7 @@ and others can be plugged in through a `ClientHttpConnector`. ...@@ -14,6 +14,7 @@ and others can be plugged in through a `ClientHttpConnector`.
[[webflux-client-builder]] [[webflux-client-builder]]
== Configuration == Configuration
...@@ -241,6 +242,7 @@ shows: ...@@ -241,6 +242,7 @@ shows:
[[webflux-client-retrieve]] [[webflux-client-retrieve]]
== `retrieve()` == `retrieve()`
...@@ -294,6 +296,7 @@ as the following example shows: ...@@ -294,6 +296,7 @@ as the following example shows:
[[webflux-client-exchange]] [[webflux-client-exchange]]
== `exchange()` == `exchange()`
...@@ -335,6 +338,7 @@ is closed and is not placed back in the pool. ...@@ -335,6 +338,7 @@ is closed and is not placed back in the pool.
[[webflux-client-body]] [[webflux-client-body]]
== Request Body == Request Body
...@@ -497,6 +501,7 @@ inline-style, through the built-in `BodyInserters`, as the following example sho ...@@ -497,6 +501,7 @@ inline-style, through the built-in `BodyInserters`, as the following example sho
[[webflux-client-filter]] [[webflux-client-filter]]
== Client Filters == Client Filters
...@@ -581,6 +586,7 @@ WebClient client = webClient.mutate() ...@@ -581,6 +586,7 @@ WebClient client = webClient.mutate()
[[webflux-client-testing]] [[webflux-client-testing]]
== Testing == Testing
......
...@@ -5,12 +5,11 @@ ...@@ -5,12 +5,11 @@
This part of the reference documentation covers support for reactive-stack WebSocket This part of the reference documentation covers support for reactive-stack WebSocket
messaging. messaging.
include::websocket-intro.adoc[leveloffset=+1] include::websocket-intro.adoc[leveloffset=+1]
[[webflux-websocket-server]] [[webflux-websocket-server]]
== WebSocket API == WebSocket API
[.small]#<<web.adoc#websocket-server,Same as in the Servlet stack>># [.small]#<<web.adoc#websocket-server,Same as in the Servlet stack>>#
......
...@@ -17,6 +17,7 @@ for example, Spring MVC controllers with the reactive `WebClient`. ...@@ -17,6 +17,7 @@ for example, Spring MVC controllers with the reactive `WebClient`.
[[webflux-new-framework]] [[webflux-new-framework]]
== Overview == Overview
...@@ -291,6 +292,7 @@ libraries, see their respective documentation. ...@@ -291,6 +292,7 @@ libraries, see their respective documentation.
[[webflux-reactive-spring-web]] [[webflux-reactive-spring-web]]
== Reactive Core == Reactive Core
...@@ -452,7 +454,6 @@ access not only to the request and response, but also to request and session att ...@@ -452,7 +454,6 @@ access not only to the request and response, but also to request and session att
access to parsed form data, multipart data, and more. access to parsed form data, multipart data, and more.
[[webflux-web-handler-api-special-beans]] [[webflux-web-handler-api-special-beans]]
==== Special bean types ==== Special bean types
...@@ -505,7 +506,6 @@ The table below lists the components that `WebHttpHandlerBuilder` detects: ...@@ -505,7 +506,6 @@ The table below lists the components that `WebHttpHandlerBuilder` detects:
|=== |===
[[webflux-form-data]] [[webflux-form-data]]
==== Form Data ==== Form Data
...@@ -525,7 +525,6 @@ The `DefaultServerWebExchange` uses the configured `HttpMessageReader` to parse ...@@ -525,7 +525,6 @@ The `DefaultServerWebExchange` uses the configured `HttpMessageReader` to parse
(see the <<webflux-web-handler-api,Web Handler API>>). (see the <<webflux-web-handler-api,Web Handler API>>).
[[webflux-multipart]] [[webflux-multipart]]
==== Multipart Data ==== Multipart Data
[.small]#<<web.adoc#mvc-multipart,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-multipart,Same as in Spring MVC>>#
...@@ -555,7 +554,6 @@ parsing multipart data in full. By contrast, you can use `@RequestBody` to decod ...@@ -555,7 +554,6 @@ parsing multipart data in full. By contrast, you can use `@RequestBody` to decod
content to `Flux<Part>` without collecting to a `MultiValueMap`. content to `Flux<Part>` without collecting to a `MultiValueMap`.
[[webflux-forwarded-headers]] [[webflux-forwarded-headers]]
==== Forwarded Headers ==== Forwarded Headers
[.small]#<<web.adoc#filters-forwarded-headers,Same as in Spring MVC>># [.small]#<<web.adoc#filters-forwarded-headers,Same as in Spring MVC>>#
...@@ -598,7 +596,6 @@ as declaring it as a Spring bean and (optionally) expressing precedence by using ...@@ -598,7 +596,6 @@ as declaring it as a Spring bean and (optionally) expressing precedence by using
the bean declaration or by implementing `Ordered`. the bean declaration or by implementing `Ordered`.
[[webflux-filters-cors]] [[webflux-filters-cors]]
==== CORS ==== CORS
[.small]#<<web.adoc#filters-cors,Same as in Spring MVC>># [.small]#<<web.adoc#filters-cors,Same as in Spring MVC>>#
...@@ -669,7 +666,6 @@ JSON, Jackson Smile, JAXB2, Protocol Buffers, and other web-specific HTTP messag ...@@ -669,7 +666,6 @@ JSON, Jackson Smile, JAXB2, Protocol Buffers, and other web-specific HTTP messag
readers and writers for form data, multipart requests, and server-sent events. readers and writers for form data, multipart requests, and server-sent events.
[[webflux-codecs-jackson]] [[webflux-codecs-jackson]]
==== Jackson JSON ==== Jackson JSON
...@@ -702,7 +698,6 @@ or a sequence of strings represent serialized JSON content, to be rendered by th ...@@ -702,7 +698,6 @@ or a sequence of strings represent serialized JSON content, to be rendered by th
use `Flux#collectToList()` and provide a `Mono<List<String>>` to be serialized. use `Flux#collectToList()` and provide a `Mono<List<String>>` to be serialized.
[[webflux-codecs-forms]] [[webflux-codecs-forms]]
==== Form Data ==== Form Data
...@@ -719,7 +714,6 @@ request body. For this reason, applications are expected to go through `ServerWe ...@@ -719,7 +714,6 @@ request body. For this reason, applications are expected to go through `ServerWe
consistently for access to the cached form data versus reading from the raw request body. consistently for access to the cached form data versus reading from the raw request body.
[[webflux-codecs-multipart]] [[webflux-codecs-multipart]]
==== Multipart Data ==== Multipart Data
...@@ -741,7 +735,6 @@ for repeated, map-like access to parts, or otherwise rely on the ...@@ -741,7 +735,6 @@ for repeated, map-like access to parts, or otherwise rely on the
`SynchronossPartHttpMessageReader` for a one-time access to `Flux<Part>`. `SynchronossPartHttpMessageReader` for a one-time access to `Flux<Part>`.
[[webflux-codecs-streaming]] [[webflux-codecs-streaming]]
==== Streaming ==== Streaming
[.small]#<<web.adoc#mvc-ann-async-http-streaming,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-async-http-streaming,Same as in Spring MVC>>#
...@@ -786,7 +779,6 @@ while a fully formatted prefix based on that ID is available from ...@@ -786,7 +779,6 @@ while a fully formatted prefix based on that ID is available from
,while a fully formatted prefix is available from `ClientRequest#logPrefix()`. ,while a fully formatted prefix is available from `ClientRequest#logPrefix()`.
[[webflux-logging-sensitive-data]] [[webflux-logging-sensitive-data]]
==== Logging Sensitive Data ==== Logging Sensitive Data
[.small]#<<web.adoc#mvc-logging-sensitive-data,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-logging-sensitive-data,Same as in Spring MVC>>#
...@@ -829,6 +821,7 @@ WebClient webClient = WebClient.builder() ...@@ -829,6 +821,7 @@ WebClient webClient = WebClient.builder()
[[webflux-dispatcher-handler]] [[webflux-dispatcher-handler]]
== `DispatcherHandler` == `DispatcherHandler`
[.small]#<<web.adoc#mvc-servlet,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-servlet,Same as in Spring MVC>>#
...@@ -1012,7 +1005,6 @@ supported through a dedicated <<webflux-resulthandling,HandlerResultHandler>> th ...@@ -1012,7 +1005,6 @@ supported through a dedicated <<webflux-resulthandling,HandlerResultHandler>> th
instance. The `View` is then used to render the response. instance. The `View` is then used to render the response.
[[webflux-viewresolution-handling]] [[webflux-viewresolution-handling]]
==== Handling ==== Handling
[.small]#<<web.adoc#mvc-handling,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-handling,Same as in Spring MVC>>#
...@@ -1049,7 +1041,6 @@ dedicated configuration API for view resolution. ...@@ -1049,7 +1041,6 @@ dedicated configuration API for view resolution.
See <<webflux-view>> for more on the view technologies integrated with Spring WebFlux. See <<webflux-view>> for more on the view technologies integrated with Spring WebFlux.
[[webflux-redirecting-redirect-prefix]] [[webflux-redirecting-redirect-prefix]]
==== Redirecting ==== Redirecting
[.small]#<<web.adoc#mvc-redirecting-redirect-prefix,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-redirecting-redirect-prefix,Same as in Spring MVC>>#
...@@ -1081,6 +1072,7 @@ always selected and used if they match the requested media type. ...@@ -1081,6 +1072,7 @@ always selected and used if they match the requested media type.
[[webflux-controller]] [[webflux-controller]]
== Annotated Controllers == Annotated Controllers
[.small]#<<web.adoc#mvc-controller,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-controller,Same as in Spring MVC>>#
...@@ -1192,7 +1184,6 @@ The following example uses type and method level mappings: ...@@ -1192,7 +1184,6 @@ The following example uses type and method level mappings:
==== ====
[[webflux-ann-requestmapping-uri-templates]] [[webflux-ann-requestmapping-uri-templates]]
==== URI Patterns ==== URI Patterns
[.small]#<<web.adoc#mvc-ann-requestmapping-uri-templates,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-requestmapping-uri-templates,Same as in Spring MVC>>#
...@@ -1295,7 +1286,6 @@ Catch-all patterns (for example, `**`, `{*varName}`) are excluded from the scori ...@@ -1295,7 +1286,6 @@ Catch-all patterns (for example, `**`, `{*varName}`) are excluded from the scori
sorted last instead. If two patterns are both catch-all, the longer is chosen. sorted last instead. If two patterns are both catch-all, the longer is chosen.
[[webflux-ann-requestmapping-consumes]] [[webflux-ann-requestmapping-consumes]]
==== Consumable Media Types ==== Consumable Media Types
[.small]#<<web.adoc#mvc-ann-requestmapping-consumes,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-requestmapping-consumes,Same as in Spring MVC>>#
...@@ -1325,7 +1315,6 @@ TIP: `MediaType` provides constants for commonly used media types -- for example ...@@ -1325,7 +1315,6 @@ TIP: `MediaType` provides constants for commonly used media types -- for example
`APPLICATION_JSON_VALUE` and `APPLICATION_XML_VALUE`. `APPLICATION_JSON_VALUE` and `APPLICATION_XML_VALUE`.
[[webflux-ann-requestmapping-produces]] [[webflux-ann-requestmapping-produces]]
==== Producible Media Types ==== Producible Media Types
[.small]#<<web.adoc#mvc-ann-requestmapping-produces,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-requestmapping-produces,Same as in Spring MVC>>#
...@@ -1361,7 +1350,6 @@ TIP: `MediaType` provides constants for commonly used media types -- e.g. ...@@ -1361,7 +1350,6 @@ TIP: `MediaType` provides constants for commonly used media types -- e.g.
`APPLICATION_JSON_UTF8_VALUE`, `APPLICATION_XML_VALUE`. `APPLICATION_JSON_UTF8_VALUE`, `APPLICATION_XML_VALUE`.
[[webflux-ann-requestmapping-params-and-headers]] [[webflux-ann-requestmapping-params-and-headers]]
==== Parameters and Headers ==== Parameters and Headers
[.small]#<<web.adoc#mvc-ann-requestmapping-params-and-headers,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-requestmapping-params-and-headers,Same as in Spring MVC>>#
...@@ -1397,7 +1385,6 @@ You can also use the same with request header conditions, as the follwing exampl ...@@ -1397,7 +1385,6 @@ You can also use the same with request header conditions, as the follwing exampl
==== ====
[[webflux-ann-requestmapping-head-options]] [[webflux-ann-requestmapping-head-options]]
==== HTTP HEAD, OPTIONS ==== HTTP HEAD, OPTIONS
[.small]#<<web.adoc#mvc-ann-requestmapping-head-options,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-requestmapping-head-options,Same as in Spring MVC>>#
...@@ -1419,7 +1406,6 @@ You can explicitly map a `@RequestMapping` method to HTTP HEAD and HTTP OPTIONS, ...@@ -1419,7 +1406,6 @@ You can explicitly map a `@RequestMapping` method to HTTP HEAD and HTTP OPTIONS,
is not necessary in the common case. is not necessary in the common case.
[[webflux-ann-requestmapping-composed]] [[webflux-ann-requestmapping-composed]]
==== Custom Annotations ==== Custom Annotations
[.small]#<<web.adoc#mvc-ann-requestmapping-composed,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-requestmapping-composed,Same as in Spring MVC>>#
...@@ -1441,7 +1427,6 @@ logic. This is a more advanced option that requires sub-classing ...@@ -1441,7 +1427,6 @@ logic. This is a more advanced option that requires sub-classing
you can check the custom attribute and return your own `RequestCondition`. you can check the custom attribute and return your own `RequestCondition`.
[[webflux-ann-requestmapping-registration]] [[webflux-ann-requestmapping-registration]]
==== Explicit Registrations ==== Explicit Registrations
[.small]#<<web.adoc#mvc-ann-requestmapping-registration,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-requestmapping-registration,Same as in Spring MVC>>#
...@@ -1487,7 +1472,6 @@ public class MyConfig { ...@@ -1487,7 +1472,6 @@ public class MyConfig {
supported controller method arguments and return values. supported controller method arguments and return values.
[[webflux-ann-arguments]] [[webflux-ann-arguments]]
==== Method Arguments ==== Method Arguments
[.small]#<<web.adoc#mvc-ann-arguments,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-arguments,Same as in Spring MVC>>#
...@@ -1697,7 +1681,6 @@ can be customized through a `WebDataBinder` (see <<mvc-ann-initbinder>>) or by r ...@@ -1697,7 +1681,6 @@ can be customized through a `WebDataBinder` (see <<mvc-ann-initbinder>>) or by r
<<core.adoc#format, Spring Field Formatting>>). <<core.adoc#format, Spring Field Formatting>>).
[[webflux-ann-matrix-variables]] [[webflux-ann-matrix-variables]]
==== Matrix Variables ==== Matrix Variables
[.small]#<<web.adoc#mvc-ann-matrix-variables,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-matrix-variables,Same as in Spring MVC>>#
...@@ -1791,7 +1774,6 @@ To get all matrix variables, use a `MultiValueMap`, as the following example sho ...@@ -1791,7 +1774,6 @@ To get all matrix variables, use a `MultiValueMap`, as the following example sho
==== ====
[[webflux-ann-requestparam]] [[webflux-ann-requestparam]]
==== `@RequestParam` ==== `@RequestParam`
[.small]#<<web.adoc#mvc-ann-requestparam,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-requestparam,Same as in Spring MVC>>#
...@@ -1847,7 +1829,6 @@ and is not resolved by any other argument resolver is treated as if it were anno ...@@ -1847,7 +1829,6 @@ and is not resolved by any other argument resolver is treated as if it were anno
with `@RequestParam`. with `@RequestParam`.
[[webflux-ann-requestheader]] [[webflux-ann-requestheader]]
==== `@RequestHeader` ==== `@RequestHeader`
[.small]#<<web.adoc#mvc-ann-requestheader,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-requestheader,Same as in Spring MVC>>#
...@@ -1900,7 +1881,6 @@ example, a method parameter annotated with `@RequestHeader("Accept")` may be of ...@@ -1900,7 +1881,6 @@ example, a method parameter annotated with `@RequestHeader("Accept")` may be of
`String` but also of `String[]` or `List<String>`. `String` but also of `String[]` or `List<String>`.
[[webflux-ann-cookievalue]] [[webflux-ann-cookievalue]]
==== `@CookieValue` ==== `@CookieValue`
[.small]#<<web.adoc#mvc-ann-cookievalue,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-cookievalue,Same as in Spring MVC>>#
...@@ -1936,7 +1916,6 @@ Type conversion is applied automatically if the target method parameter type is ...@@ -1936,7 +1916,6 @@ Type conversion is applied automatically if the target method parameter type is
`String`. See <<mvc-ann-typeconversion>>. `String`. See <<mvc-ann-typeconversion>>.
[[webflux-ann-modelattrib-method-args]] [[webflux-ann-modelattrib-method-args]]
==== `@ModelAttribute` ==== `@ModelAttribute`
[.small]#<<web.adoc#mvc-ann-modelattrib-method-args,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-modelattrib-method-args,Same as in Spring MVC>>#
...@@ -2044,7 +2023,6 @@ and is not resolved by any other argument resolver is treated as if it were anno ...@@ -2044,7 +2023,6 @@ and is not resolved by any other argument resolver is treated as if it were anno
with `@ModelAttribute`. with `@ModelAttribute`.
[[webflux-ann-sessionattributes]] [[webflux-ann-sessionattributes]]
==== `@SessionAttributes` ==== `@SessionAttributes`
[.small]#<<web.adoc#mvc-ann-sessionattributes,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-sessionattributes,Same as in Spring MVC>>#
...@@ -2101,7 +2079,6 @@ as the following example shows: ...@@ -2101,7 +2079,6 @@ as the following example shows:
==== ====
[[webflux-ann-sessionattribute]] [[webflux-ann-sessionattribute]]
==== `@SessionAttribute` ==== `@SessionAttribute`
[.small]#<<web.adoc#mvc-ann-sessionattribute,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-sessionattribute,Same as in Spring MVC>>#
...@@ -2151,7 +2128,6 @@ as the following example shows: ...@@ -2151,7 +2128,6 @@ as the following example shows:
==== ====
[[webflux-multipart-forms]] [[webflux-multipart-forms]]
==== Multipart Content ==== Multipart Content
[.small]#<<web.adoc#mvc-multipart-forms,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-multipart-forms,Same as in Spring MVC>>#
...@@ -2295,7 +2271,6 @@ To access multipart data sequentially, in streaming fashion, you can use `@Reque ...@@ -2295,7 +2271,6 @@ To access multipart data sequentially, in streaming fashion, you can use `@Reque
==== ====
[[webflux-ann-requestbody]] [[webflux-ann-requestbody]]
==== `@RequestBody` ==== `@RequestBody`
[.small]#<<web.adoc#mvc-ann-requestbody,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-requestbody,Same as in Spring MVC>>#
...@@ -2352,7 +2327,6 @@ example uses a `BindingResult` argument`: ...@@ -2352,7 +2327,6 @@ example uses a `BindingResult` argument`:
==== ====
[[webflux-ann-httpentity]] [[webflux-ann-httpentity]]
==== `HttpEntity` ==== `HttpEntity`
[.small]#<<web.adoc#mvc-ann-httpentity,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-httpentity,Same as in Spring MVC>>#
...@@ -2373,7 +2347,6 @@ container object that exposes request headers and the body. The following exampl ...@@ -2373,7 +2347,6 @@ container object that exposes request headers and the body. The following exampl
==== ====
[[webflux-ann-responsebody]] [[webflux-ann-responsebody]]
==== `@ResponseBody` ==== `@ResponseBody`
[.small]#<<web.adoc#mvc-ann-responsebody,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-responsebody,Same as in Spring MVC>>#
...@@ -2409,7 +2382,6 @@ You can use the <<webflux-config-message-codecs>> option of the <<webflux-config ...@@ -2409,7 +2382,6 @@ You can use the <<webflux-config-message-codecs>> option of the <<webflux-config
configure or customize message writing. configure or customize message writing.
[[webflux-ann-responseentity]] [[webflux-ann-responseentity]]
==== `ResponseEntity` ==== `ResponseEntity`
[.small]#<<web.adoc#mvc-ann-responseentity,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-responseentity,Same as in Spring MVC>>#
...@@ -2434,8 +2406,6 @@ produce the `ResponseEntity` asynchronously, and/or single and multi-value react ...@@ -2434,8 +2406,6 @@ produce the `ResponseEntity` asynchronously, and/or single and multi-value react
for the body. for the body.
[[webflux-ann-jackson]] [[webflux-ann-jackson]]
==== Jackson JSON ==== Jackson JSON
...@@ -2549,9 +2519,8 @@ The following example adds one attribute only: ...@@ -2549,9 +2519,8 @@ The following example adds one attribute only:
---- ----
==== ====
NOTE: When a name is not explicitly specified, a default name is chosen based on the `Object` NOTE: When a name is not explicitly specified, a default name is chosen based on the type,
type, as explained in the Javadoc for as explained in the javadoc for {api-spring-framework}/core/Conventions.html[`Conventions`].
{api-spring-framework}/core/Conventions.html[`Conventions`].
You can always assign an explicit name by using the overloaded `addAttribute` method or You can always assign an explicit name by using the overloaded `addAttribute` method or
through the name attribute on `@ModelAttribute` (for a return value). through the name attribute on `@ModelAttribute` (for a return value).
...@@ -2714,7 +2683,6 @@ Support for `@ExceptionHandler` methods in Spring WebFlux is provided by the ...@@ -2714,7 +2683,6 @@ Support for `@ExceptionHandler` methods in Spring WebFlux is provided by the
for more detail. for more detail.
[[webflux-ann-rest-exceptions]] [[webflux-ann-rest-exceptions]]
==== REST API exceptions ==== REST API exceptions
[.small]#<<web.adoc#mvc-ann-rest-exceptions,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-ann-rest-exceptions,Same as in Spring MVC>>#
...@@ -2779,30 +2747,26 @@ as the following example shows: ...@@ -2779,30 +2747,26 @@ as the following example shows:
The preceding selectors are evaluated at runtime and may negatively impact The preceding selectors are evaluated at runtime and may negatively impact
performance if you use them extensively. See the performance if you use them extensively. See the
{api-spring-framework}/web/bind/annotation/ControllerAdvice.html[`@ControllerAdvice`] {api-spring-framework}/web/bind/annotation/ControllerAdvice.html[`@ControllerAdvice`]
Javadoc for more details. javadoc for more details.
include::webflux-functional.adoc[leveloffset=+1] include::webflux-functional.adoc[leveloffset=+1]
[[webflux-uri-building]] [[webflux-uri-building]]
== URI Links == URI Links
[.small]#<<web.adoc#mvc-uri-building,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-uri-building,Same as in Spring MVC>>#
This section describes various options available in the Spring Framework to prepare URIs. This section describes various options available in the Spring Framework to prepare URIs.
include::web-uris.adoc[leveloffset=+2] include::web-uris.adoc[leveloffset=+2]
include::webflux-cors.adoc[leveloffset=+1] include::webflux-cors.adoc[leveloffset=+1]
[[webflux-web-security]] [[webflux-web-security]]
== Web Security == Web Security
[.small]#<<web.adoc#mvc-web-security,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-web-security,Same as in Spring MVC>>#
...@@ -2816,12 +2780,11 @@ reference documentation, including: ...@@ -2816,12 +2780,11 @@ reference documentation, including:
* {doc-spring-security}/html5/#csrf[CSRF Protection] * {doc-spring-security}/html5/#csrf[CSRF Protection]
* {doc-spring-security}/html5/#headers[Security Response Headers] * {doc-spring-security}/html5/#headers[Security Response Headers]
include::webflux-view.adoc[leveloffset=+1] include::webflux-view.adoc[leveloffset=+1]
[[webflux-caching]] [[webflux-caching]]
== HTTP Caching == HTTP Caching
[.small]#<<web.adoc#mvc-caching,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-caching,Same as in Spring MVC>>#
...@@ -2946,6 +2909,7 @@ for optimal performance. See the section on configuring <<webflux-config-static- ...@@ -2946,6 +2909,7 @@ for optimal performance. See the section on configuring <<webflux-config-static-
[[webflux-config]] [[webflux-config]]
== WebFlux Config == WebFlux Config
[.small]#<<web.adoc#mvc-config,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-config,Same as in Spring MVC>>#
...@@ -3358,7 +3322,7 @@ match to incoming URLs without versions (for example, `/jquery/jquery.min.js` to ...@@ -3358,7 +3322,7 @@ match to incoming URLs without versions (for example, `/jquery/jquery.min.js` to
[.small]#<<web.adoc#mvc-config-path-matching,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-config-path-matching,Same as in Spring MVC>>#
You can customize options related to path matching. For details on the individual options, see the You can customize options related to path matching. For details on the individual options, see the
{api-spring-framework}/web/reactive/config/PathMatchConfigurer.html[`PathMatchConfigurer`] Javadoc. {api-spring-framework}/web/reactive/config/PathMatchConfigurer.html[`PathMatchConfigurer`] javadoc.
The following example shows how to use `PathMatchConfigurer`: The following example shows how to use `PathMatchConfigurer`:
==== ====
...@@ -3430,6 +3394,7 @@ the classpath. ...@@ -3430,6 +3394,7 @@ the classpath.
[[webflux-http2]] [[webflux-http2]]
== HTTP/2 == HTTP/2
[.small]#<<web.adoc#mvc-http2,Same as in Spring MVC>># [.small]#<<web.adoc#mvc-http2,Same as in Spring MVC>>#
......
...@@ -5,6 +5,7 @@ This section describes options for client-side access to REST endpoints. ...@@ -5,6 +5,7 @@ This section describes options for client-side access to REST endpoints.
[[webmvc-resttemplate]] [[webmvc-resttemplate]]
== `RestTemplate` == `RestTemplate`
...@@ -21,6 +22,7 @@ See <<integration.adoc#rest-client-access,REST Endpoints>> for details. ...@@ -21,6 +22,7 @@ See <<integration.adoc#rest-client-access,REST Endpoints>> for details.
[[webmvc-webclient]] [[webmvc-webclient]]
== `WebClient` == `WebClient`
......
...@@ -7,6 +7,7 @@ describes how to do so. ...@@ -7,6 +7,7 @@ describes how to do so.
[[mvc-cors-intro]] [[mvc-cors-intro]]
== Introduction == Introduction
[.small]#<<web-reactive.adoc#webflux-cors-intro,Same as in Spring WebFlux>># [.small]#<<web-reactive.adoc#webflux-cors-intro,Same as in Spring WebFlux>>#
...@@ -23,6 +24,7 @@ powerful workarounds based on IFRAME or JSONP. ...@@ -23,6 +24,7 @@ powerful workarounds based on IFRAME or JSONP.
[[mvc-cors-processing]] [[mvc-cors-processing]]
== Processing == Processing
[.small]#<<web-reactive.adoc#webflux-cors-processing,Same as in Spring WebFlux>># [.small]#<<web-reactive.adoc#webflux-cors-processing,Same as in Spring WebFlux>>#
...@@ -72,6 +74,7 @@ To learn more from the source or make advanced customizations, check the code be ...@@ -72,6 +74,7 @@ To learn more from the source or make advanced customizations, check the code be
[[mvc-cors-controller]] [[mvc-cors-controller]]
== `@CrossOrigin` == `@CrossOrigin`
[.small]#<<web-reactive.adoc#webflux-cors-controller,Same as in Spring WebFlux>># [.small]#<<web-reactive.adoc#webflux-cors-controller,Same as in Spring WebFlux>>#
...@@ -167,6 +170,7 @@ public class AccountController { ...@@ -167,6 +170,7 @@ public class AccountController {
[[mvc-cors-global]] [[mvc-cors-global]]
== Global Configuration == Global Configuration
[.small]#<<web-reactive.adoc#webflux-cors-global,Same as in Spring WebFlux>># [.small]#<<web-reactive.adoc#webflux-cors-global,Same as in Spring WebFlux>>#
...@@ -191,7 +195,6 @@ should only be used where appropriate. ...@@ -191,7 +195,6 @@ should only be used where appropriate.
[[mvc-cors-global-java]] [[mvc-cors-global-java]]
=== Java Configuration === Java Configuration
[.small]#<<web-reactive.adoc#webflux-cors-global,Same as in Spring WebFlux>># [.small]#<<web-reactive.adoc#webflux-cors-global,Same as in Spring WebFlux>>#
...@@ -253,6 +256,7 @@ as the following example shows: ...@@ -253,6 +256,7 @@ as the following example shows:
[[mvc-cors-filter]] [[mvc-cors-filter]]
== CORS Filter == CORS Filter
[.small]#<<web-reactive.adoc#webflux-cors-webfilter,Same as in Spring WebFlux>># [.small]#<<web-reactive.adoc#webflux-cors-webfilter,Same as in Spring WebFlux>>#
......
此差异已折叠。
...@@ -57,6 +57,7 @@ instructions of the cloud provider related to WebSocket support. ...@@ -57,6 +57,7 @@ instructions of the cloud provider related to WebSocket support.
[[websocket-intro-architecture]] [[websocket-intro-architecture]]
== HTTP Versus WebSocket == HTTP Versus WebSocket
...@@ -82,6 +83,7 @@ In the absence of that, they need to come up with their own conventions. ...@@ -82,6 +83,7 @@ In the absence of that, they need to come up with their own conventions.
[[websocket-intro-when-to-use]] [[websocket-intro-when-to-use]]
== When to Use WebSockets == When to Use WebSockets
......
...@@ -7,12 +7,11 @@ This part of the reference documentation covers support for Servlet stack, WebSo ...@@ -7,12 +7,11 @@ This part of the reference documentation covers support for Servlet stack, WebSo
messaging that includes raw WebSocket interactions, WebSocket emulation through SockJS, and messaging that includes raw WebSocket interactions, WebSocket emulation through SockJS, and
publish-subscribe messaging through STOMP as a sub-protocol over WebSocket. publish-subscribe messaging through STOMP as a sub-protocol over WebSocket.
include::websocket-intro.adoc[leveloffset=+1] include::websocket-intro.adoc[leveloffset=+1]
[[websocket-server]] [[websocket-server]]
== WebSocket API == WebSocket API
[.small]#<<web-reactive.adoc#webflux-websocket-server,Same as in Spring WebFlux>># [.small]#<<web-reactive.adoc#webflux-websocket-server,Same as in Spring WebFlux>>#
...@@ -478,6 +477,7 @@ The following example shows the XML configuration equivalent of the preceding ex ...@@ -478,6 +477,7 @@ The following example shows the XML configuration equivalent of the preceding ex
[[websocket-fallback]] [[websocket-fallback]]
== SockJS Fallback == SockJS Fallback
...@@ -846,7 +846,8 @@ jettyHttpClient.setExecutor(new QueuedThreadPool(1000)); ...@@ -846,7 +846,8 @@ jettyHttpClient.setExecutor(new QueuedThreadPool(1000));
---- ----
==== ====
The following example shows the server-side SockJS-related properties (see Javadoc for details) that you should also consider customizing: The following example shows the server-side SockJS-related properties (see javadoc for details)
that you should also consider customizing:
==== ====
[source,java,indent=0] [source,java,indent=0]
...@@ -874,6 +875,7 @@ The following example shows the server-side SockJS-related properties (see Javad ...@@ -874,6 +875,7 @@ The following example shows the server-side SockJS-related properties (see Javad
[[websocket-stomp]] [[websocket-stomp]]
== STOMP == STOMP
...@@ -1263,7 +1265,6 @@ methods, as described in the following topics: ...@@ -1263,7 +1265,6 @@ methods, as described in the following topics:
* <<websocket-stomp-exception-handler>> * <<websocket-stomp-exception-handler>>
[[websocket-stomp-message-mapping]] [[websocket-stomp-message-mapping]]
==== `@MessageMapping` ==== `@MessageMapping`
...@@ -1526,15 +1527,16 @@ public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { ...@@ -1526,15 +1527,16 @@ public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
=== External Broker === External Broker
The simple broker is great for getting started but supports only a subset of The simple broker is great for getting started but supports only a subset of
STOMP commands (it does not support acks, receipts, and some other features), relies on a simple STOMP commands (it does not support acks, receipts, and some other features),
message-sending loop, and is not suitable for clustering. As an alternative, you can upgrade your applications relies on a simple message-sending loop, and is not suitable for clustering.
to use a full-featured message broker. As an alternative, you can upgrade your applications to use a full-featured
message broker.
See the STOMP documentation for your message broker of choice (such as See the STOMP documentation for your message broker of choice (such as
http://www.rabbitmq.com/stomp.html[RabbitMQ], http://www.rabbitmq.com/stomp.html[RabbitMQ],
http://activemq.apache.org/stomp.html[ActiveMQ], and others), install the broker, http://activemq.apache.org/stomp.html[ActiveMQ], and others), install the broker,
and run it with STOMP support enabled. Then you can enable the STOMP broker relay (instead of the simple broker) in the and run it with STOMP support enabled. Then you can enable the STOMP broker relay
Spring configuration. (instead of the simple broker) in the Spring configuration.
The following example configuration enables a full-featured broker: The following example configuration enables a full-featured broker:
...@@ -1600,8 +1602,7 @@ dependencies to your project for TCP connection management. ...@@ -1600,8 +1602,7 @@ dependencies to your project for TCP connection management.
Furthermore, application components (such as HTTP request handling methods, Furthermore, application components (such as HTTP request handling methods,
business services, and others) can also send messages to the broker relay, as described business services, and others) can also send messages to the broker relay, as described
in <<websocket-stomp-handle-send>>, to broadcast messages to in <<websocket-stomp-handle-send>>, to broadcast messages to subscribed WebSocket clients.
subscribed WebSocket clients.
In effect, the broker relay enables robust and scalable message broadcasting. In effect, the broker relay enables robust and scalable message broadcasting.
...@@ -1612,10 +1613,10 @@ In effect, the broker relay enables robust and scalable message broadcasting. ...@@ -1612,10 +1613,10 @@ In effect, the broker relay enables robust and scalable message broadcasting.
A STOMP broker relay maintains a single "`system`" TCP connection to the broker. A STOMP broker relay maintains a single "`system`" TCP connection to the broker.
This connection is used for messages originating from the server-side application This connection is used for messages originating from the server-side application
only, not for receiving messages. You can configure the STOMP credentials (that is, the STOMP frame `login` and `passcode` headers) only, not for receiving messages. You can configure the STOMP credentials (that is,
for this connection. This the STOMP frame `login` and `passcode` headers) for this connection. This is exposed
is exposed in both the XML namespace and Java configuration as the in both the XML namespace and Java configuration as the `systemLogin` and
`systemLogin` and `systemPasscode` properties with default values of `guest` and `guest`. `systemPasscode` properties with default values of `guest` and `guest`.
The STOMP broker relay also creates a separate TCP connection for every connected The STOMP broker relay also creates a separate TCP connection for every connected
WebSocket client. You can configure the STOMP credentials that are used for all TCP WebSocket client. You can configure the STOMP credentials that are used for all TCP
...@@ -2397,8 +2398,8 @@ In fact, if the capacity is left at its default value of Integer.MAX_VALUE, ...@@ -2397,8 +2398,8 @@ In fact, if the capacity is left at its default value of Integer.MAX_VALUE,
the thread pool never increases beyond the core pool size, since the thread pool never increases beyond the core pool size, since
all additional tasks are queued. all additional tasks are queued.
See the Javadoc of `ThreadPoolExecutor` to learn how these See the javadoc of `ThreadPoolExecutor` to learn how these properties work and
properties work and understand the various queuing strategies. understand the various queuing strategies.
==== ====
On the `clientOutboundChannel` side, it is all about sending messages to WebSocket On the `clientOutboundChannel` side, it is all about sending messages to WebSocket
...@@ -2419,9 +2420,8 @@ messages to a client. ...@@ -2419,9 +2420,8 @@ messages to a client.
The general idea is that, at any given time, only a single thread can be used The general idea is that, at any given time, only a single thread can be used
to send to a client. All additional messages, meanwhile, get buffered, and you to send to a client. All additional messages, meanwhile, get buffered, and you
can use these properties to decide how long sending a message is allowed to can use these properties to decide how long sending a message is allowed to
take and how much data can be buffered in the meantime. See the take and how much data can be buffered in the meantime. See the javadoc and
Javadoc and documentation of the XML schema for this configuration for documentation of the XML schema for important additional details.
important additional details.
The following example shows a possible configuration: The following example shows a possible configuration:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册