Commit Graph

203 Commits

Author SHA1 Message Date
Sam Brannen 5b3edcd9f9 Spring Cleaning in December
- Delete unused imports
- Delete unused code
- Clean up warnings
2015-12-17 20:27:33 +01:00
Juergen Hoeller dd647659b3 Rearranged cache test class names across several modules 2015-11-26 16:30:44 +01:00
Stephane Nicoll 9882a53c7d Fix test failure 2015-11-25 22:05:57 +01:00
Stephane Nicoll 2a2a8d3f93 Allow null values to be cached with `@CacheResult`
Even though the JSR-107 spec forbids to store null values, our cache
abstraction allows that behaviour with a special handled (and this is
the default behaviour).

While this was working fine with our own set of annotations, the
JSR-107 interceptor counterpart was interpreting the spec sensu strictu.

We now allow for that special case as well.

Issue: SPR-13641
2015-11-09 13:04:40 +01:00
Sam Brannen 3dcf8c1712 Simplify legacy JUnit 3.8 based tests in spring-orm
This is in preparation for a migration from JUnit 3 to JUnit 4.

Issue: SPR-13514, SPR-13515
2015-09-28 01:19:27 +02:00
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 edd6e76b9f Polishing 2015-07-21 22:58:34 +02:00
Juergen Hoeller dd4bc630c3 Common code in AsyncExecutionAspectSupport allows for CompletableFuture processing with AspectJ as well
Issue: SPR-13128
2015-06-22 00:29:44 +02:00
Juergen Hoeller 581ab18b85 Test for Java 8's CompletableFuture with Spring's async execution aspect
Issue: SPR-13128
2015-06-16 21:56:17 +02:00
Sam Brannen 4dffeeee64 Introduce alias for 'value' attribute in caching annotations
This commit introduces new 'cacheNames' attributes (analogous to the
existing attribute of the same name in @CacheConfig) as aliases for the
'value' attributes in @Cacheable, @CachePut, and @CacheEvict.

In addition, SpringCacheAnnotationParser.getAnnotations() has been
refactored to support synthesized annotations.

Issue: SPR-11393
2015-05-31 22:52:01 +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
Juergen Hoeller 8b2d9951e0 AnnotationAsyncExecutionAspect properly accepts ListenableFuture return type
Issue: SPR-12895
2015-04-15 14:57:43 +02:00
Juergen Hoeller 595cdf05e9 Polishing 2015-04-04 00:23:25 +02:00
Sam Brannen 6861d35ea0 Assemble iajc Ant task classpath w/ folders that exist
Prior to this commit, the [ant:iajc] tasks logged numerous warnings
regarding incorrect classpath entries. The reason is that the classpath
was constructed with paths that do not physically exist in the file
system (e.g., for projects that do not have test classes or test
folders (yet)).

This commit picks up where ef75bd8 left off and addresses this issue by
assembling the runtime classpath passed to the iajc task with folders
and JARs that actually exist in the filesystem.
2015-03-07 18:43:14 +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
Sam Brannen ef75bd8441 Clean up classpath for iajc Ant task 2015-02-12 19:32:49 +01:00
Stephane Nicoll 66735d01cf Add exception-handler attribute support for AspectJ
Previously, the exception-handler attribute was not taken care of when
task:annotation-driven is used in AspectJ mode. This commit provides the
expected behavior.

Issue: SPR-12619
2015-02-12 15:25:51 +01:00
Stephane Nicoll fa8d202a45 AspectJ support for javax.transaction.Transactional
Issue: SPR-11803
2015-02-12 14:45:47 +01:00
Stephane Nicoll 73c21fbac1 Define JCache aspect
Align default aop.xml configuration to define the JCache aspect alongside
the regular Spring cache aspect.

 Issue: SPR-12571
2014-12-29 10:02:14 +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
Janning Vygen 061b246307 Add @AjSuppressWarnings on static mocks
Issue: SPR-12447
2014-12-03 10:55:39 +01:00
Stephane Nicoll d9df50c6cd @Entity no longer required with spring-aspect
This commits complements 222d2b1 for another required dependency.

javax.persistence.Entity was previously required, regardless of which
aspects were actually used by the project. It is now optional and will
not break the build if it is not present. Note that the side effect is that
AnnotationDrivenStaticEntityMockingControl is disabled as well if the
JPA API is not available.

