Commit Graph

823 Commits

Author SHA1 Message Date
Juergen Hoeller f58e1db2e6 Explicit notes for @Bean on static methods, private methods, and Java 8 default methods
Also includes an explicit note on stop vs destroy callbacks for Lifecycle beans.

Issue: SPR-13118
Issue: SPR-12882
Issue: SPR-12345
Issue: SPR-11671
2015-07-07 16:49:26 +02:00
Juergen Hoeller ca3ba7deb5 Extended/BindingAwareModelMap are not meant to be referred to in user code
Issue: SPR-12896
2015-07-07 16:44:46 +02:00
Sam Brannen 27d1ce84a3 Polishing 2015-06-20 01:45:46 +02:00
Sam Brannen fb83e83e78 Honor contract of @Repeatable in AnnotationUtils
Prior to this commit, the implementation of getRepeatableAnnotation()
in Spring's AnnotationUtils complied neither with the contract of
getAnnotationsByType() nor with the contract of
getDeclaredAnnotationsByType() as defined in AnnotatedElement in Java 8.

Specifically, unexpected results can be encountered when using Spring's
support for @Repeatable annotations: either annotations show up in the
returned set in the wrong order, or annotations are returned in the set
that should not even be found based on the semantics of @Repeatable.

This commit remedies this problem by deprecating the existing
getRepeatableAnnotation() methods and replacing them with new
getRepeatableAnnotations() and getDeclaredRepeatableAnnotations()
methods that comply with the contracts of Java's getAnnotationsByType()
and getDeclaredAnnotationsByType(), respectively.

Issue: SPR-13068
2015-06-20 01:21:39 +02:00
Sam Brannen 6c530b7bfb Delete trailing whitespace in XML files 2015-06-19 17:14:10 +02:00
Juergen Hoeller f1c7dc4f4b Introduced SimpleTransactionScope (analogous to SimpleThreadScope)
Issue: SPR-13085
2015-06-18 00:29:46 +02:00
Juergen Hoeller d7f8fa50be Polishing 2015-06-16 22:01:58 +02:00
Juergen Hoeller 92f1754b1e Fixed fallback mode in ObjenesisCglibAopProxy, plus consistent support for bypassing Objenesis (e.g. on Google App Engine)
This 4.2 commit revises SpringObjenesis towards a smart delegate, including support for a "spring.objenesis.ignore" system property.

Issue: SPR-13131
2015-06-16 22:01:37 +02:00
Stephane Nicoll 75c88ffbeb Remove deprecated warnings 2015-06-16 15:23:56 +02:00
Juergen Hoeller c41779f895 AsyncExecutionInterceptor supports Java 8's CompletableFuture as a return type
Issue: SPR-13128
2015-06-15 20:35:48 +02:00
Juergen Hoeller 06a5ed9cae AbstractApplicationContext resets common introspection caches after refresh
Issue: SPR-13093
2015-06-15 20:34:46 +02:00
Juergen Hoeller 10cb80a500 Removed superfluous @Ignore import
Issue: SPR-11807
2015-06-15 15:57:10 +02:00
Juergen Hoeller 1c01f575c2 ConfigurationClassParser ignores unresolvable member classes
Issue: SPR-13115
2015-06-15 15:46:14 +02:00
Stephane Nicoll 95acf8c989 Remove references to codehaus.org
Issue: SPR-13129
2015-06-15 15:44:29 +02:00
Sam Brannen 32c17bf540 Revise method and parameter names in annotation support
In AnnotatedElementUtils, all methods pertaining to merging annotation
attributes have been renamed to "getMerged*()" and "findMerged*()"
accordingly. Existing methods such as getAnnotationAttributes(..) have
been deprecated in favor of the more descriptive "merged" variants.
This aligns the naming conventions in AnnotatedElementUtils with those
already present in AnnotationReadingVisitorUtils.

The use of "annotationType" as a variable name for the fully qualified
class name of an annotation type has been replaced with
"annotationName" in order to improve the readability and intent of the
code base.

In MetaAnnotationUtils.AnnotationDescriptor, getMergedAnnotation() has
been renamed to synthesizeAnnotation(), and the method is now
overridden in UntypedAnnotationDescriptor to always throw an
UnsupportedOperationException in order to avoid potential run-time
ClassCastExceptions.

Issue: SPR-11511
2015-06-14 00:34:40 +02:00
Sam Brannen 60cdfa535e Polish ComponentScanParserScopedProxyTests 2015-06-13 16:09:03 +02:00
Sam Brannen 2d23f42609 Introduce alias for 'value' attribute in @Scope
Issue: SPR-11393
2015-06-13 16:07:29 +02:00
Juergen Hoeller 75edb3979e AspectJExpressionPointcut defensively catches exceptions thrown from ShadowMatch.matchesJoinPoint
Issue: SPR-13102
2015-06-11 14:44:19 +02:00
Juergen Hoeller e97506be55 Member classes get exposed to the import stack now
Issue: SPR-13101
2015-06-11 09:56:03 +02:00
Juergen Hoeller b02352d30f Enabled test for AspectJ pointcut matching against lambda-defined bean
Issue: SPR-11807
2015-06-10 15:03:06 +02:00
Stephane Nicoll b87816ed20 Add ResolvableTypeProvider
Provide a mean to detect the actual ResolvableType based on a instance as
a counter measure to type erasure.

Upgrade the event infrastructure to detect if the event (or the payload)
implements such interface. When this is the case, the return value of
`getResolvableType` is used to validate its generic type against the
method signature of the listener.

Issue: SPR-13069
2015-06-09 10:57:31 +02:00
Stephane Nicoll e8441edcb7 Remove commons pool 2.x workaround
While working on SPR-12532, an extra IdentityWrapper was added to work
around a backward compatible issue between commons pool 1.x and 2.x. This
issue (POOL-283) has actually been fixed in 2.4 and their IdentityWrapper
is using object equality so our wrapper is in the way.

