Skip to content

Commit a3cd7af

Browse files
committed
Polishing
1 parent 6a9f910 commit a3cd7af

File tree

2 files changed

+60
-62
lines changed

2 files changed

+60
-62
lines changed

spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBuffer.java

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.io.InputStream;
2020
import java.io.OutputStream;
2121
import java.nio.ByteBuffer;
22-
import java.util.Arrays;
2322
import java.util.function.IntPredicate;
2423

2524
import io.netty.buffer.ByteBuf;

src/docs/asciidoc/data-access.adoc

+60-61
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,11 @@ moving from local to global transactions or vice versa.
379379
[[tx-resource-synchronization]]
380380
=== Synchronizing Resources with Transactions
381381

382-
How to create different transaction managers and how they are
383-
linked to related resources that need to be synchronized to transactions (for example
384-
`DataSourceTransactionManager` to a JDBC `DataSource`, `HibernateTransactionManager` to
385-
a Hibernate `SessionFactory`, and so forth) should now be clear. This section describes how the application
386-
code (directly or indirectly, by using a persistence API such as JDBC, Hibernate, or JPA)
382+
How to create different transaction managers and how they are linked to related resources
383+
that need to be synchronized to transactions (for example `DataSourceTransactionManager`
384+
to a JDBC `DataSource`, `HibernateTransactionManager` to a Hibernate `SessionFactory`,
385+
and so forth) should now be clear. This section describes how the application code
386+
(directly or indirectly, by using a persistence API such as JDBC, Hibernate, or JPA)
387387
ensures that these resources are created, reused, and cleaned up properly. The section
388388
also discusses how transaction synchronization is (optionally) triggered through the
389389
relevant `PlatformTransactionManager`.
@@ -530,16 +530,16 @@ on unchecked exceptions), it is often useful to customize this behavior.
530530

531531
It is not sufficient merely to tell you to annotate your classes with the
532532
`@Transactional` annotation, add `@EnableTransactionManagement` to your configuration,
533-
and expect you to understand how it all works. To provide a deeper understanding, this section explains the inner
534-
workings of the Spring Framework's declarative transaction infrastructure in the event
535-
of transaction-related issues.
533+
and expect you to understand how it all works. To provide a deeper understanding,
534+
this section explains the inner workings of the Spring Framework's declarative
535+
transaction infrastructure in the event of transaction-related issues.
536536

537537
The most important concepts to grasp with regard to the Spring Framework's declarative
538538
transaction support are that this support is enabled
539-
<<core.adoc#aop-understanding-aop-proxies,via AOP proxies>> and that the transactional advice
540-
is driven by metadata (currently XML- or annotation-based). The combination of AOP
541-
with transactional metadata yields an AOP proxy that uses a `TransactionInterceptor` in
542-
conjunction with an appropriate `PlatformTransactionManager` implementation to drive
539+
<<core.adoc#aop-understanding-aop-proxies,via AOP proxies>> and that the transactional
540+
advice is driven by metadata (currently XML- or annotation-based). The combination of
541+
AOP with transactional metadata yields an AOP proxy that uses a `TransactionInterceptor`
542+
in conjunction with an appropriate `PlatformTransactionManager` implementation to drive
543543
transactions around method invocations.
544544

545545
NOTE: Spring AOP is covered in <<core.adoc#aop, the AOP section>>.
@@ -1073,13 +1073,13 @@ source code puts the declarations much closer to the affected code. There is not
10731073
danger of undue coupling, because code that is meant to be used transactionally is
10741074
almost always deployed that way anyway.
10751075

1076-
NOTE: The standard `javax.transaction.Transactional` annotation is also supported as a drop-in
1077-
replacement to Spring's own annotation. Please refer to JTA 1.2 documentation for more
1078-
details.
1076+
NOTE: The standard `javax.transaction.Transactional` annotation is also supported as a
1077+
drop-in replacement to Spring's own annotation. Please refer to JTA 1.2 documentation
1078+
for more details.
10791079

10801080
The ease-of-use afforded by the use of the `@Transactional` annotation is best
1081-
illustrated with an example, which is explained in the text that follows. Consider the
1082-
following class definition:
1081+
illustrated with an example, which is explained in the text that follows.
1082+
Consider the following class definition:
10831083

10841084
====
10851085
[source,java,indent=0]
@@ -1154,8 +1154,8 @@ for full details.
11541154
When you use proxies, you should apply the `@Transactional` annotation only to methods
11551155
with public visibility. If you do annotate protected, private or package-visible
11561156
methods with the `@Transactional` annotation, no error is raised, but the annotated
1157-
method does not exhibit the configured transactional settings. If you need to annotate non-public methods, consider using
1158-
AspectJ (described later).
1157+
method does not exhibit the configured transactional settings. If you need to annotate
1158+
non-public methods, consider using AspectJ (described later).
11591159
****
11601160