Issue: SPR-6819
2014-10-24 10:39:59 +02:00
Stephane Nicoll 222d2b1639 Fix unnecessary required spring-context-support dep
Prior to this commit, a project using compile time weaving upgrading to
4.1 was forced to add spring-context-support and the jcache API in order
to build. This problem is not new really: spring-aspects holds all
aspects provided by the framework and they all are evaluated when
compiling. 4.1 just happens to define a new aspect that requires extra
dependencies.

This commit uses a new annotation of AspectJ 1.8.3. When @RequiredTypes
is added on an aspect, it is evaluated only if the classes defined on the
annotation are actually present. If they are not, the aspect is disabled
and does not break the build.

Issue: SPR-12163
2014-10-24 10:30:24 +02:00
Juergen Hoeller 8325b10080 Consistent formatting of license headers, package javadocs, and import declarations 2014-10-21 01:44:07 +02:00
Janning Vygen 6950d5517b Adding @AjSuppressWarnings on some advices
Issue: SPR-12239
2014-10-01 16:28:21 +02:00
Juergen Hoeller 20c2ba35dc Polishing 2014-09-04 00:55:38 +02:00
Stephane Nicoll 2553fb8ba1 Apply ListenableFuture support to AspectJ
Prior to this commit, only @Async annotated methods with proxy style
had an explicit support for ListenableFuture. This commit brings that
support to AspectJ as well.

Issue: SPR-12092
2014-08-18 11:12:07 +02:00
Stephane Nicoll 8fc191c95e Apply AsyncUncaughtExceptionHandler to AspectJ
Prior to this commit, only @Async annotated methods with proxy style
had their custom uncaught exception handler applied. This commit
harmonizes the configuration so that AspectJ applies that behaviour as
well.

Issue: SPR-12090
2014-08-18 10:51:21 +02:00
Juergen Hoeller 3bcfc591e9 Polishing 2014-07-29 14:11:19 +02:00
Juergen Hoeller 8f484d382e Polishing 2014-07-29 11:42:37 +02:00
Juergen Hoeller 9f3c1cf762 Polishing 2014-07-28 23:05:08 +02:00
Juergen Hoeller 036896a6b8 Split configuration constants into local XConfigUtils classes instead of piling them up in AnnotationConfigUtils 2014-07-28 21:58:21 +02:00
Stephane Nicoll d9e0b292ab polishing 2014-07-23 17:08:19 +02:00
Juergen Hoeller 9d6c38bd54 Consistent bracket alignment 2014-07-18 17:21:58 +02:00
Stephane Nicoll 35226695eb Rename default to testCache in Cache related tests
This simply renames the default cache from "default" to "testCache" as
this might be a reserved names for third party cache providers.
2014-07-16 17:25:27 +02:00
Juergen Hoeller 3c7bb9c279 Fixed Xml/AnnotationBeanConfigurerTests after AbstractBeanConfigurerTests removal 2014-05-08 17:21:26 +02:00
Juergen Hoeller 6c1f8de5fa Eventual removal of deprecated AbstractBeanConfigurerAspect, BeanReferenceFactoryBean and CommonsLogFactoryBean 2014-05-08 16:24:22 +02:00
Stephane Nicoll 3cda355e7f polishing
This commit fixes the handling of cached exceptions in the JSR-107
advisor. Such exceptions are now properly propagated instead of being
wrapped in a RuntimeException.

Issue: SPR-9616
2014-04-08 17:04:25 +02:00
Stephane Nicoll f3b8a4103e Use CacheResolver in Spring abstraction
Prior to this commit, the CacheResolver was not used by Spring's
caching abstraction. This commit provides the necessary configuration
options to tune how a cache is resolved for a given operation.

CacheResolver can be customized globally, at the operation level or at
the class level. This breaks the CachingConfigurer class and a support
implementation is provided that implements all methods so that the
default is taken if it's not overridden. The JSR-107 support has been
updated as well, with a similar support class.

In particular, the static and runtime information of a cache
operation were mixed which prevents any forms of caching. As the
CacheResolver and the KeyGenerator can be customized, every operation
call lead to a lookup in the context for the bean.

This commit adds CacheOperationMetadata, a static holder of all
the non-runtime metadata about a cache operation. This is used
as an input source for the existing CacheOperationContext.

Caching the operation metadata in an AspectJ aspect can have side
effects as the aspect is static instance for the current ClassLoader.
The metadata cache needs to be cleared when the context shutdowns.
This is essentially a test issue only as in practice each application
runs in its class loader. Tests are now closing the context properly
to honor the DisposableBean callback.

