Commit Graph

135 Commits

Author SHA1 Message Date
Sam Brannen
d5ee787e1e Migrate JUnit 3 tests to JUnit 4
This commit migrates all remaining tests from JUnit 3 to JUnit 4, with
the exception of Spring's legacy JUnit 3.8 based testing framework that
is still in use in the spring-orm module.

Issue: SPR-13514
2015-09-27 21:17:51 +02:00
Juergen Hoeller
ebe128e940 Polishing 2015-09-24 00:33:14 +02:00
Sam Brannen
164bed5c3f Use implicit aliases in @TransactionalEventListener 2015-08-28 20:04:52 +02:00
Stephane Nicoll
a3f39d5257 Add missing 4.2 XSDs
Issue: SPR-13300
2015-08-01 09:50:36 +02:00
Sam Brannen
725292081e Introduce 'value' alias for 'attribute' in @AliasFor
SPR-11512 introduced support for annotation attribute aliases via
@AliasFor, requiring the explicit declaration of the 'attribute'
attribute. However, for aliases within an annotation, this explicit
declaration is unnecessary.

This commit improves the readability of alias pairs declared within an
annotation by introducing a 'value' attribute in @AliasFor that is an
alias for the existing 'attribute' attribute. This allows annotations
such as @ContextConfiguration from the spring-test module to declare
aliases as follows.

public @interface ContextConfiguration {

     @AliasFor("locations")
     String[] value() default {};

     @AliasFor("value")
     String[] locations() default {};

    // ...
}

Issue: SPR-13289
2015-07-29 15:27:06 +02:00
Juergen Hoeller
14f27bda37 Prefer use of "Java EE" over "J2EE" 2015-07-27 15:32:56 +02:00
Juergen Hoeller
f06581f5b8 Polishing 2015-07-22 14:20:12 +02:00
Juergen Hoeller
edd6e76b9f Polishing 2015-07-21 22:58:34 +02:00
Juergen Hoeller
a8fb551b1c Allow for overriding of computeTransactionAttribute
Issue: SPR-13246
2015-07-17 15:24:24 +02:00
Sam Brannen
f300325b1b Polishing 2015-07-08 15:08:29 +02:00
Stephane Nicoll
bf786c3176 Support for multiple events per method
In addition to specifying the event type to listen to via a method
parameter, any @EventListener annotated method can now alternatively
define the event type(s) to listen to via the "classes" attributes (that
is aliased to "value").

Something like

@EventListener({FooEvent.class, BarEvent.class})
public void handleFooBar() { .... }

Issue: SPR-13156
2015-07-08 14:51:07 +02:00
Sam Brannen
6c530b7bfb Delete trailing whitespace in XML files 2015-06-19 17:14:10 +02:00
Juergen Hoeller
f1c7dc4f4b Introduced SimpleTransactionScope (analogous to SimpleThreadScope)
Issue: SPR-13085
2015-06-18 00:29:46 +02:00
Juergen Hoeller
9f64230131 TransactionAttributeSourcePointcut pointcut skips target classes with TransactionalProxy marker (e.g. Spring Data proxies)
This 4.2 commit also makes TransactionProxyFactoryBean expose the TransactionalProxy marker and refines SpringProxy marker handling.

Issue: SPR-13109
2015-06-17 13:02:26 +02:00
Sam Brannen
d9f18f7355 Polish AnnotationTransactionAttributeSourceTests 2015-06-16 21:36:13 +01:00
Sam Brannen
32c17bf540 Revise method and parameter names in annotation support
In AnnotatedElementUtils, all methods pertaining to merging annotation
attributes have been renamed to "getMerged*()" and "findMerged*()"
accordingly. Existing methods such as getAnnotationAttributes(..) have
been deprecated in favor of the more descriptive "merged" variants.
This aligns the naming conventions in AnnotatedElementUtils with those
already present in AnnotationReadingVisitorUtils.

The use of "annotationType" as a variable name for the fully qualified
class name of an annotation type has been replaced with
"annotationName" in order to improve the readability and intent of the
code base.

In MetaAnnotationUtils.AnnotationDescriptor, getMergedAnnotation() has
been renamed to synthesizeAnnotation(), and the method is now
overridden in UntypedAnnotationDescriptor to always throw an
UnsupportedOperationException in order to avoid potential run-time
ClassCastExceptions.

