Polishing
This commit is contained in:
@@ -23,7 +23,7 @@ Spring's pointcut model enables pointcut reuse independent of advice types. You
|
|||||||
target different advice with the same pointcut.
|
target different advice with the same pointcut.
|
||||||
|
|
||||||
The `org.springframework.aop.Pointcut` interface is the central interface, used to
|
The `org.springframework.aop.Pointcut` interface is the central interface, used to
|
||||||
target advices to particular classes and methods. The complete interface follows:
|
target advice to particular classes and methods. The complete interface follows:
|
||||||
|
|
||||||
[source,java,indent=0,subs="verbatim,quotes"]
|
[source,java,indent=0,subs="verbatim,quotes"]
|
||||||
----
|
----
|
||||||
@@ -843,7 +843,7 @@ created by the implementation of the `getObject()` method in the `ProxyFactoryBe
|
|||||||
method creates an AOP proxy that wraps a target object.
|
method creates an AOP proxy that wraps a target object.
|
||||||
|
|
||||||
One of the most important benefits of using a `ProxyFactoryBean` or another IoC-aware
|
One of the most important benefits of using a `ProxyFactoryBean` or another IoC-aware
|
||||||
class to create AOP proxies is that advices and pointcuts can also be
|
class to create AOP proxies is that advice and pointcuts can also be
|
||||||
managed by IoC. This is a powerful feature, enabling certain approaches that are hard to
|
managed by IoC. This is a powerful feature, enabling certain approaches that are hard to
|
||||||
achieve with other AOP frameworks. For example, an advice may itself reference
|
achieve with other AOP frameworks. For example, an advice may itself reference
|
||||||
application objects (besides the target, which should be available in any AOP
|
application objects (besides the target, which should be available in any AOP
|
||||||
@@ -901,7 +901,7 @@ to be applied. You can find an example of using this feature in <<aop-global-adv
|
|||||||
* singleton: Whether or not the factory should return a single object, no matter how
|
* singleton: Whether or not the factory should return a single object, no matter how
|
||||||
often the `getObject()` method is called. Several `FactoryBean` implementations offer
|
often the `getObject()` method is called. Several `FactoryBean` implementations offer
|
||||||
such a method. The default value is `true`. If you want to use stateful advice - for
|
such a method. The default value is `true`. If you want to use stateful advice - for
|
||||||
example, for stateful mixins - use prototype advices along with a singleton value of
|
example, for stateful mixins - use prototype advice along with a singleton value of
|
||||||
`false`.
|
`false`.
|
||||||
|
|
||||||
|
|
||||||
@@ -965,7 +965,7 @@ Consider a simple example of `ProxyFactoryBean` in action. This example involves
|
|||||||
the example.
|
the example.
|
||||||
* An `Advisor` and an `Interceptor` used to provide advice.
|
* An `Advisor` and an `Interceptor` used to provide advice.
|
||||||
* An AOP proxy bean definition to specify the target object (the `personTarget` bean),
|
* An AOP proxy bean definition to specify the target object (the `personTarget` bean),
|
||||||
the interfaces to proxy, and the advices to apply.
|
the interfaces to proxy, and the advice to apply.
|
||||||
|
|
||||||
The following listing shows the example:
|
The following listing shows the example:
|
||||||
|
|
||||||
@@ -1239,7 +1239,7 @@ The first step is to construct an object of type
|
|||||||
object, as in the preceding example, or specify the interfaces to be proxied in an alternate
|
object, as in the preceding example, or specify the interfaces to be proxied in an alternate
|
||||||
constructor.
|
constructor.
|
||||||
|
|
||||||
You can add advices (with interceptors as a specialized kind of advice), advisors, or both
|
You can add advice (with interceptors as a specialized kind of advice), advisors, or both
|
||||||
and manipulate them for the life of the `ProxyFactory`. If you add an
|
and manipulate them for the life of the `ProxyFactory`. If you add an
|
||||||
`IntroductionInterceptionAroundAdvisor`, you can cause the proxy to implement additional
|
`IntroductionInterceptionAroundAdvisor`, you can cause the proxy to implement additional
|
||||||
interfaces.
|
interfaces.
|
||||||
@@ -1468,7 +1468,7 @@ Using this mechanism involves:
|
|||||||
|
|
||||||
* Specifying a `DefaultAdvisorAutoProxyCreator` bean definition.
|
* Specifying a `DefaultAdvisorAutoProxyCreator` bean definition.
|
||||||
* Specifying any number of advisors in the same or related contexts. Note that these
|
* Specifying any number of advisors in the same or related contexts. Note that these
|
||||||
must be advisors, not interceptors or other advices. This is necessary,
|
must be advisors, not interceptors or other advice. This is necessary,
|
||||||
because there must be a pointcut to evaluate, to check the eligibility of each advice
|
because there must be a pointcut to evaluate, to check the eligibility of each advice
|
||||||
to candidate bean definitions.
|
to candidate bean definitions.
|
||||||
|
|
||||||
@@ -1731,7 +1731,7 @@ of target source, as the following example shows:
|
|||||||
|
|
||||||
NOTE: `ThreadLocal` instances come with serious issues (potentially resulting in memory leaks) when
|
NOTE: `ThreadLocal` instances come with serious issues (potentially resulting in memory leaks) when
|
||||||
incorrectly using them in multi-threaded and multi-classloader environments. You
|
incorrectly using them in multi-threaded and multi-classloader environments. You
|
||||||
should always consider wrapping a threadlocal in some other class and never directly use
|
should always consider wrapping a `ThreadLocal` in some other class and never directly use
|
||||||
the `ThreadLocal` itself (except in the wrapper class). Also, you should
|
the `ThreadLocal` itself (except in the wrapper class). Also, you should
|
||||||
always remember to correctly set and unset (where the latter simply involves a call to
|
always remember to correctly set and unset (where the latter simply involves a call to
|
||||||
`ThreadLocal.set(null)`) the resource local to the thread. Unsetting should be done in
|
`ThreadLocal.set(null)`) the resource local to the thread. Unsetting should be done in
|
||||||
|
|||||||
@@ -4149,7 +4149,7 @@ The following example specifies a `ReflectiveLoadTimeWeaver`:
|
|||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
If you use XML-based configuration, you can specify the fully qualified classname
|
If you use XML-based configuration, you can specify the fully qualified class name
|
||||||
as the value of the `weaver-class` attribute on the `<context:load-time-weaver/>`
|
as the value of the `weaver-class` attribute on the `<context:load-time-weaver/>`
|
||||||
element. Again, the following example specifies a `ReflectiveLoadTimeWeaver`:
|
element. Again, the following example specifies a `ReflectiveLoadTimeWeaver`:
|
||||||
|
|
||||||
|
|||||||
@@ -1069,7 +1069,7 @@ The following listing shows the `Component` class:
|
|||||||
private String name;
|
private String name;
|
||||||
private List<Component> components = new ArrayList<Component> ();
|
private List<Component> components = new ArrayList<Component> ();
|
||||||
|
|
||||||
// mmm, there is no setter method for the 'components'
|
// there is no setter method for the 'components'
|
||||||
public void addComponent(Component component) {
|
public void addComponent(Component component) {
|
||||||
this.components.add(component);
|
this.components.add(component);
|
||||||
}
|
}
|
||||||
@@ -1099,7 +1099,7 @@ The following listing shows the `Component` class:
|
|||||||
var name: String? = null
|
var name: String? = null
|
||||||
private val components = ArrayList<Component>()
|
private val components = ArrayList<Component>()
|
||||||
|
|
||||||
// mmm, there is no setter method for the 'components'
|
// there is no setter method for the 'components'
|
||||||
fun addComponent(component: Component) {
|
fun addComponent(component: Component) {
|
||||||
this.components.add(component)
|
this.components.add(component)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -605,7 +605,7 @@ creating a namespace), yet they refer to the same bean.
|
|||||||
|
|
||||||
.Java-configuration
|
.Java-configuration
|
||||||
****
|
****
|
||||||
If you use Javaconfiguration, the `@Bean` annotation can be used to provide aliases.
|
If you use Java Configuration, the `@Bean` annotation can be used to provide aliases.
|
||||||
See <<beans-java-bean-annotation>> for details.
|
See <<beans-java-bean-annotation>> for details.
|
||||||
****
|
****
|
||||||
|
|
||||||
@@ -3981,7 +3981,7 @@ dependency type. The following table summarizes the most important `Aware` inter
|
|||||||
| <<aop-aj-ltw>>
|
| <<aop-aj-ltw>>
|
||||||
|
|
||||||
| `MessageSourceAware`
|
| `MessageSourceAware`
|
||||||
| Configured strategy for resolving messages (with support for parametrization and
|
| Configured strategy for resolving messages (with support for parameterization and
|
||||||
internationalization).
|
internationalization).
|
||||||
| <<context-introduction>>
|
| <<context-introduction>>
|
||||||
|
|
||||||
@@ -5020,7 +5020,7 @@ through Java 8's `java.util.Optional`, as the following example shows:
|
|||||||
|
|
||||||
As of Spring Framework 5.0, you can also use a `@Nullable` annotation (of any kind
|
As of Spring Framework 5.0, you can also use a `@Nullable` annotation (of any kind
|
||||||
in any package -- for example, `javax.annotation.Nullable` from JSR-305) or just leverage
|
in any package -- for example, `javax.annotation.Nullable` from JSR-305) or just leverage
|
||||||
Kotlin builtin null-safety support:
|
Kotlin built-in null-safety support:
|
||||||
|
|
||||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
|
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
|
||||||
.Java
|
.Java
|
||||||
@@ -6324,7 +6324,7 @@ the `@RestController` annotation from Spring MVC is composed of `@Controller` an
|
|||||||
In addition, composed annotations can optionally redeclare attributes from
|
In addition, composed annotations can optionally redeclare attributes from
|
||||||
meta-annotations to allow customization. This can be particularly useful when you
|
meta-annotations to allow customization. This can be particularly useful when you
|
||||||
want to only expose a subset of the meta-annotation's attributes. For example, Spring's
|
want to only expose a subset of the meta-annotation's attributes. For example, Spring's
|
||||||
`@SessionScope` annotation hardcodes the scope name to `session` but still allows
|
`@SessionScope` annotation hard codes the scope name to `session` but still allows
|
||||||
customization of the `proxyMode`. The following listing shows the definition of the
|
customization of the `proxyMode`. The following listing shows the definition of the
|
||||||
`SessionScope` annotation:
|
`SessionScope` annotation:
|
||||||
|
|
||||||
|
|||||||
@@ -4188,7 +4188,7 @@ To configure a `DriverManagerDataSource`:
|
|||||||
|
|
||||||
. Obtain a connection with `DriverManagerDataSource` as you typically obtain a JDBC
|
. Obtain a connection with `DriverManagerDataSource` as you typically obtain a JDBC
|
||||||
connection.
|
connection.
|
||||||
. Specify the fully qualified classname of the JDBC driver so that the `DriverManager`
|
. Specify the fully qualified class name of the JDBC driver so that the `DriverManager`
|
||||||
can load the driver class.
|
can load the driver class.
|
||||||
. Provide a URL that varies between JDBC drivers. (See the documentation for your driver
|
. Provide a URL that varies between JDBC drivers. (See the documentation for your driver
|
||||||
for the correct value.)
|
for the correct value.)
|
||||||
@@ -4346,7 +4346,7 @@ javadoc for more details.
|
|||||||
==== Using `DataSourceTransactionManager`
|
==== Using `DataSourceTransactionManager`
|
||||||
|
|
||||||
The `DataSourceTransactionManager` class is a `PlatformTransactionManager`
|
The `DataSourceTransactionManager` class is a `PlatformTransactionManager`
|
||||||
implementation for single JDBC datasources. It binds a JDBC connection from the
|
implementation for single JDBC data sources. It binds a JDBC connection from the
|
||||||
specified data source to the currently executing thread, potentially allowing for one
|
specified data source to the currently executing thread, potentially allowing for one
|
||||||
thread connection per data source.
|
thread connection per data source.
|
||||||
|
|
||||||
@@ -6966,7 +6966,7 @@ Consider the following query:
|
|||||||
SELECT id, name, state FROM table WHERE (name, age) IN (('John', 35), ('Ann', 50))
|
SELECT id, name, state FROM table WHERE (name, age) IN (('John', 35), ('Ann', 50))
|
||||||
----
|
----
|
||||||
|
|
||||||
The preceding query can be parametrized and run as follows:
|
The preceding query can be parameterized and run as follows:
|
||||||
|
|
||||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
|
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
|
||||||
.Java
|
.Java
|
||||||
@@ -7286,7 +7286,7 @@ javadoc for more details.
|
|||||||
==== Using `R2dbcTransactionManager`
|
==== Using `R2dbcTransactionManager`
|
||||||
|
|
||||||
The `R2dbcTransactionManager` class is a `ReactiveTransactionManager` implementation for
|
The `R2dbcTransactionManager` class is a `ReactiveTransactionManager` implementation for
|
||||||
single R2DBC datasources. It binds an R2DBC connection from the specified connection factory
|
single R2DBC data sources. It binds an R2DBC connection from the specified connection factory
|
||||||
to the subscriber `Context`, potentially allowing for one subscriber connection for each
|
to the subscriber `Context`, potentially allowing for one subscriber connection for each
|
||||||
connection factory.
|
connection factory.
|
||||||
|
|
||||||
|
|||||||
@@ -140,9 +140,9 @@ Since caches are essentially key-value stores, each invocation of a cached metho
|
|||||||
needs to be translated into a suitable key for cache access. The caching abstraction
|
needs to be translated into a suitable key for cache access. The caching abstraction
|
||||||
uses a simple `KeyGenerator` based on the following algorithm:
|
uses a simple `KeyGenerator` based on the following algorithm:
|
||||||
|
|
||||||
* If no params are given, return `SimpleKey.EMPTY`.
|
* If no parameters are given, return `SimpleKey.EMPTY`.
|
||||||
* If only one param is given, return that instance.
|
* If only one parameter is given, return that instance.
|
||||||
* If more than one param is given, return a `SimpleKey` that contains all parameters.
|
* If more than one parameter is given, return a `SimpleKey` that contains all parameters.
|
||||||
|
|
||||||
This approach works well for most use-cases, as long as parameters have natural keys
|
This approach works well for most use-cases, as long as parameters have natural keys
|
||||||
and implement valid `hashCode()` and `equals()` methods. If that is not the case,
|
and implement valid `hashCode()` and `equals()` methods. If that is not the case,
|
||||||
|
|||||||
@@ -961,7 +961,7 @@ leads to a number of additional challenges:
|
|||||||
* Testing can become slow, since each test would need to ensure that the database is in
|
* Testing can become slow, since each test would need to ensure that the database is in
|
||||||
the correct state.
|
the correct state.
|
||||||
* Since our database needs to be in a specific state, we cannot run tests in parallel.
|
* Since our database needs to be in a specific state, we cannot run tests in parallel.
|
||||||
* Performing assertions on such items as auto-generated ids, timestamps, and others can
|
* Performing assertions on such items as auto-generated IDs, timestamps, and others can
|
||||||
be difficult.
|
be difficult.
|
||||||
|
|
||||||
These challenges do not mean that we should abandon end-to-end integration testing
|
These challenges do not mean that we should abandon end-to-end integration testing
|
||||||
|
|||||||
@@ -1196,7 +1196,7 @@ response individually, and instead wait for the combined result:
|
|||||||
|
|
||||||
The above is merely one example. There are lots of other patterns and operators for putting
|
The above is merely one example. There are lots of other patterns and operators for putting
|
||||||
together a reactive pipeline that makes many remote calls, potentially some nested,
|
together a reactive pipeline that makes many remote calls, potentially some nested,
|
||||||
inter-dependent, without ever blocking until the end.
|
interdependent, without ever blocking until the end.
|
||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
====
|
====
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ as the value for the `fieldType` parameter.
|
|||||||
|
|
||||||
The parameters to any of the above macros have consistent meanings:
|
The parameters to any of the above macros have consistent meanings:
|
||||||
|
|
||||||
* `path`: The name of the field to bind to (ie "command.name")
|
* `path`: The name of the field to bind to (for example, "command.name")
|
||||||
* `options`: A `Map` of all the available values that can be selected from in the input
|
* `options`: A `Map` of all the available values that can be selected from in the input
|
||||||
field. The keys to the map represent the values that are POSTed back from the form
|
field. The keys to the map represent the values that are POSTed back from the form
|
||||||
and bound to the command object. Map objects stored against the keys are the labels
|
and bound to the command object. Map objects stored against the keys are the labels
|
||||||
|
|||||||
@@ -978,7 +978,7 @@ The following table describes the properties `CookieLocaleResolver`:
|
|||||||
| Property | Default | Description
|
| Property | Default | Description
|
||||||
|
|
||||||
| `cookieName`
|
| `cookieName`
|
||||||
| classname + LOCALE
|
| class name + LOCALE
|
||||||
| The name of the cookie
|
| The name of the cookie
|
||||||
|
|
||||||
| `cookieMaxAge`
|
| `cookieMaxAge`
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ In the absence of that, they need to come up with their own conventions.
|
|||||||
== When to Use WebSockets
|
== When to Use WebSockets
|
||||||
|
|
||||||
WebSockets can make a web page be dynamic and interactive. However, in many cases,
|
WebSockets can make a web page be dynamic and interactive. However, in many cases,
|
||||||
a combination of Ajax and HTTP streaming or long polling can provide a simple and
|
a combination of AJAX and HTTP streaming or long polling can provide a simple and
|
||||||
effective solution.
|
effective solution.
|
||||||
|
|
||||||
For example, news, mail, and social feeds need to update dynamically, but it may be
|
For example, news, mail, and social feeds need to update dynamically, but it may be
|
||||||
|
|||||||
Reference in New Issue
Block a user