Issue: SPR-11490
2014-04-07 15:41:09 +02:00
Stephane Nicoll 47a4327193 Add JSR-107 cache annotations support
This commit adds support for the JSR-107 cache annotations alongside
the Spring's cache annotations, that is @CacheResult, @CachePut,
@CacheRemove and @CacheRemoveAll as well as related annotations
@CacheDefaults, @CacheKey and @CacheValue.

Spring's caching configuration infrastructure detects the presence of
the JSR-107 API and Spring's JCache implementation. Both
@EnableCaching and the cache namespace are able to configure the
required JCache infrastructure when necessary. Both proxy mode
and AspectJ mode are supported.

As JSR-107 permits the customization of the CacheResolver to use for
both regular and exception caches, JCacheConfigurer has been
introduced as an extension of CachingConfigurer and permits to define
those.

If an exception is cached and should be rethrown, it is cloned and
the call stack is rewritten so that it matches the calling thread each
time. If the exception cannot be cloned, the original exception is
returned.

Internally, the interceptors uses Spring's caching abstraction by default
with an adapter layer when a JSR-107 component needs to be called.
This is the case for CacheResolver and CacheKeyGenerator.

The implementation uses Spring's CacheManager abstraction behind the
scene. The standard annotations can therefore be used against any
CacheManager implementation.

Issue: SPR-9616
2014-04-07 12:07:20 +02:00
Stephane Nicoll f06cad91c0 Add custom cache manager per cache operation
It is now possible to specify the CacheManager to use per operation.
The related cache annotation now has an extra attribute that defines
the name of the CacheManager bean to use.  The cache manager that
was previously used is therefore a 'default' cache manager (i.e. the
one to use if no custom cache manager has been set on the operation).

Issue: SPR-8696
2014-03-31 14:17:54 +02:00
Stephane Nicoll 81c208098f Custom KeyGenerator
This commit adds an extra parameter to the base @Cache method
annotations: keyGenerator. This parameter holds the name of the
KeyGenerator bean to use to compute the key for that specific
caching endpoint.

This gives therefore a third way to customize the key. These are:
1. Default KeyGenerator (global for all endpoints)
2. The 'key' attribute of the annotation, giving the SpEL expression to use
3. The 'keyGenerator' attribute of the annotation

The annotation attributes are therefore exclusive. Trying to specify
them both will result in an IllegalStateException.

The KeyGenerator to use for a given operation is cached on startup
so that multiple calls to it does not resolve the instance to use over and
over again.

Issue: SPR-10629
2014-03-31 14:15:27 +02:00
Stephane Nicoll 4cd818b9e4 Harmonize log configuration
Prior to this commit, the codebase was using a mix of log4j.xml
and log4j.properties for test-related logging configuration. This
can be an issue as log4j takes the xml variant first when looking
for a default bootstrap configuration.

In practice, some modules declaring the properties variant were
taking the xml variant configuration from another module.

The general structure of the configuration has also been
harmonized to provide a standard console output as well as an
easy way to enable trace logs for the current module.
2014-03-20 09:43:29 -07:00
Sam Brannen fbdebc1bd6 Clean up warnings that show up in Gradle build 2014-02-26 14:05:26 +01:00
Sam Brannen c335e99e3f Remove trailing whitespace from source code 2014-02-08 17:30:39 +01:00
Sam Brannen 624170f178 Introduce verify & reset methods in ADSEMockCtrl
This commit introduces static verify() and reset() methods in
AnnotationDrivenStaticEntityMockingControl for programmatic control
on the mock.

Issue: SPR-11395
2014-02-05 23:18:41 +01:00
Sam Brannen 81c259fe42 Explain mock scope in static method mocking aspect 2014-02-05 20:17:34 +01:00
Sam Brannen 9fe9e27189 Explain after advice behavior in static method mock aspect
This commit makes it clear that mock verification will not occur if an
advised test method throws an exception.
2014-02-05 15:57:52 +01:00
Sam Brannen 76f3d6e501 Improve test coverage for AbstractMethodMockingControl
This commit improves the test coverage for AbstractMethodMockingControl
by introducing tests that verify expected behavior for:

 - reentrant method invocations via public methods
 - reentrant method invocations via private methods
 - test methods that do not set expectations or invoke playback()
 - test methods that throw exceptions

For a more complete discussion of "after" vs. "after returning" advice
within AbstractMethodMockingControl, see the Javadoc in the tests.
2014-02-05 15:41:47 +01:00
Sam Brannen 3a89bc4b26 Fix merge error in previous commit
Issue: SPR-11385
2014-02-04 23:27:55 +01:00
Sam Brannen 69a89b1bb0 Fix off-by-one regression in AbstractMethodMockingControl
This commit fixes the off-by-one regression accidentally introduced in
commit 55961544a7.