Looking retrospectively, the code looks all fine without the workaround
and commons pool 2.4 or later so it has been removed.
2015-06-05 16:41:21 +02:00
Juergen Hoeller 869b0bc7ee Create enhanced FactoryBean instance before applying method interceptor (preferably via Objenesis)
Also removes "throws Exception" declaration from ThreadPoolExecutorFactoryBean's getObject method.

Issue: SPR-13095
2015-06-05 00:09:42 +02:00
Juergen Hoeller d195ad216a Polishing 2015-06-04 23:27:40 +02:00
Juergen Hoeller 9410dff99c AsyncResult allows for exposing an execution exception
Issue: SPR-13076
2015-06-04 23:25:18 +02:00
Sam Brannen 0db948e72d Polish Javadoc for @Scope 2015-06-04 15:42:15 -04:00
Sam Brannen ff8597fa80 Introduce alias for 'value' attribute in @ComponentScan.Filter
Issue: SPR-11393
2015-06-04 15:25:20 -04:00
Sam Brannen 39e820b4bf Polish Javadoc for @ComponentScan 2015-06-04 15:20:37 -04:00
Sam Brannen d4ee75ddf0 Log correct class name for introspection failure
Issue: SPR-13091
2015-06-03 21:31:12 -04:00
Sam Brannen d3b5aeb768 Introduce alias for 'value' attribute in @ImportResource
Issue: SPR-11393
2015-06-03 21:26:43 -04:00
Sam Brannen e5dc6e964c Introduce getAliasedStringArray() in AnnotationAttributes
Issue: SPR-11393
2015-06-03 21:26:43 -04:00
Stephane Nicoll 08c032d9fd Allow Cache annotations to not specify any cache name
Since Spring 4.1, a CacheResolver may be configured to customize the way
the cache(s) to use for a given cache operation are retrieved. Since a
CacheResolver implementation may not use the cache names information at
all, this attribute has been made optional.

However, a fix was still applied, preventing a Cache operation without a
cache name to be defined properly. We now allow this valid use case.

Issue: SPR-13081
2015-06-03 11:42:49 +02:00
Juergen Hoeller 4f1286a4c3 Lite configuration candidate check defensively handles method introspection failure
Issue: SPR-13091
2015-06-02 14:18:00 +02:00
Juergen Hoeller 11401bd5e4 Upgrade to Hibernate ORM 5.0 RC1 and Hibernate Validator 5.2 RC1
Includes other recent dependency updates (JRuby 1.7.20, Jetty 9.2.11, Tomcat 8.0.23, Reactor 2.0.3)

Issue: SPR-13088
2015-06-01 18:35:57 +02:00
Sam Brannen 81844191f8 Polish Javadoc for @ImportResource 2015-05-31 23:06:15 +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 de06f422f3 Polish Javadoc for caching annotations 2015-05-31 22:51:53 +02:00
Sam Brannen 845f4f2bb7 Improve attribute alias support in @ComponentScan
Prior to this commit, @ComponentScan already had a value/basePackages
alias pair; however, the semantics were not properly enforced.

This commit addresses this issue by refactoring
ComponentScanAnnotationParser to ensure that it is not possible to
declare both of the aliased attributes. In addition, the 'value' and
'basePackages' attributes are now annotated with @AliasFor in order to
make the semantics clearer.

Issue: SPR-11393
2015-05-31 15:39:15 +02:00
Sam Brannen 94aa90646b Polish Javadoc for @ComponentScan 2015-05-31 15:32:56 +02:00
Sam Brannen e30c9b2ef3 Synthesize annotation from a map of attributes
Spring Framework 4.2 RC1 introduced support for synthesizing an
annotation from an existing annotation in order to provide additional
functionality above and beyond that provided by Java. Specifically,
such synthesized annotations provide support for @AliasFor semantics.
As luck would have it, the same principle can be used to synthesize an
annotation from any map of attributes, and in particular, from an
instance of AnnotationAttributes.

The following highlight the major changes in this commit toward
achieving this goal.

- Introduced AnnotationAttributeExtractor abstraction and refactored
  SynthesizedAnnotationInvocationHandler to delegate to an
  AnnotationAttributeExtractor.

- Extracted code from SynthesizedAnnotationInvocationHandler into new
  AbstractAliasAwareAnnotationAttributeExtractor and
  DefaultAnnotationAttributeExtractor implementation classes.

- Introduced MapAnnotationAttributeExtractor for synthesizing an
  annotation that is backed by a map or AnnotationAttributes instance.

- Introduced a variant of synthesizeAnnotation() in AnnotationUtils
  that accepts a map.

- Introduced findAnnotation(*) methods in AnnotatedElementUtils that
  synthesize merged AnnotationAttributes back into an annotation of the
  target type.

The following classes have been refactored to use the new support for
synthesizing AnnotationAttributes back into an annotation.

- ApplicationListenerMethodAdapter
- TestAnnotationUtils
- AbstractTestContextBootstrapper
- ActiveProfilesUtils
- ContextLoaderUtils
- DefaultActiveProfilesResolver
- DirtiesContextTestExecutionListener
- TestPropertySourceAttributes
- TestPropertySourceUtils
- TransactionalTestExecutionListener
- MetaAnnotationUtils
- MvcUriComponentsBuilder
- RequestMappingHandlerMapping

In addition, this commit also includes changes to ensure that arrays
returned by synthesized annotations are properly cloned first.

Issue: SPR-13067
2015-05-29 01:38:51 +02:00
Juergen Hoeller c622f4c487 Polishing 2015-05-23 22:24:10 +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
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