Issue: SPR-11511
2015-06-14 00:34:40 +02:00
Sam Brannen
6b7c1d72e8 Introduce alias for 'value' attribute in @Transactional
Issue: SPR-11393
2015-06-12 22:35:20 +02:00
Sam Brannen
6fc388315e Polish Javadoc for @Transactional 2015-06-12 21:59:44 +02:00
Sam Brannen
9afcd17c71 Introduce getAnnotationAttributes(..,Class) in AnnoElUtils 2015-05-29 21:36:00 +02:00
Juergen Hoeller
b4095c3e1d Class identity comparisons wherever possible
Issue: SPR-12926
2015-05-20 14:34:16 +02:00
Stephane Nicoll
cf391f5ce1 polish
Remove unused imports
2015-05-19 08:49:01 +02:00
Sam Brannen
122d3476d9 Polish Javadoc for condition annotation attributes 2015-04-24 01:38:13 +02:00
Sam Brannen
ad6bea1cda Support abstract, bridge, & interface methods in AnnotatedElementUtils
This commit introduces support for finding annotations on abstract,
bridge, and interface methods in AnnotatedElementUtils.

 - Introduced dedicated findAnnotationAttributes() methods in
   AnnotatedElementUtils that provide first-class support for
   processing methods, class hierarchies, interfaces, bridge methods,
   etc.

 - Introduced find/get search algorithm dichotomy in
   AnnotatedElementUtils which is visible in the public API as well as
   in the internal implementation. This was necessary in order to
   maintain backwards compatibility with the existing API (even though
   it was undocumented).

 - Reverted all recent changes made to the "get semantics" search
   algorithm in AnnotatedElementUtils in order to ensure backwards
   compatibility, and reverted recent changes to
   JtaTransactionAnnotationParser and SpringTransactionAnnotationParser
   accordingly.

 - Documented internal AnnotatedElementUtils.Processor<T> interface.

 - Enabled failing tests and introduced
   findAnnotationAttributesFromBridgeMethod() test in
   AnnotatedElementUtilsTests.

 - Refactored ApplicationListenerMethodAdapter.getCondition() and
   enabled failing test in TransactionalEventListenerTests.

 - AnnotationUtils.isInterfaceWithAnnotatedMethods() is now package
   private.

Issue: SPR-12738, SPR-11514, SPR-11598
2015-04-24 00:55:48 +02:00
Sam Brannen
8ece1b145c Introduce failing/ignored tests for SPR-12738
Issue: SPR-12738
2015-04-23 01:33:46 +02:00
Sam Brannen
7f0f04dfe3 Support annotations on interfaces in AnnotatedElementUtils
This commit introduces support in AnnotatedElementUtils for finding
annotations declared on interfaces at the type level.

NB: this commit does not include support for finding annotations
declared on interface methods.

In order to maintain backward compatibility with @Transactional
annotation attribute processing, a new getAnnotationAttributes() method
has been added to AnnotatedElementUtils that provides a flag to control
whether interfaces should be searched.
SpringTransactionAnnotationParser and JtaTransactionAnnotationParser
have been updated accordingly to ensure that interfaces are not
unintentionally searched in the @Transactional resolution process.

This commit also introduces additional tests and updates TODOs for
SPR-12738.

Issue: SPR-12944, SPR-12738
2015-04-23 01:33:37 +02:00
Sam Brannen
b9b0b78fa1 Support n meta-annotation levels on methods in AnnotationUtils
Prior to this commit, the search algorithm used by the
findAnnotation(Method, Class) method in AnnotationUtils only found
direct annotations or direct meta-annotations (i.e., one level of
meta-annotations).

This commit reworks the search algorithm so that it supports arbitrary
levels of meta-annotations on methods. To make this possible, a new
findAnnotation(AnnotatedElement, Class) method has been introduced in
AnnotationUtils.

This fix also allows for the @Ignore'd tests in
TransactionalEventListenerTests to be re-enabled.

Issue: SPR-12941
2015-04-22 02:26:24 +02:00
Sam Brannen
8a1f9f8aa3 Fix typo in exception message 2015-04-21 19:54:48 +02:00
Stephane Nicoll
ca91956bdb Do not retain BeanFactory ref
This is a rework of fd7153f that also now clears the reference to the
BeanFactory when the context is disposed.

Issue: SPR-12518
2015-04-20 17:05:59 +02:00
Juergen Hoeller
13659d645b Consistent support for @Order annotation as alternative to Ordered interface
Issue: SPR-12806
2015-03-13 18:18:33 +01:00
Juergen Hoeller
5ec2cd7947 AbstractPlatformTransactionManager logs warning for custom isolation level in case of no actual transaction
Issue: SPR-12600
2015-03-06 17:45:45 +01:00
Juergen Hoeller
fdd1f83639 Polishing
(cherry picked from commit 3783591)
2015-03-02 22:05:16 +01:00
Stephane Nicoll
babbf6e871 Harmonize resources location
Issue: SPR-12766
2015-02-28 10:32:40 +01:00
Juergen Hoeller
2b3409461f Polishing 2015-02-27 22:29:42 +01:00
Stephane Nicoll
4741a12fdc Support for transactional event listener
Update the application event listener infrastructure to support events
that are processed according to a transactional phase.