Specifically, this fix ensures that the correct recorded call is
indexed in the 'calls' list in the implementation of
AbstractMethodMockingControl.Expectations.nextCall().

In addition, this commit improves the Javadoc for
AbstractMethodMockingControl, @MockStaticEntityMethods, and
AnnotationDrivenStaticEntityMockingControl and introduces a proper
toString() implementation for the internal Expectations.Call class in
AbstractMethodMockingControl. Furthermore, code from the obsolete
Delegate test class has been inlined in
AnnotationDrivenStaticEntityMockingControlTests.

Issue: SPR-11385, SPR-10885
2014-02-04 23:14:39 +01:00
Sam Brannen d90a36170a Polish Javadoc for @MockStaticEntityMethods & its aspect 2014-02-03 23:47:02 +01:00
Sam Brannen b8ed2f4967 Ensure all tests are executed in the Gradle build
Prior to this commit several test classes named "*Test" were not
recognized as tests by the Gradle build. This is due to the configured
inclusion of '**/*Tests.*' which follows Spring's naming convention for
test classes.

This commit addresses this issue by:

 - Renaming real test classes consistently to "*Tests".
 - Renaming internal test classes to "*TestCase".
 - Renaming @WebTest to @WebTestStereotype.
 - Disabling broken tests in AnnoDrivenStaticEntityMockingControlTest.
 - Modifying the Gradle build configuration so that classes ending in
   either "*Tests" or "*Test" are considered test classes.

Issue: SPR-11384
2014-02-03 23:16:47 +01:00
Juergen Hoeller ee2022e54c Polishing 2014-01-05 03:01:44 +01:00
Juergen Hoeller a0ccd65d51 Consistent build dependencies 2014-01-05 03:00:12 +01:00
Phillip Webb 043a41e382 Consistent whitespace after imports
Update code to have a consistent number of new-line characters after
import statements.
2013-11-26 15:14:43 -08:00
Phillip Webb 05072e1762 Expand var-args before passing to KeyGenerator
Update `CacheAspectSupport` to expand any var-arg parameters before
calling `KeyGenerator` implementations. Prior to this commit var-args
would be passed to `KeyGenerator` implementations as a nested array,
often causing the same key to be generated regardless of the arguments.

Issue: SPR-10870
2013-09-23 15:14:58 -07:00
Juergen Hoeller 3ca0dcd912 Fixed method count in AbstractMethodMockingControl's IllegalStateException message
Issue: SPR-10885
(cherry picked from commit 5596154)
2013-09-02 20:25:47 +02:00
Juergen Hoeller 2d1b44202b OpenJDK 8 build 99: annotation discovery on bridge methods 2013-07-24 13:36:59 +02:00
Phillip Webb eea230f2a8 Allow @CachePut 'key' SpEL to refer to #result
Allow the @CachePut 'key' SpEL to refer to the result of the method call
via a '#result' variable.

This change is particularly useful when working with JPA entities that
have generated @Id values since the ID will often not be available
until the entity has been saved.

Issue: SPR-10664
2013-06-23 09:07:16 -07:00
Rob Winch 6a5acb9372 Update to Gradle 1.6 2013-05-14 12:24:00 -05:00
Rob Winch 9468548116 Add @Override to remaining source files
Issue: SPR-10130
2013-05-13 17:04:56 -05:00
Juergen Hoeller 2a44228b98 Consistent use of <pre class="code">
Issue: SPR-8108
2013-05-07 21:31:26 +02:00
Juergen Hoeller cd996ba18f Upgrading to JDK 1.8 bytecode along with ASM 4.1 patch
ASM has been patched to accept 1.8 bytecode simply through removing an assertion. As a consequence, we have an embedded copy of the ASM sources now instead of jarjar'ing the original ASM jar. The sources originate from ASM 4.1; for CGLIB 3.0 compatibility, a further assertion has been removed.

Issue: SPR-9639
2013-04-23 13:57:26 +02:00
Chris Beams 2a78b97598 Polish whitespace in JpaExceptionTranslatorAspect.aj
Issue: SPR-10208
2013-02-28 09:14:46 +01:00
Rob Winch 21a49ef4c5 Polish whitespace in *.aj
Previously we had restored the whitespace for *.aj files in 6888a6f28
to avoid a but in aspectj.

We have updated to the latest version of apsectj and restored the
changes in commit 6888a6f28 which included a significant cleanup of
whitespace.

