Clarification: Spring AOP pointcuts may match non-public methods
Issue: SPR-15354
This commit is contained in:
parent
b2a6a572d3
commit
b90d3d0e88
|
@ -405,16 +405,20 @@ proxy (bound to `target`).
|
||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
====
|
====
|
||||||
Due to the proxy-based nature of Spring's AOP framework, protected methods are by
|
Due to the proxy-based nature of Spring's AOP framework, calls within the target object
|
||||||
definition __not__ intercepted, neither for JDK proxies (where this isn't applicable)
|
are by definition __not__ intercepted. For JDK proxies, only public interface method
|
||||||
nor for CGLIB proxies (where this is technically possible but not recommendable for AOP
|
calls on the proxy can be intercepted. With CGLIB, public and protected method calls on
|
||||||
purposes). As a consequence, any given pointcut will be matched against __public methods
|
the proxy will be intercepted, and even package-visible methods if necessary. However,
|
||||||
only__!
|
common interactions through proxies should always be designed through public signatures.
|
||||||
|
|
||||||
If your interception needs include protected/private methods or even constructors,
|
Note that pointcut definitions are generally matched against any intercepted method.
|
||||||
consider the use of Spring-driven <<aop-aj-ltw,native AspectJ weaving>> instead of
|
If a pointcut is strictly meant to be public-only, even in a CGLIB proxy scenario with
|
||||||
Spring's proxy-based AOP framework. This constitutes a different mode of AOP usage with
|
potential non-public interactions through proxies, it needs to be defined accordingly.
|
||||||
different characteristics, so be sure to make yourself familiar with weaving first
|
|
||||||
|
If your interception needs include method calls or even constructors within the target
|
||||||
|
class, consider the use of Spring-driven <<aop-aj-ltw,native AspectJ weaving>> instead
|
||||||
|
of Spring's proxy-based AOP framework. This constitutes a different mode of AOP usage
|
||||||
|
with different characteristics, so be sure to make yourself familiar with weaving first
|
||||||
before making a decision.
|
before making a decision.
|
||||||
====
|
====
|
||||||
|
|
||||||
|
@ -1558,7 +1562,6 @@ advisor, and aspect elements (note these must be declared in that order).
|
||||||
|
|
||||||
[WARNING]
|
[WARNING]
|
||||||
====
|
====
|
||||||
|
|
||||||
The `<aop:config>` style of configuration makes heavy use of Spring's
|
The `<aop:config>` style of configuration makes heavy use of Spring's
|
||||||
<<aop-autoproxy,auto-proxying>> mechanism. This can cause issues (such as advice not
|
<<aop-autoproxy,auto-proxying>> mechanism. This can cause issues (such as advice not
|
||||||
being woven) if you are already using explicit auto-proxying via the use of
|
being woven) if you are already using explicit auto-proxying via the use of
|
||||||
|
|
|
@ -8329,7 +8329,7 @@ synchronously. This means the `publishEvent()` method blocks until all listeners
|
||||||
finished processing the event. One advantage of this synchronous and single-threaded
|
finished processing the event. One advantage of this synchronous and single-threaded
|
||||||
approach is that when a listener receives an event, it operates inside the transaction
|
approach is that when a listener receives an event, it operates inside the transaction
|
||||||
context of the publisher if a transaction context is available. If another strategy for
|
context of the publisher if a transaction context is available. If another strategy for
|
||||||
event publication becomes necessary, refer to the JavaDoc for Spring's
|
event publication becomes necessary, refer to the javadoc for Spring's
|
||||||
`ApplicationEventMulticaster` interface.
|
`ApplicationEventMulticaster` interface.
|
||||||
|
|
||||||
The following example shows the bean definitions used to register and configure each of
|
The following example shows the bean definitions used to register and configure each of
|
||||||
|
@ -8396,9 +8396,10 @@ follows:
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
As you can see above, the method signature actually _infer_ which even type it listens to. This
|
As you can see above, the method signature once again declares the event type it listens to,
|
||||||
also works for nested generics as long as the actual event resolves the generics parameter you
|
but this time with a flexible name and without implementing a specific listener interface.
|
||||||
would filter on.
|
The event type can also be narrowed through generics as long as the actual event type
|
||||||
|
resolves your generic parameter in its implementation hierarchy.
|
||||||
|
|
||||||
If your method should listen to several events or if you want to define it with no
|
If your method should listen to several events or if you want to define it with no
|
||||||
parameter at all, the event type(s) can also be specified on the annotation itself:
|
parameter at all, the event type(s) can also be specified on the annotation itself:
|
||||||
|
@ -8408,7 +8409,7 @@ parameter at all, the event type(s) can also be specified on the annotation itse
|
||||||
----
|
----
|
||||||
@EventListener({ContextStartedEvent.class, ContextRefreshedEvent.class})
|
@EventListener({ContextStartedEvent.class, ContextRefreshedEvent.class})
|
||||||
public void handleContextStart() {
|
public void handleContextStart() {
|
||||||
|
...
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -8658,7 +8659,7 @@ platform's JMX server - all through Spring's standard transaction management and
|
||||||
and JMX support facilities. Application components can also interact with the
|
and JMX support facilities. Application components can also interact with the
|
||||||
application server's JCA WorkManager through Spring's `TaskExecutor` abstraction.
|
application server's JCA WorkManager through Spring's `TaskExecutor` abstraction.
|
||||||
|
|
||||||
Check out the JavaDoc of the
|
Check out the javadoc of the
|
||||||
{api-spring-framework}/jca/context/SpringContextResourceAdapter.html[`SpringContextResourceAdapter`]
|
{api-spring-framework}/jca/context/SpringContextResourceAdapter.html[`SpringContextResourceAdapter`]
|
||||||
class for the configuration details involved in RAR deployment.
|
class for the configuration details involved in RAR deployment.
|
||||||
|
|
||||||
|
@ -8666,7 +8667,7 @@ __For a simple deployment of a Spring ApplicationContext as a Java EE RAR file:_
|
||||||
all application classes into a RAR file, which is a standard JAR file with a different
|
all application classes into a RAR file, which is a standard JAR file with a different
|
||||||
file extension. Add all required library JARs into the root of the RAR archive. Add a
|
file extension. Add all required library JARs into the root of the RAR archive. Add a
|
||||||
"META-INF/ra.xml" deployment descriptor (as shown in ``SpringContextResourceAdapter``s
|
"META-INF/ra.xml" deployment descriptor (as shown in ``SpringContextResourceAdapter``s
|
||||||
JavaDoc) and the corresponding Spring XML bean definition file(s) (typically
|
javadoc) and the corresponding Spring XML bean definition file(s) (typically
|
||||||
"META-INF/applicationContext.xml"), and drop the resulting RAR file into your
|
"META-INF/applicationContext.xml"), and drop the resulting RAR file into your
|
||||||
application server's deployment directory.
|
application server's deployment directory.
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ variables and functions are described in the language reference sections
|
||||||
<<expressions-ref-variables,Variables>> and <<expressions-ref-functions,Functions>>. The
|
<<expressions-ref-variables,Variables>> and <<expressions-ref-functions,Functions>>. The
|
||||||
`StandardEvaluationContext` is also where you can register custom
|
`StandardEvaluationContext` is also where you can register custom
|
||||||
``ConstructorResolver``s, ``MethodResolver``s, and ``PropertyAccessor``s to extend how SpEL
|
``ConstructorResolver``s, ``MethodResolver``s, and ``PropertyAccessor``s to extend how SpEL
|
||||||
evaluates expressions. Please refer to the JavaDoc of these classes for more details.
|
evaluates expressions. Please refer to the javadoc of these classes for more details.
|
||||||
|
|
||||||
|
|
||||||
[[expressions-type-conversion]]
|
[[expressions-type-conversion]]
|
||||||
|
|
Loading…
Reference in New Issue