Skip to content

Commit 2f262af

Browse files
committed
Add documentation section on proxy type defaults and @proxyable
See gh-35286 See gh-35296
1 parent 573c5d9 commit 2f262af

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

framework-docs/modules/ROOT/pages/core/aop/proxying.adoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ you can do so. However, you should consider the following issues:
2828
deploying on the module path. Such cases require a JVM bootstrap flag
2929
`--add-opens=java.base/java.lang=ALL-UNNAMED` which is not available for modules.
3030

31+
32+
[[aop-forcing-proxy-types]]
33+
== Forcing Specific AOP Proxy Types
34+
3135
To force the use of CGLIB proxies, set the value of the `proxy-target-class` attribute
3236
of the `<aop:config>` element to true, as follows:
3337

@@ -60,6 +64,24 @@ To be clear, using `proxy-target-class="true"` on `<tx:annotation-driven/>`,
6064
proxies _for all three of them_.
6165
====
6266

67+
`@EnableAspectJAutoProxy`, `@EnableTransactionManagement` and related configuration
68+
annotations offer a corresponding `proxyTargetClass` attribute. These are collapsed
69+
into a single unified auto-proxy creator too, effectively applying the _strongest_
70+
proxy settings at runtime. As of 7.0, this applies to individual proxy processors
71+
as well, for example `@EnableAsync`, consistently participating in unified global
72+
default settings for all auto-proxying attempts in a given application.
73+
74+
The global default proxy type may differ between setups. While the core framework
75+
suggests interface-based proxies by default, Spring Boot may - depending on
76+
configuration properties - enable class-based proxies by default.
77+
78+
As of 7.0, forcing a specific proxy type for individual beans is possible through
79+
the `@Proxyable` annotation on a given `@Bean` method or `@Component` class, with
80+
`@Proxyable(INTERFACES)` or `@Proxyable(TARGET_CLASS)` overriding any globally
81+
configured default. For very specific purposes, you may even specify the proxy
82+
interface(s) to use through `@Proxyable(interfaces=...)`, limiting the exposure
83+
to selected interfaces rather than all interfaces that the target bean implements.
84+
6385

6486
[[aop-understanding-aop-proxies]]
6587
== Understanding AOP Proxies

0 commit comments

Comments
 (0)