Issue: SPR-10208
2013-02-27 15:06:11 -06:00
Juergen Hoeller 1af28efe39 @Transactional in AspectJ mode works with CallbackPreferringPlatformTransactionManager (WebSphere) as well
Effectively, AbstractTransactionAspect got refactored into around advice, reusing former TransactionInterceptor code which now lives in slightly generalized form in TransactionAspectSupport, and using a workaround for rethrowing checked exceptions.

Issue: SPR-9268
2013-02-10 18:06:50 +01:00
Phillip Webb 8c2ace33cb Support 'unless' expression for cache veto
Allow @Cachable, @CachePut and equivalent XML configuration to provide
a SpEL expression that can be used to veto putting an item into the
cache. Unlike 'condition' the 'unless' parameter is evaluated after
the method has been called and can therefore reference the #result.

For example:

    @Cacheable(value="book",
        condition="#name.length < 32",
        unless="#result.hardback")

This commit also allows #result to be referenced from @CacheEvict
expressions as long as 'beforeInvocation' is false.

Issue: SPR-8871
2013-02-04 11:59:15 -08:00
Phillip Webb f464a45ba4 Polish formatting
Minor formatting polish across that codebase. Primarily fixing
whitespace issues.
2013-02-04 10:35:25 -08:00
Phillip Webb 065b1c0e46 Fix unused local variable warnings 2013-01-25 14:35:19 -08:00
Phillip Webb 6a1e841952 Fix unused type compiler warnings 2013-01-25 14:35:07 -08:00
Chris Beams e659deab4f Remove .aj sources from spring-aspects jar
Issue: SPR-10179
2013-01-16 08:56:06 +01:00
Rob Winch 6888a6f286 Restore *.aj whitespace
The removal of whitespace to the *.aj files made in 1762157 cause
NoSuchMethodError for code compiled against previous versions of
spring-aspects due to a bug in AspectJ (see SPR-10178 for details).

This commit reverts all the whitespace changes made in 1762157 which
resolves the NoSuchMethodErrors.

Issue: SPR-10178
2013-01-15 17:20:54 -06:00
Rob Winch 91da138314 Use explicit JDK versions in aspects.gradle
Previously aspects.gradle used the Gradle conventions for the source
and target compatibility. This means that unless the conventions were
updated the current JDK would be used for both source and target
compatibilty. Since an update to build.gradle changed to configure the
compileJava and compileTestJava tasks explicitly spring-aspects has
been compiled with JDK 7 compatibility.

This commit explicitly uses the source and target compatibility from
spring-core to ensure that aspects.gradle is kept up to date.

Issue: SPR-10161
2013-01-10 15:40:22 -06:00
Chris Beams cf68cc5f0b Eliminate AJ @Async warning in test case
Prior to this commit, ClassWithAsyncAnnotation#return5 forced an
unsuppressable warning in Eclipse, making it virtually impossible to
get to a zero-warnings state in the codebase.

The 'solution' here is simply to comment out the method and it's
associated test case. The 'declare warnings' functionality around
@Async is well-understood and has long been stable.

Also, the entire AnnotationAsyncExecutionAspectTests class has been
added to TestGroup#PERFORMANCE (SPR-9984), as opposed to just
asyncMethodGetsRoutedAsynchronously as it was previously, the
rationale being that all tests are actually timing dependent.

Issue: SPR-9431, SPR-9984
2013-01-04 12:20:19 +01:00
Chris Beams 662a02b952 Fix several miscellaneous compiler/Eclipse warnings
- Suppress an (intentional) AspectJ warning
 - Remove unused imports
 - Suppress a [hiding] warning
 - Fix a generics warning related to extension of final types

Issue: SPR-9431
2013-01-04 11:41:49 +01:00
Chris Beams b836e14b5f Merge branch 'cleanup-test-duplicates' into cleanup-3.2.x
* cleanup-test-duplicates:
  Update Apache license headers for affected sources
  Remove duplicate test classes
  Replace test beans with test objects

Conflicts:
	spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java
	spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java
2013-01-04 10:31:31 +01:00
Chris Beams d1e6dbe74a Update Apache license headers for affected sources 2013-01-04 10:29:11 +01:00
Phillip Webb 42b5d6dd7e Remove duplicate test classes
Prior to this commit many test utility classes and sample beans were
duplicated across projects. This was previously necessary due to the
fact that dependent test sources were not shared during a gradle
build. Since the introduction of the 'test-source-set-dependencies'
gradle plugin this is no longer the case.

This commit attempts to remove as much duplicate code as possible,
co-locating test utilities and beans in the most suitable project.
For example, test beans are now located in the 'spring-beans'
project.