Introduce EventListenerFactory that can be implemented to provide support
for additional event listener types. TransactionalEventListener is a new
annotation that can be used in lieu of the regular EventListener. Its
related factory implementation is registered in the context automatically
via @EnableTransactionManagement or <tx:annotation-driven/>

By default, a TransactionalEventListener is invoked when the transaction
has completed successfully (i.e. AFTER_COMMIT). Additional phases are
provided to handle BEFORE_COMMIT and AFTER_ROLLBACK events.

If no transaction is running, such listener is not invoked at all unless
the `fallbackExecution` flag has been explicitly set.

Issue: SPR-12080
2015-02-10 09:14:33 +01:00
Juergen Hoeller
1cd4433621 Polishing 2015-01-22 18:44:07 +01:00
Stephane Nicoll
a79fe25917 Restore default transaction manager by name lookup
Fix a regression introduced by 961574bd17 that prevents a proper lookup
of the default transaction manager by name as the absence of a qualifier
is represented by an empty string (passing the faulty null check).

Issue: SPR-12577
2014-12-31 15:21:43 +01:00
Juergen Hoeller
9ac02b319d Remove pre-3.2 deprecated classes and methods
Issue: SPR-12578
2014-12-30 20:05:15 +01:00
Stephane Nicoll
961574bd17 Fix regression in determineTransactionManager
One more (and hopefully last) attempt at making sure
determineTransactionManager does not break existing use cases.

This commit prevents any lookup if no transaction attributes are set
which is more compliant with the original version and prevents a lookup
if a non existing bean name is provided explicitly (as it can be the case
with Spring Boot).

Issue: SPR-12541
2014-12-28 18:17:01 +01:00
Stephane Nicoll
4a0ac97550 Fix regression in determineTransactionManager
The fix in cec26e9 for SPR-12541 actually introduced a regression
when the interceptor is enabled on a method that does not require any
transaction. In such a case we try to locate the default
PlatformTransactionManager instead of just returning what we have (that
is null).

This commit updates the determineTransactionManager condition again to
take that use case into account again.

Issue: SPR-12541
2014-12-28 17:38:06 +01:00
Juergen Hoeller
b30843aee0 AbstractFallbackTransactionAttributeSource's DefaultCacheKey takes targetClass into account (again)
Issue: SPR-12536
(cherry picked from commit c087e51)
2014-12-22 18:46:07 +01:00
Stephane Nicoll
fd7153ffbb Do not retain cache transaction managers
Previously, cache transaction managers may be  retained outside the
boundaries of an application context with AspectJ since an aspect is
basically a singleton for the current class loader.

This commit adds a "clearTransactionManagerCache" that is similar to the
"clearMetadataCache" introduced in CacheAspectSupport: whenever the
context is disposed, the cache is cleared to remove any reference to a
transaction manager defined by that context.

Issue: SPR-12518
2014-12-16 16:26:02 +01:00
Stephane Nicoll
cec26e9ac4 Rework determineTransactionManager condition
SPR-11954 introduced a regression that when the "default" transaction
manager is cached, qualified transaction managers are not taken into
account anymore.

This commit rework the "determineTransactionManager" condition to
favor qualifier and "named" transaction managers. If none of these apply,
the default transaction manager is used as it should.

Also reworked the caching infrastructure so that a single cache holds
all transaction manager instances.

Issue: SPR-12541
2014-12-16 15:05:00 +01:00
Sam Brannen
c2101cbcf4 Require non-empty values for TxMgr qualifiers & bean names 2014-12-12 21:01:00 +01:00
Sam Brannen
5b5cf37ac5 Polish Javadoc regarding default transaction manager 2014-12-12 20:56:59 +01:00
Juergen Hoeller
ff8655846d TransactionAspectSupport.currentTransactionStatus() reliably throws NoTransactionException
Issue: SPR-9144
2014-10-27 15:47:52 +01:00
Juergen Hoeller
8325b10080 Consistent formatting of license headers, package javadocs, and import declarations 2014-10-21 01:44:07 +02:00
Juergen Hoeller
43597bfed4 Polishing 2014-10-16 17:26:10 +02:00
Juergen Hoeller
e58b33a593 Consistent reset of resource holders on doBegin failure
Issue: SPR-12280
2014-10-06 20:31:45 +02:00
Juergen Hoeller
3a3c52dbdd Polishing 2014-10-01 01:10:25 +02:00
Juergen Hoeller
fcb9dd1939 JtaTransactionManagerFactoryBean as an equivalent to <tx:jta-transaction-manager/>
Issue: SPR-12197
2014-09-30 20:14:51 +02:00