Skip to content

Commit 4f81ab7

Browse files
committed
Polishing
1 parent 7281d44 commit 4f81ab7

File tree

4 files changed

+90
-76
lines changed

4 files changed

+90
-76
lines changed

spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,12 +61,12 @@ public class AopNamespaceHandler extends NamespaceHandlerSupport {
6161
*/
6262
@Override
6363
public void init() {
64-
// In 2.0 XSD as well as in 2.1 XSD.
64+
// In 2.0 XSD as well as in 2.5+ XSDs
6565
registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser());
6666
registerBeanDefinitionParser("aspectj-autoproxy", new AspectJAutoProxyBeanDefinitionParser());
6767
registerBeanDefinitionDecorator("scoped-proxy", new ScopedProxyBeanDefinitionDecorator());
6868

69-
// Only in 2.0 XSD: moved to context namespace as of 2.1
69+
// Only in 2.0 XSD: moved to context namespace in 2.5+
7070
registerBeanDefinitionParser("spring-configured", new SpringConfiguredBeanDefinitionParser());
7171
}
7272

spring-web/src/main/java/org/springframework/web/util/DefaultUriBuilderFactory.java

Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,55 +39,6 @@
3939
*/
4040
public class DefaultUriBuilderFactory implements UriBuilderFactory {
4141

42-
/**
43-
* Enum to represent multiple URI encoding strategies.
44-
* @see #setEncodingMode
45-
*/
46-
public enum EncodingMode {
47-
48-
/**
49-
* Pre-encode the URI template first, then strictly encode URI variables
50-
* when expanded, with the following rules:
51-
* <ul>
52-
* <li>For the URI template replace <em>only</em> non-ASCII and illegal
53-
* (within a given URI component type) characters with escaped octets.
54-
* <li>For URI variables do the same and also replace characters with
55-
* reserved meaning.
56-
* </ul>
57-
* <p>For most cases, this mode is most likely to give the expected
58-
* result because in treats URI variables as opaque data to be fully
59-
* encoded, while {@link #URI_COMPONENT} by comparison is useful only
60-
* if intentionally expanding URI variables with reserved characters.
61-
* @since 5.0.8
62-
* @see UriComponentsBuilder#encode()
63-
*/
64-
TEMPLATE_AND_VALUES,
65-
66-
/**
67-
* Does not encode the URI template and instead applies strict encoding
68-
* to URI variables via {@link UriUtils#encodeUriVariables} prior to
69-
* expanding them into the template.
70-
* @see UriUtils#encodeUriVariables(Object...)
71-
* @see UriUtils#encodeUriVariables(Map)
72-
*/
73-
VALUES_ONLY,
74-
75-
/**
76-
* Expand URI variables first, and then encode the resulting URI
77-
* component values, replacing <em>only</em> non-ASCII and illegal
78-
* (within a given URI component type) characters, but not characters
79-
* with reserved meaning.
80-
* @see UriComponents#encode()
81-
*/
82-
URI_COMPONENT,
83-
84-
/**
85-
* No encoding should be applied.
86-
*/
87-
NONE
88-
}
89-
90-
9142
@Nullable
9243
private final UriComponentsBuilder baseUri;
9344

@@ -194,16 +145,19 @@ public boolean shouldParsePath() {
194145

195146
// UriTemplateHandler
196147

148+
@Override
197149
public URI expand(String uriTemplate, Map<String, ?> uriVars) {
198150
return uriString(uriTemplate).build(uriVars);
199151
}
200152

153+
@Override
201154
public URI expand(String uriTemplate, Object... uriVars) {
202155
return uriString(uriTemplate).build(uriVars);
203156
}
204157

205158
// UriBuilderFactory
206159

160+
@Override
207161
public UriBuilder uriString(String uriTemplate) {
208162
return new DefaultUriBuilder(uriTemplate);
209163
}
@@ -214,6 +168,62 @@ public UriBuilder builder() {
214168
}
215169

216170

171+
/**
172+
* Enum to represent multiple URI encoding strategies. The following are
173+
* available:
174+
* <ul>
175+
* <li>{@link #TEMPLATE_AND_VALUES}
176+
* <li>{@link #VALUES_ONLY}
177+
* <li>{@link #URI_COMPONENT}
178+
* <li>{@link #NONE}
179+
* </ul>
180+
* @see #setEncodingMode
181+
*/
182+
public enum EncodingMode {
183+
184+
/**
185+
* Pre-encode the URI template first, then strictly encode URI variables
186+
* when expanded, with the following rules:
187+
* <ul>
188+
* <li>For the URI template replace <em>only</em> non-ASCII and illegal
189+
* (within a given URI component type) characters with escaped octets.
190+
* <li>For URI variables do the same and also replace characters with
191+
* reserved meaning.
192+
* </ul>
193+
* <p>For most cases, this mode is most likely to give the expected
194+
* result because in treats URI variables as opaque data to be fully
195+
* encoded, while {@link #URI_COMPONENT} by comparison is useful only
196+
* if intentionally expanding URI variables with reserved characters.
197+
* @since 5.0.8
198+
* @see UriComponentsBuilder#encode()
199+
*/
200+
TEMPLATE_AND_VALUES,
201+
202+
/**
203+
* Does not encode the URI template and instead applies strict encoding
204+
* to URI variables via {@link UriUtils#encodeUriVariables} prior to
205+
* expanding them into the template.
206+
* @see UriUtils#encodeUriVariables(Object...)
207+
* @see UriUtils#encodeUriVariables(Map)
208+
*/
209+
VALUES_ONLY,
210+
211+
/**
212+
* Expand URI variables first, and then encode the resulting URI
213+
* component values, replacing <em>only</em> non-ASCII and illegal
214+
* (within a given URI component type) characters, but not characters
215+
* with reserved meaning.
216+
* @see UriComponents#encode()
217+
*/
218+
URI_COMPONENT,
219+
220+
/**
221+
* No encoding should be applied.
222+
*/
223+
NONE
224+
}
225+
226+
217227
/**
218228
* {@link DefaultUriBuilderFactory} specific implementation of UriBuilder.
219229
*/

spring-web/src/main/java/org/springframework/web/util/UriBuilderFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.util;
1718

1819
/**
@@ -22,13 +23,14 @@
2223
*
2324
* @author Rossen Stoyanchev
2425
* @since 5.0
26+
* @see DefaultUriBuilderFactory
2527
*/
2628
public interface UriBuilderFactory extends UriTemplateHandler {
2729

2830
/**
2931
* Initialize a builder with the given URI template.
3032
* @param uriTemplate the URI template to use
31-
* @return the URI builder instance
33+
* @return the builder instance
3234
*/
3335
UriBuilder uriString(String uriTemplate);
3436

src/docs/asciidoc/core/core-aop.adoc

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,16 +1403,16 @@ In many cases, you do this binding anyway (as in the preceding example).
14031403

14041404
What happens when multiple pieces of advice all want to run at the same join point?
14051405
Spring AOP follows the same precedence rules as AspectJ to determine the order of advice
1406-
execution. The highest precedence advice runs first "`on the way in`" (so, given two pieces
1407-
of before advice, the one with highest precedence runs first). "`On the way out`" from a
1406+
execution. The highest precedence advice runs first "on the way in" (so, given two pieces
1407+
of before advice, the one with highest precedence runs first). "On the way out" from a
14081408
join point, the highest precedence advice runs last (so, given two pieces of after
14091409
advice, the one with the highest precedence will run second).
14101410

14111411
When two pieces of advice defined in different aspects both need to run at the same
14121412
join point, unless you specify otherwise, the order of execution is undefined. You can
14131413
control the order of execution by specifying precedence. This is done in the normal
14141414
Spring way by either implementing the `org.springframework.core.Ordered` interface in
1415-
the aspect class or annotating it with the `Order` annotation. Given two aspects, the
1415+
the aspect class or annotating it with the `@Order` annotation. Given two aspects, the
14161416
aspect returning the lower value from `Ordered.getValue()` (or the annotation value) has
14171417
the higher precedence.
14181418

@@ -1643,9 +1643,9 @@ expression so that only `@Idempotent` operations match, as follows:
16431643
== Schema-based AOP Support
16441644

16451645
If you prefer an XML-based format, Spring also offers support for defining aspects
1646-
using the new `aop` namespace tags. The exact same pointcut expressions and advice kinds
1646+
using the `aop` namespace tags. The exact same pointcut expressions and advice kinds
16471647
as when using the @AspectJ style are supported. Hence, in this section we focus on
1648-
the new syntax and refer the reader to the discussion in the previous section
1648+
that syntax and refer the reader to the discussion in the previous section
16491649
(<<aop-ataspectj>>) for an understanding of writing pointcut expressions and the binding
16501650
of advice parameters.
16511651

@@ -1675,7 +1675,7 @@ When you use the schema support, an aspect is a regular Java object defined as a
16751675
your Spring application context. The state and behavior are captured in the fields and
16761676
methods of the object, and the pointcut and advice information are captured in the XML.
16771677

1678-
You can declare an aspect by using the <aop:aspect> element, and reference the backing bean
1678+
You can declare an aspect by using the `<aop:aspect>` element, and reference the backing bean
16791679
by using the `ref` attribute, as the following example shows:
16801680

16811681
====
@@ -1801,9 +1801,10 @@ parameters of the matching names, as follows:
18011801
----
18021802
====
18031803

1804-
When combining pointcut sub-expressions, `&&` is awkward within an XML document, so
1805-
you can use the `and`, `or`, and `not` keywords in place of `&&`, `||`, and `!`,
1806-
respectively. For example, the previous pointcut can be better written as follows:
1804+
When combining pointcut sub-expressions, `+&amp;&amp;+` is awkward within an XML
1805+
document, so you can use the `and`, `or`, and `not` keywords in place of `+&amp;&amp;+`,
1806+
`||`, and `!`, respectively. For example, the previous pointcut can be better written as
1807+
follows:
18071808

18081809
====
18091810
[source,xml,indent=0]
@@ -1913,8 +1914,8 @@ shows how to declare it:
19131914
----
19141915
====
19151916

1916-
As in the @AspectJ style, you can get the return value within the
1917-
advice body. To do so, use the returning attribute to specify the name of the parameter to which
1917+
As in the @AspectJ style, you can get the return value within the advice body.
1918+
To do so, use the `returning` attribute to specify the name of the parameter to which
19181919
the return value should be passed, as the following example shows:
19191920

19201921
====
@@ -1951,7 +1952,7 @@ example, you can declare the method signature as follows:
19511952
==== After Throwing Advice
19521953

19531954
After throwing advice executes when a matched method execution exits by throwing an
1954-
exception. It is declared inside an `<aop:aspect>` by using the after-throwing element,
1955+
exception. It is declared inside an `<aop:aspect>` by using the `after-throwing` element,
19551956
as the following example shows:
19561957

19571958
====
@@ -1970,8 +1971,8 @@ as the following example shows:
19701971
----
19711972
====
19721973

1973-
As in the @AspectJ style, you can get the thrown exception within
1974-
the advice body. To do so, use the throwing attribute to specify the name of the parameter to
1974+
As in the @AspectJ style, you can get the thrown exception within the advice body.
1975+
To do so, use the `throwing` attribute to specify the name of the parameter to
19751976
which the exception should be passed as the following example shows:
19761977

19771978
====
@@ -2030,7 +2031,7 @@ by using the `after` element, as the following example shows:
20302031
[[aop-schema-advice-around]]
20312032
==== Around Advice
20322033

2033-
The last kind of advice is around advice. Around advice runs "`around`" a matched method
2034+
The last kind of advice is around advice. Around advice runs "around" a matched method
20342035
execution. It has the opportunity to do work both before and after the method executes
20352036
and to determine when, how, and even if the method actually gets to execute at all.
20362037
Around advice is often used to share state before and after a method
@@ -2233,10 +2234,11 @@ ms % Task name
22332234
[[aop-ordering]]
22342235
==== Advice Ordering
22352236

2236-
When multiple advice needs to execute at the same join point (executing method) the
2237-
ordering rules are as described in <<aop-ataspectj-advice-ordering>>. The precedence
2238-
between aspects is determined by either adding the `Order` annotation to the bean
2239-
that backs the aspect or by having the bean implement the `Ordered` interface.
2237+
When multiple pieces of advice need to execute at the same join point (executing method)
2238+
the ordering rules are as described in <<aop-ataspectj-advice-ordering>>. The precedence
2239+
between aspects is determined via the `order` attribute in the `<aop:aspect>` element or
2240+
by either adding the `@Order` annotation to the bean that backs the aspect or by having
2241+
the bean implement the `Ordered` interface.
22402242

22412243

22422244

@@ -2781,7 +2783,7 @@ following example shows:
27812783
27822784
public static void main(String[] args) {
27832785
ProxyFactory factory = new ProxyFactory(new SimplePojo());
2784-
factory.adddInterface(Pojo.class);
2786+
factory.addInterface(Pojo.class);
27852787
factory.addAdvice(new RetryAdvice());
27862788
factory.setExposeProxy(true);
27872789
@@ -3472,7 +3474,7 @@ for AspectJ LTW:
34723474
* `spring-aop.jar`
34733475
* `aspectjweaver.jar`
34743476

3475-
If you use the <<aop-aj-ltw-environment-generic, Spring-provided agent to enable
3477+
If you use the <<aop-aj-ltw-environments-generic, Spring-provided agent to enable
34763478
instrumentation>>, you also need:
34773479

34783480
* `spring-instrument.jar`

0 commit comments

Comments
 (0)