Some of the duplicated code had started to drift apart when
modifications made in one project where not ported to others. All
changes have now been consolidated and when necessary existing tests
have been refactored to account for the differences.

Conflicts:
	spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java
	spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java
	spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java
2013-01-04 10:02:29 +01:00
Chris Beams 68e3b7773c Segregate add'l long-running and performance tests
- Add TestGroup#LONG_RUNNING to distinguish from #PERFORMANCE, the
   former being tests that simply take a long time vs the latter being
   tests that are actually dependent on certain actions happening within
   a given time window and are thefore CPU-dependent.

Issue: SPR-9984
2013-01-03 19:28:05 +01:00
Chris Beams dcda78bad6 Skip creation of IDEA metadata for spring-aspects
See diff for details
2013-01-03 19:19:24 +01:00
Phillip Webb 6626a38730 Fix [deprecation] compiler warnings
Fix deprecation compiler warnings by refactoring code or applying
@SuppressWarnings("deprecation") annotations. JUnit tests of
internally deprecated classes are now themselves marked as
@Deprecated.

Numerous EasyMock deprecation warnings will remain until the
migration to mockito can be completed.
2013-01-01 13:42:15 -08:00
Chris Beams 8472a2b2ab Update Apache license headers for affected sources 2012-12-28 23:09:31 +01:00
Phillip Webb 6c14eaad61 Fix [cast] compiler warnings 2012-12-28 22:41:06 +01:00
Phillip Webb b0986049a3 Fix [serial] compiler warnings
Fix serialization warnings by applying @SuppressWarnings("serial")
when appropriate.

In certain cases and for unknown reasons, a correctly-placed
@SuppressWarnings("serial") annotation will fix the warning at the
javac level (i.e. the Gradle command-line), but will produce an
"unnecessary @SuppressWarnings" warning within Eclipse. In these
cases, a private static final serialVersionUID field has been added
with the default value of 1L.
2012-12-28 22:41:06 +01:00
Chris Beams 9540d2c81b Replace <code> with {@code} throughout Javadoc
Issue: SPR-10128
2012-12-28 22:36:02 +01:00
Chris Beams 8597ec25ec Fix various Javadoc warnings
Issue: SPR-10128
2012-12-28 22:36:02 +01:00
Phillip Webb 2cf45bad86 Replace space indentation with tabs
Issue: SPR-10127
2012-12-28 20:49:56 +01:00
Phillip Webb 1762157ad1 Remove trailing whitespace in source files
find . -type f -name "*.java" -or -name "*.aj" | \
    xargs perl -p -i -e "s/[ \t]*$//g" {} \;

Issue: SPR-10127
2012-12-28 20:49:45 +01:00
Chris Beams f26534700a Eliminate all Javadoc warnings
- Support external Javadoc links using Gradle's javadoc.options.links

 - Fix all other Javadoc warnings, such as typos, references to
   non-existent (or no longer existent) types and members, etc,
   including changes related to the Quartz 2.0 upgrade (SPR-8275) and
   adding the HTTP PATCH method (SPR-7985).

 - Suppress all output for project-level `javadoc` tasks in order to
   hide false-negative warnings about cross-module @see and @link
   references (e.g. spring-core having a @see reference to spring-web).
   Use the `--info` (-i) flag to gradle at any time to see project-level
   javadoc warnings without running the entire `api` task. e.g.
   `gradle :spring-core:javadoc -i`

 - Favor root project level `api` task for detection of legitimate
   Javadoc warnings. There are now zero Javadoc warnings across the
   entirety of spring-framework. Goal: keep it that way.

 - Remove all @link and @see references to types and members that exist
   only in Servlet <= 2.5 and Hibernate <= 4.0, favoring 3.0+ and 4.0+
   respectively. This is necessary because only one version of each of
   these dependencies can be present on the global `api` javadoc task's
   classpath. To that end, the `api` task classpath has now been
   customized to ensure that the Servlet 3 API and Hibernate Core 4 jars
   have precedence.

 - SPR-8896 replaced our dependency on aspectjrt with a dependency on
   aspectjweaver, which is fine from a POM point of view, but causes
   a spurious warning to be emitted from the ant iajc task that it
   "cannot find aspectjrt on the classpath" - even though aspectjweaver
   is perfectly sufficient. In the name of keeping the console quiet, a
   new `rt` configuration has been added, and aspectjrt added as a
   dependency to it. In turn, configurations.rt.asPath is appended to
   the iajc classpath during both compileJava and compileTestJava for
   spring-aspects.

