Commit Graph

55 Commits

Author SHA1 Message Date
Chris Beams
2cfd15899d Fix split package introduced by @EnableSpringConfigured
Commit 6263c9abf9
@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
Backport-Commit: 54db7387de
2012-10-26 14:06:47 +02:00
Chris Beams
8bab873107 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-9443
Backport-Issue: SPR-6847
Backport-Commit: ed0576c181
2012-06-27 23:06:54 +02:00
Chris Beams
e8006bdf78 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

Issue: SPR-9443
Backport-Issue: SPR-6847
Backport-Commit: 3fb11870d9
2012-06-27 23:06:05 +02:00
Chris Beams
6263c9abf9 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.

Backporter's note: this change causes Bundlor warnings in
org.springframework.aspect as its manifest now "imports and exports the
package org.springframework.context.annotation". To 'solve' this
problem, `fail.on.warnings=false` has been added to build.properties.
This means that future Bundlor-based warnings may go unnoticed.

Issue: SPR-9442
Backport-Issue: SPR-9441
Backport-Commit: 5327a7a37d
2012-06-27 23:06:04 +02:00
Costin Leau
c39a14a130 Parse cache:annotation-driven key-generator attribute
Prior to this change, the spring-cache XSD allowed a 'key-generator'
attribute, but it was not actually parsed by AnnotationDrivenCacheBDP.

This commit adds the parsing logic as originally intended and the test
to prove it.

Issue: SPR-8939
2011-12-22 14:50:45 +01:00
Chris Beams
41c405998e Convert CRLF=>LF on files missed earlier
Complete pass with `dos2unix` found additional files missed on earlier
related commit.

Issue: SPR-5608
2011-12-22 14:06:44 +01:00
Chris Beams
88913f2b23 Convert CRLF (dos) to LF (unix)
Prior to this change, roughly 5% (~300 out of 6000+) of files under the
source tree had CRLF line endings as opposed to the majority which have
LF endings.

This change normalizes these files to LF for consistency going forward.

Command used:

$ git ls-files | xargs file | grep CRLF | cut -d":" -f1 | xargs dos2unix

Issue: SPR-5608
2011-12-21 14:52:47 +01:00
Costin Leau
312b1aa3d6 + add cache aspectj aspect 2011-12-08 13:20:01 +00:00
Costin Leau
f74789ffbe optimize AJ pointcut definition (SPR-8890) 2011-12-06 22:38:50 +00:00
Juergen Hoeller
5ab2bf16a5 fixed pointcut for type-level annotation to only apply to public methods (SPR-8890) 2011-12-06 21:14:31 +00:00
Juergen Hoeller
3a62aa053e fixed pointcut for type-level annotation to only apply to public methods (SPR-8890) 2011-12-06 21:03:57 +00:00
Juergen Hoeller
a347e4d3c2 optimized AnnotationTransactionAspect pointcut to avoid runtime checks (SPR-8890) 2011-12-06 20:48:49 +00:00
Costin Leau
1a2a3dd02a + update AJ tests 2011-12-06 14:13:29 +00:00
Costin Leau
cb3524ff30 + fix failing cache tests
+ renamed afterInvocation to beforeInvocation (and changed the docs and tests accordingly)
2011-12-06 14:05:33 +00:00
Costin Leau
d10f2258e8 + update aspectj cache aspects
+ update integration tests
2011-11-28 13:05:59 +00:00
Chris Beams
d35620511e Introduce @EnableSpringConfigured
Equivalent to <context:spring-configured/>.

Also update @EnableLoadTimeWeaving Javadoc and spring-configured XSD
documentation to reflect.

Issue: SPR-7888
2011-11-28 06:57:17 +00:00
Chris Beams
4318ccd9d5 Refactor BeanConfigurerTests
In preparation for the introduction of @EnableSpringConfigured

Issue: SPR-7888
2011-11-28 06:57:09 +00:00
Chris Beams
4f3cbb45f4 Introduce @EnableCaching
See EnableCaching Javadoc for details.

