Commit Graph

255 Commits

Author SHA1 Message Date
Juergen Hoeller 16da15eca1 final preparations for 3.1.2 2012-07-06 22:48:43 +02:00
Juergen Hoeller c87989477d preparations for 3.1.2 2012-07-05 00:51:17 +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
Rossen Stoyanchev e8deba2915 Fix issue with encoded params in UriComponentsBuilder
The fromUri method of UriComponentsBuilder used uri.getXxx() methods,
which decode the URI parts causing URI parsing issues. The same method
now uses uri.getRawXxx().

Issue: SPR-9317
Backport-Issue: SPR-9549
Backport-Commit: a33fe6fa0a
2012-06-27 10:51:45 -04:00
Rossen Stoyanchev fa33c4b857 Update changelog 2012-06-26 18:03:32 -04:00
Rossen Stoyanchev 24c30eac49 Raise RestClientException for unknown status codes
HttpStatus cannot be created with an unknown status code. If a server
returns a status code that's not in the HttpStatus enum values, an
IllegalArgumentException is raised. Rather than allowing it to
propagate as such, this change ensures the actual exception raised is
a RestClientException.

Issue: SPR-9406
Backport-Issue: SPR-9502
2012-06-26 17:56:31 -04:00
Rossen Stoyanchev 9e370208d0 Fix content negotiation issue with sort by q-value
Before this fix the q-value of media types in the Accept header were
ignored when using the new RequestMappingHandlerAdapter in combination
with @ResponseBody and HttpMessageConverters.

Issue: SPR-9160
Backport-Issue: SPR-9168
Backport-Commit: 982cb2f258
2012-06-26 17:28:52 -04:00
Rossen Stoyanchev e66bc07c37 Translate EOF to HttpMessageNotReadableException
The MappingJacksonHttpMessageConverter now catches all IOException
types raised while reading JSON and translates them into
HttpMessageNotReadableException.

Issue: SPR-9238
Backport-Issue: SPR-9397
Backport-Commit: 816c1f47a4
2012-06-26 17:04:44 -04:00
Rossen Stoyanchev c9a2dbdbfd Add Jackson 2 HttpMessageConverter and View
Jackson 2 uses completely new package names and new maven artifact ids.
This change adds Jackson 2 as an optional dependency and also provides
MappingJackson2HttpMessageConverter and MappingJackson2JsonView for use
with the new version.

The MVC namespace and the MVC Java config detect and use
MappingJackson2HttpMessageConverter if Jackson 2 is present.
Otherwise if Jackson 1.x is present,
then MappingJacksonHttpMessageConverter is used.

Issue: SPR-9302
Backport-Issue: SPR-9507
Backport-Commit: e63ca04fdb
2012-06-26 16:52:51 -04:00
Rossen Stoyanchev 83ac44d1e4 Fix issue with parsing media types
Invalid Content-Type or Accept header values previously resulted in the
IllegalArgumentException getting propagated. After this change such
errors are detected and generally treated as a "no match", which
may for example result in a 406 in the case of the Accept header.

Issue: SPR-9142
Backport-Issue: SPR-9148
Backport-Commit: ca8b98e947
2012-06-26 13:55:05 -04:00
Juergen Hoeller bc243b5aa7 preparations for 3.1.2 release 2012-05-28 00:23:01 +02:00
Chris Beams 2fe74a4ef0 Eliminate INDEX.LIST from Spring jar META-INF dirs
The contents of this file could be problematic as they were generated
by spring-build with "org.springframework.core.jar" EBR-style naming,
but this naming is incorrect when dealing with Maven-central style
artifacts, e.g. spring-core.jar.

While a well-formed INDEX.LIST may speed up classloading, the simplest
solution to the issues listed below is simply to eliminate the file.
This also means consistent treatment across 3.1.x and 3.2.x artifacts,
as the new Gradle build in 3.2.x does not create these index files.

Issue: SPR-6383, SPR-9208
2012-04-13 16:58:26 +03:00
Juergen Hoeller c976fa329f initial fixes for 3.1.2 2012-03-14 16:18:06 +01:00
Juergen Hoeller ff862addbe final preparations for 3.1.1 release 2012-02-16 17:34:53 +01:00
Juergen Hoeller ab98f288e9 prepared for 3.1.1 release 2012-02-14 21:30:12 +01:00
Juergen Hoeller acaf820941 CustomSQLExceptionTranslatorRegistry/Registrar etc 2012-02-14 21:29:52 +01:00
Juergen Hoeller a46facc2f9 Hibernate 4.1 etc 2012-02-11 19:15:42 +01:00
Arjen Poutsma edc80ffa95 Use request contentType/encoding in ServletServetHttpRequest/Response
ServletServerHttpRequest now falls back on the contentType and the
the characterEncoding of the ServletRequest, if the headers of the
incoming request don't specify one. Similary ServletServerHttpResponse
sets the contentType and the characterEncoding of the ServletResponse
if not already set.

This allows using the CharacterEncodingFilter to set a character
encoding where the request doesn't specify one and have it be used
in HttpMessageConverter's.

SPR-9096
2012-02-09 12:34:27 -05:00
Juergen Hoeller e4f2cfe39e Provider injection etc 2012-02-08 17:53:15 +01:00
Rossen Stoyanchev 4f4a2e7fc7 Update documentation with regards to differences between @MVC 3.0/3.1
Although the reference documentation listed the new @MVC support
classes and their benefits, it did not explicitly mention a few
use cases that are no longer supported. There is now a specific
section on the new support classes listing exactly what is not
supported.

Similary the @RequestMapping annotation never refered explicitly
to the existence of old and new support and never made it clear
exactly what the differences are.

