Commit Graph

782 Commits

Author SHA1 Message Date
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
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
Juergen Hoeller de893ada2b Compatibility with JSR-354 final (and its new Monetary singleton)
Includes support for currency detection with @NumberFormat.

Issue: SPR-12209
2015-05-20 15:15:29 +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
Juergen Hoeller 6418b54f81 DataBinder tries ConversionService if PropertyEditor could not produce required type
Issue: SPR-13042
2015-05-18 23:53:39 +02:00
Sam Brannen 03ade48d68 Expound on inheritance semantics for @Conditional
Issue: SPR-11598
2015-05-13 16:06:36 +02:00
Juergen Hoeller ef7cf2c650 Revised description of event source parameter
Issue: SPR-13021
2015-05-13 14:58:02 +02:00
Juergen Hoeller 02da2e85ee DataBinder allows for adding custom Formatters as alternative to PropertyEditors (including per-field formatters)
Includes a generic FormatterPropertyEditorAdapter plus Number conversion support in TypeConverterDelegate.

Issue: SPR-7773
Issue: SPR-6069
2015-05-12 22:33:18 +02:00
Juergen Hoeller 64a01d64c5 Polishing 2015-05-11 14:42:45 +02:00
Philippe Marschall 994d86992c Avoid eager formatting in pre-condition checks
In general, the Spring Framework aims to construct error message
strings only if an actual error has occurred. This seems to be the
common pattern in the codebase and saves both CPU and memory. However,
there are some places where eager error message formatting occurs
unnecessarily.

This commit addresses this issue in the following classes:
AdviceModeImportSelector, AnnotationAttributes, and
ReadOnlySystemAttributesMap.

The change in ReadOnlySystemAttributesMap also avoids a potential
NullPointerException.

Issue: SPR-13007
2015-05-10 12:36:01 +02:00
Juergen Hoeller 1722fa6678 JSR-223 based StandardScriptFactory (including <lang:std> support)
This commit also completes 4.2 schema variants in spring-context.

Issue: SPR-5215
2015-05-08 23:56:08 +02:00
Sam Brannen 4bf32578b5 Rename MethodBasedEvaluationContextTest to *Tests 2015-05-08 18:44:49 +02:00
Juergen Hoeller dbd82d128d Polishing 2015-05-07 20:18:17 +02:00
Juergen Hoeller e87dc9f82d Test for AspectJ pointcuts with lambdas (currently marked as ignored)
Issue: SPR-11807
2015-05-07 19:59:54 +02:00
Juergen Hoeller 1cc042d4c7 Polishing 2015-05-07 16:03:15 +02:00
Sam Brannen 7a690df925 Remove trailing whitespace from Java source code 2015-05-06 20:08:42 +02:00
Sam Brannen 2015781ea1 Rename duplicate EnvironmentIntegrationTests to EnvironmentSystemIntegrationTests 2015-05-06 15:55:20 +02:00
Stephane Nicoll b8f10f69a9 Fix binary compatibility for SmartApplicationListener
Making sure that `GenericApplicationListenerAdapter` implements
`SmartApplicationListener` again as older code may try to cast an
instance to `SmartApplicationListener`.

Issue: SPR-8201
2015-05-06 08:52:47 +09:00
Sam Brannen 572cbb0821 Consistently supply test name to @Parameters 2015-05-05 14:07:00 +02:00
Juergen Hoeller 706d3adf07 Consistently throw IllegalStateException from getAutowireCapableBeanFactory()
Issue: SPR-12932
2015-04-24 23:20:43 +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 e0d2dbd21d Polish Javadoc & TODOs in ApplicationListenerMethodAdapter
Issue: SPR-12738
2015-04-23 01:33:47 +02:00
Sam Brannen 86733a98da Polish ApplicationListenerMethodAdapter 2015-04-22 02:54:23 +02:00
Juergen Hoeller 9ed0a56d84 AbstractApplicationContext collects early ApplicationEvents and publishes them once the multicaster is available
Issue: SPR-12902
2015-04-16 18:16:15 +02:00
Juergen Hoeller aa49949d7a Bean type mismatch check accepts assignable values according to ClassUtils
Issue: SPR-12905
2015-04-16 18:15:33 +02:00
Juergen Hoeller e403aefe86 Proper exception in case of an @Bean method call encountering a bean type mismatch
Issue: SPR-12905
2015-04-15 23:37:51 +02:00
Juergen Hoeller 1da98b0542 @Bean-returned FactoryBean proxy delegates to actual target instance now
Issue: SPR-12915
2015-04-15 22:49:53 +02:00
Sam Brannen 96e6406b4b Clarify semantics for multiple profiles in @Profile 2015-04-15 21:56:31 +02:00
Juergen Hoeller fafb823e8d Polishing 2015-04-15 15:13:42 +02:00
Stephane Nicoll e5b505224b Improve exception message
Issue: SPR-12898
2015-04-10 09:20:51 +02:00
Stephane Nicoll 6bc14cc7ae Add cache-related logs
Add a trace log for cache hit and cache miss events.