Issue: SPR-8312
2011-11-16 04:21:21 +00:00
Chris Beams
b7f9bf2e1c Polish cache Javadoc 2011-11-16 04:20:36 +00:00
Chris Beams
dacfa6993a Fix assignment error in AbstractAsyncExecutionAspect
Issue: SPR-8772
2011-10-17 18:35:27 +00:00
Costin Leau
d9de19d7b3 SPR-8653
+ refactor a bit the internals of CacheAspect to allow invocations that do not throw any exceptions (AspectJ)
2011-09-02 15:37:42 +00:00
Costin Leau
04bcd77520 + temporarily revert change 2011-09-02 08:25:39 +00:00
Costin Leau
ddfb2d3c58 + remove unneeded catch for exceptions inside AbstractCacheAspect.aj 2011-09-01 08:04:16 +00:00
Juergen Hoeller
79ed87e3d5 updated cache aspect after CacheAspectSupport base class changes 2011-07-22 10:12:07 +00:00
Chris Beams
3e5c6306be Polish @EnableAsync Javadoc and related XSD 2011-06-02 14:42:26 +00:00
Chris Beams
066daaf5be Polish @EnableTransactionManagement Javadoc and XSD 2011-06-02 14:29:06 +00:00
Costin Leau
b39673aa79 revised cache abstraction
- removed generics from Cache/CacheManager (they add no value since it's an SPI not API)
+ update docs and tests
+ renamed ConcurrentCacheFactoryBean to ConcurrentMapCacheFactoryBean
2011-05-18 18:34:41 +00:00
Costin Leau
dea1fc933f revise cache API
+ update failing AJ test
2011-05-17 17:35:01 +00:00
Costin Leau
0b917e3f9c revise cache API
- eliminate unneeded methods
+ introduced value wrapper (name still to be decided) to avoid cache race conditions
+ improved name consistency
2011-05-17 16:50:00 +00:00
Costin Leau
cc519e7c6d SPR-8334
+ commit missing configs
2011-05-13 15:59:22 +00:00
Chris Beams
01e5120a26 Introduce @EnableTransactionManagement 2011-05-06 19:10:25 +00:00
Chris Beams
de50789cb6 Introduce @EnableAsync
Introduce @EnableAsync#order

AsyncAnnotationBeanPostProcessor's 'order' property is now mutable;
@EnableAsync's 'order()' attribute allows for setting it, but must
have a default value, thus uses the new Ordered#NOT_ORDERED
constant - a reserved negative number very unlikely to be otherwise
used that may be interpreted as 'not ordered', useful in annotation
defaulting scenarios where null is not an option.

Introduce first working cut of AsyncConfiguration

Remove AsyncCapability
2011-05-06 19:08:53 +00:00
Costin Leau
08bccb28ae + revert back deleted resource 2011-03-06 18:19:19 +00:00
Costin Leau
4a589a78e1 + more configuration file 2011-03-06 17:14:10 +00:00
Costin Leau
c3a635196b SPR-8015
+ update default key generator strategy to improve compatibility for implicit declaration on one arg method
+ updated docs
2011-03-06 17:13:24 +00:00
Chris Beams
2f7c2230f0 Include license.txt and notice.txt in module JARs 2011-02-09 06:56:40 +00:00
Costin Leau
58633e4a89 SPR-7308
+ update AJ caching test
2010-12-16 21:25:12 +00:00
Costin Leau
85c02981b5 SPR-7308
+ initial commit of caching abstraction
+ main API
+ Spring AOP and AspectJ support
+ annotation driven, declarative support
+ initial namespace draft
2010-10-29 17:00:08 +00:00
Juergen Hoeller
577755d580 polishing 2010-10-20 05:51:51 +00:00
Juergen Hoeller
244c96151e added consistent license header 2010-10-20 05:19:17 +00:00
Juergen Hoeller
8c9b64c948 added mode="proxy"/"aspectj" and proxy-target-class options to task namespace; switched to concise names for async aspects 2010-10-15 20:50:23 +00:00
Juergen Hoeller
21d6883139 moved async aspect to aspectj sub-package 2010-10-13 21:06:38 +00:00
Juergen Hoeller
a6569a2930 moved async aspect to aspectj sub-package 2010-10-13 20:53:12 +00:00
Ramnivas Laddad
00984781af SPR-7369: @Async support in spring-aspects with AspectJ 2010-10-06 20:13:22 +00:00
Chris Beams
605ac0e230 Remove redundant @Aspect from CodeStyleAspect.aj
This has been present for quite some time, and compilation at the
command line was never a problem.  However, after upgrading to
STS 2.3.3.M2, errors started appearing in the Problems tab about
'duplicate @Aspect annotations'.  This message was a bit misleading
given that the underlying issue is that applying an @Aspect annotation
on an aspect declared in .aj style is redundant.  Andy Clement is
investigating as well, but for now the reason for the change in behavior
remains a mystery.
2010-07-21 19:18:11 +00:00
Ramnivas Laddad
f82cc6458b Fixed SPR-6734 by resticting record/replay logic to only entity methods that originated in a test method 2010-03-08 20:42:22 +00:00
Ramnivas Laddad
868cf09b2d Modified staticmethod mocking to remove compile-time dependency on JUnit (see ROO-314 and related issues) 2009-11-03 00:51:22 +00:00
Ramnivas Laddad
92d6dfbe8d Renamed static_mock package to staticmock 2009-10-28 01:23:43 +00:00
Ramnivas Laddad
66261ecb8c Moved over JPA exception translator from Roo 2009-10-27 19:15:54 +00:00
Ramnivas Laddad
dee410c0c4 Fixed test by moving Delegate to its own file 2009-10-27 17:38:50 +00:00