Issue: SPR-10078, SPR-8275, SPR-7985, SPR-8896
2012-12-12 12:55:10 +01:00
Phillip Webb 0751b2cbeb Convert Gradle build to use new propdeps-plugin
Replace existing 'optional' and 'provided' Spring specific build
extensions with a new Gradle propdeps-plugin. Optional and Provided
dependencies are now defined use dependency configurations.

The new plugin does not currently support the notion of optional
runtime dependencies. All optional dependencies are implicitly
part of the 'compile' scope. This is an intentional design decision
that aims to keep both the plugin and the build simple. Since optional
dependencies are non-transitive this restriction should not cause
any real problems for existing users. The only existing dependency
affected is 'commons-io' in the 'spring-beans' project, however, this
was an optional compile scope dependency in the previous Spring 3.1
release.

Both provided and optional dependencies are no longer exported from
generated eclipse .classpath files. This fixes several tests that
would previously fail when running within eclipse. The servlet-api
specific elements of ide.gradle are also no longer required.

Issue: SPR-9656, SPR-10070
2012-12-09 21:33:34 -08:00
Phillip Webb a268528726 Polish .gradle file formatting to use tabs
Replace spaces with tabs for consistency with Java source code
2012-12-09 21:32:27 -08:00
Phillip Webb da50a0213b Polish Javadoc
Minor Javadoc reformat to prevent erroneous eclipse warnings
2012-11-20 12:17:25 -08:00
Chris Beams 54db7387de Fix split package introduced by @EnableSpringConfigured
Commit 5327a7a37d moved
@EnableSpringConfigured from beans.factory.aspectj =>
context.annotation within the spring-aspects module. This resolved a
package cycle but had the side-effect of causing a "split package" [1]
problem between spring-context and spring-aspects in OSGi-based
classloader environments because the context.annotation package now
exists in both modules.

The simplest and best solution from an OSGi perspective is to relocate
@EnableSpringConfigured and its supporting SpringConfiguredConfiguration
class into a new package. This commit moves both these types into
context.annotation.aspectj, following convention with other such
"aspectj"-qualified packages in the spring-aspects module.

As with the previous move, it is presumed this change will be low-impact
as the "spring-configured" approach to domain object injection is a
niche feature to begin with, and @EnableSpringConfigured has existed in
its current location only since 3.1.2 and this change is being made in
time for 3.1.3.

[1]: http://wiki.osgi.org/wiki/Split_Packages

Issue: SPR-9811, SPR-9441
2012-10-26 14:01:29 +02:00
Chris Beams b8ff6c1f86 Update dependencies for spring-aspects
- Explicitly specify compile-time dependencies on other spring-*
   modules, primarily for accuracy in pom generation and ensuring
   minimal dependencies for users of spring-aspects.

 - Remove use of p: namespace from annotation-cache-aspectj.xml to
   avoid parser-related test failures under Eclipse (likely due to
   classpath differences between Gradle and Eclipse).
2012-06-01 15:35:29 +02:00
Chris Beams 5327a7a37d Fix package cycle in @EnableSpringConfigured
@EnableSpringConfigured and its @Import'ed
SpringConfiguredConfiguration @Configuration class inadvertently
established a package cycle between beans.factory.aspectj and
context.annotation due to SpringConfiguredConfiguration's
dependency on annotations such as @Configuration, @Bean and @Role.

This commit fixes this architecture bug by moving
@EnableSpringConfigured and SpringConfiguredConfiguration from the
beans.factory.aspectj package to the context.annotation package where
they belong.

This change is assumed to be very low impact as @EnableSpringConfigured
was introduced in 3.1.0 and relocation is happening as quickly as
possible in 3.1.2. @EnableSpringConfigured is assumed to be infrequently
used at this point, and for those that are the migration path
is straightforward. When upgrading from Spring 3.1.0 or 3.1.1, update
import statements in any affected @Configuration classes to reflect the
new packaging.

Issue: SPR-9441
2012-05-26 14:23:11 +03:00
Chris Beams ed0576c181 Support executor qualification with @Async#value
Prior to this change, Spring's @Async annotation support was tied to a
single AsyncTaskExecutor bean, meaning that all methods marked with
@Async were forced to use the same executor. This is an undesirable
limitation, given that certain methods may have different priorities,
etc. This leads to the need to (optionally) qualify which executor
should handle each method.

This is similar to the way that Spring's @Transactional annotation was
originally tied to a single PlatformTransactionManager, but in Spring
3.0 was enhanced to allow for a qualifier via the #value attribute, e.g.

  @Transactional("ptm1")
  public void m() { ... }