Issue: SPR-11654
2015-04-07 14:27:43 +02:00
Juergen Hoeller 595cdf05e9 Polishing 2015-04-04 00:23:25 +02:00
Juergen Hoeller e1395a6c68 Avoid repeated exposure of SpringProxy/Advised for fallback interfaces as well
Issue: SPR-12870
2015-04-01 18:54:47 +02:00
Juergen Hoeller 2c637dcb2e ReaderEditor supports Reader injection analogous to InputStreamEditor (from Spring resource location)
Also, EncodedResource implements InputStreamSource now since it declares getInputStream() anyway.

Issue: SPR-12876
2015-04-01 17:02:55 +02:00
Juergen Hoeller ceb17fcaca CronSequenceGenerator explicitly rejects invalid incrementer delta
Issue: SPR-12871
2015-04-01 16:45:24 +02:00
Juergen Hoeller f9c2d1d171 DefaultAopProxyFactory falls back to JdkDynamicAopProxy when encountering JDK proxy as target
Issue: SPR-12870
2015-03-31 16:15:22 +02:00
Juergen Hoeller a15dc08bea @Import allows for importing regular component classes as well
Issue: SPR-11740
2015-03-31 11:39:20 +02:00
Juergen Hoeller 14c891c3b3 MethodValidationPostProcessor provides protected createMethodValidationAdvice template method
Issue: SPR-12863
2015-03-31 10:12:35 +02:00
Juergen Hoeller 7e22623758 Clarification: Lifecycle does not imply auto-startup semantics
Issue: SPR-12855
2015-03-30 21:06:12 +02:00
Juergen Hoeller beae336627 Polishing 2015-03-25 15:22:41 +01:00
Stephane Nicoll 314b069fd8 Only require an exception CacheResolver if necessary
Previously, a cache infrastructure with only a CacheResolver would have
worked fine until the JSR-107 API is added to the classpath. When this is
the case, the JCache support kicks in and an exception cache resolver is
all of the sudden required.

The CacheResolver _is_ different as the default implementation does look
different attributes so if a custom CacheResolver is set, it is not
possible to "reuse" it as a fallback exception CacheResolver.

Now, an exception CacheResolver is only required if a JSR-107 annotation
with an "exceptionCacheName" attribute is processed (i.e. the exception
CacheResolver is lazily instantiated if necessary).

The use case of having a CachingConfigurerSupport with only a
CacheResolver was still broken though since the JCache support only looks
for a JCacheConfigurer bean (per the generic type set on
AbstractCachingConfiguration). This has been fixed as well.

Issue: SPR-12850
2015-03-25 15:12:08 +01:00
Juergen Hoeller d23893fd25 Consistent javadoc param declarations for type variables 2015-03-25 00:44:01 +01:00
Juergen Hoeller b2308926bc Restored isTypeMatch null behavior and refined typeToMatch parameter name
Issue: SPR-12147
2015-03-23 21:57:03 +01:00
Juergen Hoeller 1a8c6fa5ee Deferred import processing reliably detects late registration attempts
Issue: SPR-12838
2015-03-23 19:58:02 +01:00
Juergen Hoeller 192462902e Consistent support for Java 8 default methods (in interfaces implemented by user classes)
Covers ReflectionUtils.doWithMethods as well as affected annotation post-processors.
Includes an extension of MethodMetadata for the detection of @Bean default methods.

Issue: SPR-12822
Issue: SPR-10919
2015-03-19 16:50:15 +01:00
Juergen Hoeller 778a01943b ResolvableType-based type matching at the BeanFactory API level
Issue: SPR-12147
2015-03-18 23:05:13 +01:00