11611161
You can place the `@Transactional` annotation before an interface definition, a method
@@ -1167,28 +1167,27 @@ the metadata to configure the appropriate beans with transactional behavior. In
11671167
preceding example, the `<tx:annotation-driven/>` element switches on the
11681168
transactional behavior.
11691169

1170-
TIP: The Spring team recommends that you annotate only concrete classes (and methods of concrete
1171-
classes) with the `@Transactional` annotation, as opposed to annotating interfaces. You
1172-
certainly can place the `@Transactional` annotation on an interface (or an interface
1170+
TIP: The Spring team recommends that you annotate only concrete classes (and methods of
1171+
concrete classes) with the `@Transactional` annotation, as opposed to annotating interfaces.
1172+
You certainly can place the `@Transactional` annotation on an interface (or an interface
11731173
method), but this works only as you would expect it to if you use interface-based
11741174
proxies. The fact that Java annotations are not inherited from interfaces means that,
11751175
if you use class-based proxies (`proxy-target-class="true"`) or the weaving-based
11761176
aspect (`mode="aspectj"`), the transaction settings are not recognized by the
11771177
proxying and weaving infrastructure, and the object is not wrapped in a
11781178
transactional proxy, which would be decidedly bad.
11791179

1180-
NOTE: In proxy mode (which is the default), only external method calls coming in through the
1181-
proxy are intercepted. This means that self-invocation (in effect, a method within the
1182-
target object calling another method of the target object) does not lead to an actual
1180+
NOTE: In proxy mode (which is the default), only external method calls coming in through
1181+
the proxy are intercepted. This means that self-invocation (in effect, a method within
1182+
the target object calling another method of the target object) does not lead to an actual
11831183
transaction at runtime even if the invoked method is marked with `@Transactional`. Also,
11841184
the proxy must be fully initialized to provide the expected behavior, so you should not
11851185
rely on this feature in your initialization code (that is, `@PostConstruct`).
11861186

1187-
Consider using of AspectJ mode (see the `mode` attribute in the following table) if you expect
1188-
self-invocations to be wrapped with transactions as well. In this case, there no
1189-
proxy in the first place. Instead, the target class is woven (that is, its
1190-
byte code is modified) to turn `@Transactional` into runtime behavior on
1191-
any kind of method.
1187+
Consider using of AspectJ mode (see the `mode` attribute in the following table) if you
1188+
expect self-invocations to be wrapped with transactions as well. In this case, there no
1189+
proxy in the first place. Instead, the target class is woven (that is, its byte code is
1190+
modified) to turn `@Transactional` into runtime behavior on any kind of method.
11921191

11931192
[[tx-annotation-driven-settings]]
11941193
.Annotation driven transaction settings
@@ -1232,9 +1231,9 @@ any kind of method.
12321231
No specified ordering means that the AOP subsystem determines the order of the advice.
12331232
|===
12341233

1235-
NOTE: The default advice mode for processing `@Transactional` annotations is `proxy`, which
1236-
allows for interception of calls through the proxy only. Local calls within the same
1237-
class cannot get intercepted that way. For a more advanced mode of interception,
1234+
NOTE: The default advice mode for processing `@Transactional` annotations is `proxy`,
1235+
which allows for interception of calls through the proxy only. Local calls within the
1236+
same class cannot get intercepted that way. For a more advanced mode of interception,
12381237
consider switching to `aspectj` mode in combination with compile-time or load-time weaving.
12391238

12401239
NOTE: The `proxy-target-class` attribute controls what type of transactional proxies are
@@ -1245,9 +1244,9 @@ interface-based proxies are created. (See <<aop-proxying>> for a discussion of t
12451244
different proxy types.)
12461245

12471246
NOTE: `@EnableTransactionManagement` and `<tx:annotation-driven/>` looks for
1248-
`@Transactional` only on beans in the same application context in which they are defined. This
1249-
means that, if you put annotation-driven configuration in a `WebApplicationContext` for
1250-
a `DispatcherServlet`, it checks for `@Transactional` beans only in your controllers
1247+
`@Transactional` only on beans in the same application context in which they are defined.
1248+
This means that, if you put annotation-driven configuration in a `WebApplicationContext`
1249+
for a `DispatcherServlet`, it checks for `@Transactional` beans only in your controllers
12511250
and not your services. See <<web.adoc#mvc-servlet, MVC>> for more information.
12521251

12531252
The most derived location takes precedence when evaluating the transactional settings
@@ -1279,10 +1278,10 @@ precedence over the transactional settings defined at the class level.
12791278
[[transaction-declarative-attransactional-settings]]
12801279
===== `@Transactional` Settings
12811280

1282-
The `@Transactional` annotation is metadata that specifies that an interface, class, or
1283-
method must have transactional semantics (for example, "`start a brand new read-only
1284-
transaction when this method is invoked, suspending any existing transaction`"). The
1285-
default `@Transactional` settings are as follows:
1281+
The `@Transactional` annotation is metadata that specifies that an interface, class,
1282+
or method must have transactional semantics (for example, "`start a brand new read-only
1283+
transaction when this method is invoked, suspending any existing transaction`").
1284+
The default `@Transactional` settings are as follows:
12861285

12871286
* The propagation setting is `PROPAGATION_REQUIRED.`
12881287
* The isolation level is `ISOLATION_DEFAULT.`
@@ -1291,8 +1290,8 @@ default `@Transactional` settings are as follows:
12911290
system, or to none if timeouts are not supported.
12921291
* Any `RuntimeException` triggers rollback, and any checked `Exception` does not.
12931292

1294-
You can change these default settings. The following table summarizes the various properties of the `@Transactional`
1295-
annotation:
1293+
You can change these default settings. The following table summarizes the various
1294+
properties of the `@Transactional` annotation:
12961295

12971296
[[tx-attransactional-properties]]
12981297
.@Transactional Settings
@@ -1350,10 +1349,10 @@ name of the transaction would be: `com.example.BusinessService.handlePayment`.
13501349
Most Spring applications need only a single transaction manager, but there may be
13511350
situations where you want multiple independent transaction managers in a single
13521351
application. You can use the `value` attribute of the `@Transactional` annotation to
1353-
optionally specify the identity of the `PlatformTransactionManager` to be used. This can
1354-
either be the bean name or the qualifier value of the transaction manager bean. For
1355-
example, using the qualifier notation, you can combine the following Java code with the
1356-
following transaction manager bean declarations in the application context:
1352+
optionally specify the identity of the `PlatformTransactionManager` to be used.
1353+
This can either be the bean name or the qualifier value of the transaction manager bean.
1354+
For example, using the qualifier notation, you can combine the following Java code with
1355+
the following transaction manager bean declarations in the application context:
13571356

13581357
====
13591358
[source,java,indent=0]
@@ -1390,18 +1389,18 @@ The following listing shows the bean declarations:
13901389
----
13911390
====
13921391

1393-
In this case, the two methods on `TransactionalService` run under separate
1394-
transaction managers, differentiated by the `order` and `account` qualifiers. The
1395-
default `<tx:annotation-driven>` target bean name, `transactionManager`, is still
1396-
used if no specifically qualified `PlatformTransactionManager` bean is found.
1392+
In this case, the two methods on `TransactionalService` run under separate transaction
1393+
managers, differentiated by the `order` and `account` qualifiers. The default
1394+
`<tx:annotation-driven>` target bean name, `transactionManager`, is still used if no
1395+
specifically qualified `PlatformTransactionManager` bean is found.
13971396

13981397
[[tx-custom-attributes]]
13991398
===== Custom Shortcut Annotations
14001399

1401-
If you find you repeatedly use the same attributes with `@Transactional` on many
1402-
different methods, <<core.adoc#beans-meta-annotations,Spring's meta-annotation support>> lets
1403-
you define custom shortcut annotations for your specific use cases. For example, consider
1404-
the following annotation definitions:
1400+
If you find you repeatedly use the same attributes with `@Transactional` on many different
1401+
methods, <<core.adoc#beans-meta-annotations,Spring's meta-annotation support>> lets you
1402+
define custom shortcut annotations for your specific use cases. For example, consider the
1403+
following annotation definitions:
14051404

14061405
====
14071406
[source,java,indent=0]
@@ -1702,10 +1701,10 @@ You can configure additional aspects in similar fashion.
17021701
[[transaction-declarative-aspectj]]
17031702
==== Using `@Transactional` with AspectJ
17041703

1705-
You can also use the Spring Framework's `@Transactional` support outside of a
1706-
Spring container by means of an AspectJ aspect. To do so, first annotate your
1707-
classes (and optionally your classes' methods) with the `@Transactional` annotation, and
1708-
then link (weave) your application with the
1704+
You can also use the Spring Framework's `@Transactional` support outside of a Spring
1705+
container by means of an AspectJ aspect. To do so, first annotate your classes
1706+
(and optionally your classes' methods) with the `@Transactional` annotation,
1707+
and then link (weave) your application with the
17091708
`org.springframework.transaction.aspectj.AnnotationTransactionAspect` defined in the
17101709
`spring-aspects.jar` file. You must also configure The aspect with a transaction
17111710
manager. You can use the Spring Framework's IoC container to take care of
@@ -5533,9 +5532,9 @@ these annotated methods. The following example shows how to do so:
55335532
----
55345533
====
55355534

5536-
In the container, you need to set up the `PlatformTransactionManager`
5537-
implementation (as a bean) and a `<tx:annotation-driven/>` entry,
5538-
opting into `@Transactional` processing at runtime. The following example shows how to do so:
5535+
In the container, you need to set up the `PlatformTransactionManager` implementation
5536+
(as a bean) and a `<tx:annotation-driven/>` entry, opting into `@Transactional`
5537+
processing at runtime. The following example shows how to do so:
55395538

55405539
====
55415540
[source,xml,indent=0]

0 commit comments

Comments
 (0)