Both have not been corrected.

SPR-9063, SPR-9042
2012-02-07 19:49:44 -05:00
Juergen Hoeller 905d17d444 LocalContainerEntityManagerFactoryBean etc 2012-02-07 21:00:14 +01:00
Rossen Stoyanchev 871336a8c8 Better support for @SessionAttributes in clustered environments
A list of "known" session attributes (listed in @SessionAttributes)
was gradually built as attributes get added to the model. In a
failover scenario that knowledge is lost causing session attributes
to be potentially re-initialized via @ModelAttribute methods.

With this change @SessionAttributes listed by name are immediately
added to he list of "known" session attributes thus this knowledge
is not lost after a failover. Attributes listed by type however
still must be discovered as they get added to the model.
2012-02-03 12:23:24 -05:00
Rossen Stoyanchev 010abd06e3 SPR-9077 Remove empty path segments from input to UriComponentsBuilder. 2012-02-01 19:51:00 -05:00
Rossen Stoyanchev 64a69f7cf8 SPR-9079 Don't check for "POST" multipart request method arg resolvers 2012-02-01 13:22:12 -05:00
Rossen Stoyanchev 3d1fa4f6b6 SPR-9060 Revise HTTP Session based FlashMapManager implementation.
The "default" FlashMapManager implementation added in 3.1 was invoked
after the redirect, which is too late in cases where the HTTP session
has not been yet been created since as the response is committed.

This change corrects the issue and makes other improvements to the
FlashMapManager implementation such as extracting a base
AbstractFlashMapManager class and making it easier for other
implementations to be added (for example cookie-based).
2012-01-31 22:10:55 -05:00
Rossen Stoyanchev e9208981a6 SPR-9062 Fix bug with ambiguous path and HTTP method request mappings
A direct path match with incorrect HTTP request method was causing another
request mapping with a pattern and a correct HTTP method to be ignored.
The bug affects the new @MVC support classes
(i.e. RequestMappingHandlerMapping).
2012-01-30 19:52:20 -05:00
Rossen Stoyanchev 21966990c8 SPR-9016 Add flag to Redirectview to disable expanding URI vars 2012-01-30 18:39:20 -05:00
Rossen Stoyanchev bcd8355e61 SPR-8974 Fix regression in UriUtils.java 2012-01-19 23:47:31 -05:00
Juergen Hoeller 958bd49850 Hibernate 4 LocalSessionFactoryBean, etc 2012-01-15 20:09:35 +01:00
Rossen Stoyanchev 6da6acbe54 Make AbstractHandlerMethodExceptionResolver an abstract class. 2012-01-11 11:10:52 -05:00
Juergen Hoeller e208a2de5f JBoss AS 7, etc 2012-01-05 17:38:02 +01:00
Juergen Hoeller 3d5e245374 CacheNamespaceHandler etc 2011-12-22 15:54:17 +01:00
Juergen Hoeller 89ee5e2d80 DataBinder etc 2011-12-22 15:54:17 +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
Juergen Hoeller f1168ea453 DefaultPersistenceUnitManager etc 2011-12-22 13:31:09 +01:00
Juergen Hoeller 4b138e0e50 Hibernate etc 2011-12-22 13:31:08 +01:00
Juergen Hoeller 2caca29498 deprecated TopLinkJpaDialect, etc 2011-12-22 13:31:07 +01:00
Juergen Hoeller 1c9fe623f9 further post-GA fixes 2011-12-22 13:26:09 +01:00
Juergen Hoeller cc2e558fe0 prepared for 3.1.1 2011-12-22 13:19:18 +01:00
Juergen Hoeller 8f18337543 final preparations for 3.1 GA release 2011-12-12 23:38:05 +00:00
Juergen Hoeller dd7950638d MethodValidationPostProcessor, MappingJacksonMessageConverter, etc 2011-12-11 22:10:11 +00:00
Rossen Stoyanchev 6f150e4f07 SPR-8898 Allow match by trailing slash in RequestMappingHandlerMapping. 2011-12-08 03:38:50 +00:00
Juergen Hoeller 7428b57052 final refinements for 3.1 GA 2011-12-07 00:01:53 +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
Rossen Stoyanchev 4bfcb79ae3 SPR-8892 Add String constants to MediaType. 2011-12-02 18:58:41 +00:00
Juergen Hoeller 0ef3beb462 prepared for 3.1 GA 2011-12-01 18:52:12 +00:00
Juergen Hoeller 686ae8f7b3 final preparations for 3.1 RC2 release 2011-11-28 22:57:33 +00:00
Rossen Stoyanchev a9a068e678 SPR-8867 Fix issue with Content-Length header and UTF-8 charset.
The AbstractHttpMessageConverter was using the requested Content-Type
rather than the actual response Content-Type to determine the length
of the content. This can lead to a problem when a controller returns
a ResponseEntity with a Content-Type header that ignores (overrides)
the requested Content-Type. The fix ensures that actual response 
Content-Type is the one used both to write to the response and to 
determine the length of the content.
2011-11-28 18:42:57 +00:00
Rossen Stoyanchev 6eba6f2059 Document MVC Java config side-by-side with the MVC namespace. 2011-11-22 23:25:12 +00:00
Rossen Stoyanchev 60ee0bb8f4 SPR-8020 Support UriComponentsBuilder as a controller method argument.
The UriComponentsBuilder instance passed into the method is initialized
with current request information including host, scheme, port, context
path, and the servlet mapping's literal part.

Also added shortcut methods to buildAndExpand in UriComponentsBuilder.
2011-11-18 14:36:44 +00:00