Commit Graph

10373 Commits

Author SHA1 Message Date
Sam Brannen
62d1b4b6e8 Document getAttributeAliasMap() in AnnotationUtils
This commit also introduces a cache for attribute alias metadata.

Issue: SPR-11512
2015-05-23 20:30:03 +02:00
Juergen Hoeller
92bf32b9be Polishing 2015-05-23 20:04:48 +02:00
Juergen Hoeller
e0a11f2ae7 SockJsTransportFailureException provides constructor variant without session id 2015-05-23 20:02:42 +02:00
Sam Brannen
f5e096e2a0 Document @AliasFor
Issue: SPR-11512
2015-05-23 19:52:03 +02:00
Sam Brannen
b9e13ea308 Align AnnotationAttributes.toString() with contract in Map 2015-05-23 18:25:50 +02:00
Sam Brannen
f380689230 Don't use Java 8's Method.getParameterCount() 2015-05-23 18:18:03 +02:00
Sam Brannen
1e50d8d5c2 Implement toString() for synthesized annotations
Issue: SPR-13064
2015-05-23 18:09:39 +02:00
Sam Brannen
ab92f4ed3a Document SynthesizedAnnotation support
Issue: SPR-11512
2015-05-23 01:01:39 +02:00
Juergen Hoeller
05d475a275 Polishing 2015-05-22 23:50:47 +02:00
Juergen Hoeller
5f60d700a1 Reordered Jackson initialization steps and restored HandlerInstantiator else block 2015-05-22 23:50:39 +02:00
Juergen Hoeller
41e4273a71 Upgrade to Jackson 2.6, JasperReports 6.1, OpenJPA 2.4 2015-05-22 23:50:31 +02:00
Juergen Hoeller
d7a361315f Added further core features to 4.2 section 2015-05-22 23:50:22 +02:00
Sam Brannen
57e765f9ca Document annotation improvements & @AliasFor in new-in-4.2 2015-05-22 23:46:28 +02:00
Sam Brannen
9983add0f5 Polish new-in-4.2 section 2015-05-22 23:01:28 +02:00
Sam Brannen
347264e4d9 Add "Testing Improvements" to new-in-4.2 section 2015-05-22 22:53:31 +02:00
Brian Clozel
9e6494eef6 Reinstate WebContentGenerator.checkAndPrepare variant
Reinstate a variant of the `WebContentGenerator.checkAndPrepare` method
for projects that are using it.

This variant is now marked as deprecated.

Issue: SPR-11792
2015-05-22 22:31:56 +02:00
Sam Brannen
bd787769be Introduce "synthesizable" cache in AnnotationUtils
Issue: SPR-11512
2015-05-22 21:40:36 +02:00
Sam Brannen
2e4dabb349 Polishing 2015-05-22 21:37:50 +02:00
Rossen Stoyanchev
bbd3f902d0 Fix failing tests 2015-05-22 14:14:20 -04:00
Rossen Stoyanchev
c48e8708a7 Fix NPE in DefaultSimpUserRegistry 2015-05-22 13:44:09 -04:00
Rossen Stoyanchev
92bd7bba50 Restore userSessionRegistry field in StompSubProtocolHandler
This change ensures that the deprecated UserSessionRegistry is still
used if configured.
2015-05-22 13:44:09 -04:00
Sam Brannen
3a2da3f701 Polish and reorganize new-in-4.2 section 2015-05-22 17:54:10 +02:00
Sam Brannen
73170224c9 Polish annotation utility tests 2015-05-22 17:46:34 +02:00
Andy Clement
91ed5b6b8c SpEL: ensure correct object used for nested #this references
Before this commit the object that #this would refer to in
nested expressions within projection/selection clauses was always
the root context object. This was incorrect as it should be the
element being projected/selected over. This commit introduces
a scope root context object which is set upon entering a new
scope (like when entering a projection or selection). Any
object. With this change this kind of expression now behaves:

where #this is the element of list1. Unqualified references
are also resolved against this scope root context object.

Issues: SPR-10417, SPR-12035, SPR-13055
2015-05-22 08:07:09 -07:00
Stephane Nicoll
5a3eea8adb Update what's new section 2015-05-22 16:54:14 +02:00
Sam Brannen
e7ea92561d Verify that SynthesizedAnnotation must be public
This commit introduces a test that will fail if SynthesizedAnnotation is
not public as is required by the contract for getProxyClass() in
java.lang.reflect.Proxy.

