Explicit notes on advice mode proxy vs aspectj

Issue: SPR-16092
This commit is contained in:
Juergen Hoeller
2017-10-22 20:34:34 +02:00
parent 75ec973bae
commit c7100f771c
5 changed files with 84 additions and 34 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -131,15 +131,19 @@ import org.springframework.core.Ordered;
* {@code @Transactional} methods. See {@link TransactionManagementConfigurer} Javadoc
* for further details.
*
* <p>The {@link #mode()} attribute controls how advice is applied; if the mode is
* <p>The {@link #mode} attribute controls how advice is applied: If the mode is
* {@link AdviceMode#PROXY} (the default), then the other attributes control the behavior
* of the proxying.
* of the proxying. Please note that proxy mode allows for interception of calls through
* the proxy only; local calls within the same class cannot get intercepted that way.
*
* <p>If the {@linkplain #mode} is set to {@link AdviceMode#ASPECTJ}, then the
* {@link #proxyTargetClass()} attribute is obsolete. Note also that in this case the
* {@code spring-aspects} module JAR must be present on the classpath.
* <p>Note that if the {@linkplain #mode} is set to {@link AdviceMode#ASPECTJ}, then the
* value of the {@link #proxyTargetClass} attribute will be ignored. Note also that in
* this case the {@code spring-aspects} module JAR must be present on the classpath, with
* compile-time weaving or load-time weaving applying the aspect to the affected classes.
* There is no proxy involved in such a scenario; local calls will be intercepted as well.
*
* @author Chris Beams
* @author Juergen Hoeller
* @since 3.1
* @see TransactionManagementConfigurer
* @see TransactionManagementConfigurationSelector
@@ -167,16 +171,21 @@ public @interface EnableTransactionManagement {
boolean proxyTargetClass() default false;
/**
* Indicate how transactional advice should be applied. The default is
* {@link AdviceMode#PROXY}.
* @see AdviceMode
* Indicate how transactional advice should be applied.
* <p><b>The default is {@link AdviceMode#PROXY}.</b>
* Please note that proxy mode allows for interception of calls through the proxy
* only. Local calls within the same class cannot get intercepted that way; an
* {@link Transactional} annotation on such a method within a local call will be
* ignored since Spring's interceptor does not even kick in for such a runtime
* scenario. For a more advanced mode of interception, consider switching this to
* {@link AdviceMode#ASPECTJ}.
*/
AdviceMode mode() default AdviceMode.PROXY;
/**
* Indicate the ordering of the execution of the transaction advisor
* when multiple advices are applied at a specific joinpoint.
* The default is {@link Ordered#LOWEST_PRECEDENCE}.
* <p>The default is {@link Ordered#LOWEST_PRECEDENCE}.
*/
int order() default Ordered.LOWEST_PRECEDENCE;