where "ptm1" is either the name of a PlatformTransactionManager bean or
a qualifier value associated with a PlatformTransactionManager bean,
e.g. via the <qualifier> element in XML or the @Qualifier annotation.

This commit introduces the same approach to @Async and its relationship
to underlying executor beans. As always, the following syntax remains
supported

  @Async
  public void m() { ... }

indicating that calls to #m will be delegated to the "default" executor,
i.e. the executor provided to

  <task:annotation-driven executor="..."/>

or the executor specified when authoring a @Configuration class that
implements AsyncConfigurer and its #getAsyncExecutor method.

However, it now also possible to qualify which executor should be used
on a method-by-method basis, e.g.

  @Async("e1")
  public void m() { ... }

indicating that calls to #m will be delegated to the executor bean
named or otherwise qualified as "e1". Unlike the default executor
which is specified up front at configuration time as described above,
the "e1" executor bean is looked up within the container on the first
execution of #m and then cached in association with that method for the
lifetime of the container.

Class-level use of Async#value behaves as expected, indicating that all
methods within the annotated class should be executed with the named
executor. In the case of both method- and class-level annotations, any
method-level #value overrides any class level #value.

This commit introduces the following major changes:

 - Add @Async#value attribute for executor qualification

 - Introduce AsyncExecutionAspectSupport as a common base class for
   both MethodInterceptor- and AspectJ-based async aspects. This base
   class provides common structure for specifying the default executor
   (#setExecutor) as well as logic for determining (and caching) which
   executor should execute a given method (#determineAsyncExecutor) and
   an abstract method to allow subclasses to provide specific strategies
   for executor qualification (#getExecutorQualifier).

 - Introduce AnnotationAsyncExecutionInterceptor as a specialization of
   the existing AsyncExecutionInterceptor to allow for introspection of
   the @Async annotation and its #value attribute for a given method.
   Note that this new subclass was necessary for packaging reasons -
   the original AsyncExecutionInterceptor lives in
   org.springframework.aop and therefore does not have visibility to
   the @Async annotation in org.springframework.scheduling.annotation.
   This new subclass replaces usage of AsyncExecutionInterceptor
   throughout the framework, though the latter remains usable and
   undeprecated for compatibility with any existing third-party
   extensions.

 - Add documentation to spring-task-3.2.xsd and reference manual
   explaining @Async executor qualification

 - Add tests covering all new functionality

Note that the public API of all affected components remains backward-
compatible.

Issue: SPR-6847
2012-05-20 15:18:10 +03:00
Chris Beams 3fb11870d9 Polish async method execution infrastructure
In anticipation of substantive changes required to implement @Async
executor qualification, the following updates have been made to the
components and infrastructure supporting @Async functionality:

 - Fix trailing whitespace and indentation errors
 - Fix generics warnings
 - Add Javadoc where missing, update to use {@code} tags, etc.
 - Avoid NPE in AopUtils#canApply
 - Organize imports to follow conventions
 - Remove System.out.println statements from tests
 - Correct various punctuation and grammar problems
2012-05-20 15:17:28 +03:00
Stevo Slavic effb762558 Fix javadoc warnings
Before this change there were numerous javadoc warnings being reported
while building Spring framework API.

This commit resolves most of the javadoc warnings, reducing the total
number from 265 to 103.

Issue: SPR-9113
2012-04-30 11:31:02 +03:00
Chris Beams 5ea51f42fb Fix and refactor spring-aspects build
- Fix compileTestJava issue in which test classes were not being
   compiled or run

 - Use built-in eclipse.project DSL instead of withXml closure
   to add AspectJ nature and builder

 - Rename {aspectJ=>aspects}.gradle and format source
2012-01-31 14:37:12 +01:00
Chris Beams 6235a341a7 Remove bundlor support 2012-01-31 14:37:11 +01:00
Chris Beams 02a4473c62 Rename modules {org.springframework.*=>spring-*}
This renaming more intuitively expresses the relationship between
subprojects and the JAR artifacts they produce.

Tracking history across these renames is possible, but it requires
use of the --follow flag to `git log`, for example

    $ git log spring-aop/src/main/java/org/springframework/aop/Advisor.java

will show history up until the renaming event, where

    $ git log --follow spring-aop/src/main/java/org/springframework/aop/Advisor.java

will show history for all changes to the file, before and after the
renaming.

See http://chrisbeams.com/git-diff-across-renamed-directories
2012-01-31 14:37:10 +01:00