Issue: SPR-13057
2015-05-22 16:42:26 +02:00
Sam Brannen
ca09b1ff20 Introduce putIfAbsent() in AnnotationAttributes
Issue: SPR-13060
2015-05-22 15:52:49 +02:00
Rossen Stoyanchev
18946c829f Upgrade to Reactor 2.0.2 2015-05-22 09:24:02 -04:00
Rossen Stoyanchev
0db216daab Polish 2015-05-22 09:06:18 -04:00
Juergen Hoeller
fee63fdfb8 Message listener containers only call Session.recover() in client acknowledge mode
Issue: SPR-13056
2015-05-22 12:16:59 +02:00
Sebastien Deleuze
5255e7ae21 Support CompletableFuture in @MessageMapping handler methods
Issue: SPR-12207
2015-05-22 11:30:56 +02:00
Sebastien Deleuze
d3db99c201 Support ListenableFuture in @MessageMapping handler methods
This commit introduces support for asynchronous return values thanks
to the new AsyncHandlerMethodReturnValueHandler interface. Out of
the box support for ListenableFuture is also provided.

Issue: SPR-12168
2015-05-22 11:29:13 +02:00
Juergen Hoeller
792b7b9d11 ByteBufferConverter explicitly declares applicability to byte[]
Includes an optimization for simple ByteBuffer duplication.

Issue: SPR-13056
2015-05-22 11:19:17 +02:00
Stephane Nicoll
2dc674f356 Restore AbstractPropertyAccessor
Commit 3d86f15 added a lot of new feature in AbstractPropertyAccessor
shared by both DirectFieldAccessor and BeanWrapperImpl. This makes this
abstract class harder to implement for others having simpler use cases.

It turns that Spring Data has such use case; this commit split these new
features in a dedicated new base class, leaving AbstractPropertyAccessor
untouched.

Issue: SPR-12805
2015-05-22 10:33:28 +02:00
Stephane Nicoll
27c435c4ea Polish 2015-05-22 10:28:40 +02:00
Stephane Nicoll
39b2fbbccf Make SynthetizedAnnotation public
Enable public visibility on SynthetizedAnnotation to allow annotation
outside its package to be proxied properly. This commit is pending a
unit test that actually reproduces the problem.

Issue: SPR-13057
2015-05-22 10:21:23 +02:00
Sam Brannen
4549d76fbe Merge from sbrannen/SPR-11512
* SPR-11512:
  Support annotation attribute aliases and overrides via @AliasFor
2015-05-22 00:07:51 +02:00
Sam Brannen
ca66e076d1 Support annotation attribute aliases and overrides via @AliasFor
This commit introduces first-class support for aliases for annotation
attributes. Specifically, this commit introduces a new @AliasFor
annotation that can be used to declare a pair of aliased attributes
within a single annotation or an alias from an attribute in a custom
composed annotation to an attribute in a meta-annotation.

To support @AliasFor within annotation instances, AnnotationUtils has
been overhauled to "synthesize" any annotations returned by "get" and
"find" searches. A SynthesizedAnnotation is an annotation that is
wrapped in a JDK dynamic proxy which provides run-time support for
@AliasFor semantics. SynthesizedAnnotationInvocationHandler is the
actual handler behind the proxy.

In addition, the contract for @AliasFor is fully validated, and an
AnnotationConfigurationException is thrown in case invalid
configuration is detected.

For example, @ContextConfiguration from the spring-test module is now
declared as follows:

    public @interface ContextConfiguration {

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

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

        // ...
    }

The following annotations and their related support classes have been
modified to use @AliasFor.

- @ManagedResource
- @ContextConfiguration
- @ActiveProfiles
- @TestExecutionListeners
- @TestPropertySource
- @Sql
- @ControllerAdvice
- @RequestMapping

Similarly, support for AnnotationAttributes has been reworked to
support @AliasFor as well. This allows for fine-grained control over
exactly which attributes are overridden within an annotation hierarchy.
In fact, it is now possible to declare an alias for the 'value'
attribute of a meta-annotation.

For example, given the revised declaration of @ContextConfiguration
above, one can now develop a composed annotation with a custom
attribute override as follows.

    @ContextConfiguration
    public @interface MyTestConfig {

        @AliasFor(
           annotation = ContextConfiguration.class,
           attribute = "locations"
        )
        String[] xmlFiles();

        // ...
    }

Consequently, the following are functionally equivalent.

- @MyTestConfig(xmlFiles = "test.xml")
- @ContextConfiguration("test.xml")
- @ContextConfiguration(locations = "test.xml").

Issue: SPR-11512, SPR-11513
2015-05-22 00:01:07 +02:00
Stephane Nicoll
a87d5f8a63 Make PropertyMatches public
Issue: SPR-13054
2015-05-21 20:16:20 +02:00
Stephane Nicoll
6fb3190353 Fix regression with binding and validation
Previously, the binding may have to call the getter first to retrieve the
old value of a property before actually setting it. This was guarded by
a catch block that was accidentally removed in 3d86f15

Restore that catch block and add a test to cover it.

Issue: SPR-12805
2015-05-21 17:48:11 +02:00
Stephane Nicoll
2ab34373d1 Add possible matches for field access
DirectFieldAccessor now support richer NotWritablePropertyException
content, including dedicated error message and possible matches.

Issue: SPR-13053
2015-05-21 15:10:51 +02:00
Brian Clozel
4d5fca596d Fix directories I/O in ResourceHttpRequestHandler
Prior to this commit, the `ResourceHttpRequestHandler` would not
properly handle HTTP requests to **directories contained in JARs**.
This would result in HTTP 500 errors, caused by `FileNotFoundException`
or `NullPointerException`.

This can be tracked to webapp ClassLoader implementations in servlet
containers:
* in Jetty9x, fetching a directory within a JAR as a `Resource` and
getting its InputStream work fine, but attempting to `close()` it
results in a NullPointerException as the underlying stream is null.
* In Tomcat6x, one cannot fetch an InputStream for the same `Resource`
as it throws a FileNotFoundException.

This change adds more try/catch clauses and catches more Exception so as
to result in HTTP 200 OK responses instead of server errors. While this
is inconsistent because the same code path would result in HTTP 404 with
existing directories on the file system, there's no other simple way to
make those checks for resources contained in JARs.

Issue: SPR-12999
2015-05-21 14:30:12 +02:00
Stephane Nicoll
3d86f15a84 Merge BeanWrapperImpl and DirectFieldAccessor
`BeanWrapperImpl` and `DirectFieldAccessor` are two
`ConfigurablePropertyAccessor` implementations with different features
set.

This commit harmonizes the two implementations to use a common base class
that delegates the actual property handling to the sub-classes:

* `BeanWrapperImpl`:  `PropertyDescriptor` and introspection utilities
* `DirectFieldAccessor`: reflection on `java.lang.Field`

Issues: SPR-12206 - SPR-12805
2015-05-21 13:49:55 +02:00
Rossen Stoyanchev
ad4c8795ae Include only path in <spring:mvcUrl>
Issue: SPR-13045
2015-05-20 17:06:47 -04:00
Rossen Stoyanchev
af67bd944b Add 4.2 section to the reference 2015-05-20 16:43:01 -04:00
Rossen Stoyanchev
1ba0625cd9 Add baseUrl to DefaultUriTemplateHandler
Issue: SPR-13035
2015-05-20 15:12:32 -04:00
Stephane Nicoll
01d1e71d66 Merge pull request #801 from echatman/patch-1
* patch-1:
  Fix number parsing of @Scheduled attributes
2015-05-20 20:46:53 +02:00
Elizabeth Chatman
5652f02af0 Fix number parsing of @Scheduled attributes
See gh-801
2015-05-20 20:41:29 +02:00
Stephane Nicoll
0ed9ca097b Customize destruction callback for AutoCloseable beans
Previously, a Bean implementing `AutoCloseable` (or `Closeable`) was
always destroyed regardless of its bean definition. In particular, the
documented way of disabling the destruction callback via an empty String
did not work.

AutoCloseable beans are now treated pretty much as any other bean: we
still use the presence of the interface to optimize the check of a
destroy method and we only auto-discover the method name to invoke if
the inferred mode is enabled.

Issue: SPR-13022
2015-05-20 17:19:42 +02:00
Juergen Hoeller
271804f105 Polishing 2015-05-20 15:35:11 +02:00