Commit Graph

811 Commits

Author SHA1 Message Date
Juergen Hoeller 7987f80866 GenericConversionService uses ConcurrentReferenceHashMap instead of ConcurrentHashMap
Issue: SPR-13099
2015-06-15 15:55:53 +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 31c547456a Introduce getAliasedString() in AnnotationAttributes
Issue: SPR-11393
2015-06-12 21:09:33 +02:00
Sam Brannen 05de9a8c4a Introduce general purpose isEmpty() method in ObjectUtils
Prior to this commit, there existed several isEmpty() methods scattered
across various utilities such as ObjectUtils, CollectionUtils, and
StringUtils; however, each of these methods requires a cast to the type
supported for that particular variant.

This commit introduces a general-purpose isEmpty(Object) method in
ObjectUtils that transparently supports multiple object types in a
central location without the need for casts or juggling multiple
utility classes.

Issue: SPR-13119
2015-06-12 19:19:22 +02:00
Sam Brannen e7f4544248 Polish ObjectUtilsTests 2015-06-12 19:19:22 +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
Sam Brannen 384ee69300 Introduce getAliasedClassArray() in AnnotationAttributes
Issue: SPR-11393
2015-06-04 15:23:53 -04:00
Sam Brannen e5dc6e964c Introduce getAliasedStringArray() in AnnotationAttributes
Issue: SPR-11393
2015-06-03 21:26:43 -04:00
izeye b8d7d46da7 Fix typo 2015-06-01 09:21:38 +02:00
Sam Brannen 518c85b107 Support synthesized annotations in MethodParameter 2015-05-29 22:48:55 +02:00
Sam Brannen 1afc938da1 Introduce synthesizeAnnotationArray() in AnnotationUtils 2015-05-29 22:45:34 +02:00
Sam Brannen 9f717871e6 Introduce getAnnotation() in AnnotatedElementUtils
This commit introduces a "synthesized annotation" alternative to
getAnnotationAttributes() in AnnotatedElementUtils, analogous to the
recently introduced findAnnotation() methods.

Issue: SPR-13082
2015-05-29 22:04:10 +02:00
Sam Brannen 9afcd17c71 Introduce getAnnotationAttributes(..,Class) in AnnoElUtils 2015-05-29 21:36:00 +02:00
Sam Brannen 46be176875 Allow AnnoConfigEx to propagate from getRepeatableAnnotation()
Issue: SPR-13084
2015-05-29 21:17:33 +02:00
Sam Brannen 7018747cec Remove trailing whitespace in Java source code 2015-05-29 02:03:44 +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
Sam Brannen f41de12cf6 Ensure synthesized nested annotation arrays retain correct type
Prior to this commit, when a nested array of annotations was
synthesized while adapting values within an AnnotationAttributes map,
the array was improperly replaced with an array of type Annotation[]
instead of an array of the concrete annotation type, which can lead to
unexpected run-time exceptions.

This commit fixes this bug by replacing annotations in the existing
array with synthesized versions of those annotations, thereby retaining
the original array's component type.

Issue: SPR-13077
2015-05-27 17:55:10 +02:00
Sam Brannen a2f152ce8b Support nested annotations in AnnotationAttributes
This commit introduces support in AnnotationAttributes for retrieving
nested annotations that is on par with the existing type-safe support
for retrieving nested AnnotationAttributes.

Issue: SPR-13074
2015-05-27 17:03:01 +02:00
Sam Brannen 0ac0e2ce20 Document public API in AnnotationAttributes
AnnotationAttributes has existed for several years, but none of the
"get" methods that make up its public API are documented. In many
cases, the behavior can be inferred from the name of the method, but
for some methods there are "hidden gems" and unexpected behavior
lurking behind the scenes.

This commit addresses this issue by documenting all public methods. In
addition, the hidden support for converting single elements into
single-element arrays has also been documented and tested.

Issue: SPR-13072
2015-05-27 16:15:25 +02:00
Sam Brannen 197f6594f4 Simplify annotation attribute override algorithm
Issue: SPR-11513
2015-05-24 17:59:30 +02:00
Sam Brannen c80932490f Complete documentation of synthesized annotations
Issue: SPR-11512
2015-05-24 16:42:09 +02:00
Sam Brannen b6f2d95c3e Cache computed values in SynthesizedAnnotationInvocationHandler
Issue: SPR-11512
2015-05-24 15:58:20 +02:00
Sam Brannen 8ecae8697a Cache attribute methods in AnnotationUtils
Issue: SPR-11512
2015-05-24 15:58:20 +02:00
Sam Brannen d5974a18ab Polish AnnotationUtils 2015-05-24 15:58:19 +02:00
Sam Brannen a1fc2097a1 Document SynthesizedAnnotationInvocationHandler constructor
Issue: SPR-11512
2015-05-24 15:58:07 +02:00
Sam Brannen c13f689537 Document isSynthesizable() in AnnotationUtils
Issue: SPR-11512
2015-05-24 00:13:53 +02:00
Sam Brannen 7f22f09890 PolishingPolish SynthesizedAnnotationInvocationHandler 2015-05-23 23:58:35 +02:00
Sam Brannen def7663ec4 Implement hashCode() for synthesized annotations
Issue: SPR-13066
2015-05-23 23:46:48 +02:00
Sam Brannen ae5c8285a6 Polish SynthesizedAnnotationInvocationHandler 2015-05-23 22:40:05 +02:00
Sam Brannen 7e2e9a80d0 Document getAttributeMethods() in AnnotationUtils
Issue: SPR-11512
2015-05-23 22:29:12 +02:00
Sam Brannen 7bf609f111 Implement equals() for synthesized annotations
Issue: SPR-13065
2015-05-23 22:29:12 +02:00
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
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
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
Sam Brannen 73170224c9 Polish annotation utility tests 2015-05-22 17:46:34 +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
Sebastien Deleuze 5255e7ae21 Support CompletableFuture in @MessageMapping handler methods
Issue: SPR-12207
2015-05-22 11:30:56 +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 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 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
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 008c9a3b45 Test for ByteBuffer-to-ByteBuffer conversion (fresh copy)
ByteBufferConverter also defensively returns the rewind result now.

Issue: SPR-13031
2015-05-18 16:17:11 +02:00
Juergen Hoeller 1e7d954fcb MethodMetadata exposes method return type
Issue: SPR-13024
2015-05-18 16:16:58 +02:00
Stephane Nicoll 0612bc7bc5 Harmonize default converters
Provide Converter implementations for Charset, Currency and TimeZone as
related PropertyEditors are available for those.

Issue: SPR-13020
2015-05-15 15:23:57 +02:00
Sam Brannen 477d4c5126 Document "present" terminology in AnnotationUtils
Prior to this commit, the documentation in AnnotationUtils was
inconsistent, and at times even misleading, with regard to finding
annotations that are "present" or "directly present" on annotated
elements.

This commit defines the terminology used within AnnotationUtils and
introduces the explicit notion of "meta-present" to denote that
annotations are present within annotation hierarchies above annotated
elements.

Issue: SPR-13030
2015-05-14 21:25:54 +02:00
Sam Brannen ebed52cc22 Favor local, composed annotations in AnnotatedElementUtils
This commit updates the "get semantics" search algorithm used in
`AnnotatedElementUtils` so that locally declared 'composed annotations'
are favored over inherited annotations.

Specifically, the internal `searchWithGetSemantics()` method now
searches locally declared annotations before searching inherited
annotations.

All TODOs in `AnnotatedElementUtilsTests` have been completed, and all
ignored tests have been reinstated.

Issue: SPR-11598
2015-05-13 16:06:36 +02:00
Juergen Hoeller 0711d6d0df Polishing 2015-05-13 15:04:26 +02:00
Juergen Hoeller e83d495cbb SimpleAliasRegistry prevents NPE for alias resolved to null
Issue: SPR-13016
2015-05-12 22:04:44 +02:00
Sam Brannen 52153bd454 Document search scope in Ann*[Element]Utils
This commit improves the documentation for AnnotationUtils and
AnnotatedElementUtils by explaining that the scope of most annotation
searches is limited to finding the first such annotation, resulting in
additional such annotations being silently ignored.

Issue: SPR-13015
2015-05-12 21:06:27 +02:00
Juergen Hoeller 00147379f9 Polishing
(cherry picked from commit 9e925aa)
2015-05-11 22:22:23 +02:00
Juergen Hoeller 64a01d64c5 Polishing 2015-05-11 14:42:45 +02:00
Sam Brannen fcf75c90b1 Fix broken AnnotationAttributesTests
Issue: SPR-13007
2015-05-10 13:10:04 +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 1e046435ab AntPathMatcher actually throws IllegalArgumentException if patterns cannot be combined
Issue: SPR-12998
2015-05-09 15:29:33 +02:00
Sam Brannen 04d6afe54d Support arbitrary levels of meta-annotations in TypeDescriptor
Prior to this commit, the `getAnnotation()` method in `TypeDescriptor`
only supported a single level of meta-annotations. In other words, the
annotation hierarchy would not be exhaustively searched.

This commit provides support for arbitrary levels of meta-annotations
in `TypeDescriptor` by delegating to `AnnotationUtils.findAnnotation()`
within `TypeDescriptor.getAnnotation()`.

Issue: SPR-12793
2015-05-08 16:05:18 +02:00
Sam Brannen 5f03c97295 Polish Javadoc for MethodParameter 2015-05-08 16:03:55 +02:00
Sam Brannen 638926be4f Use JUnit ExpectedException rule in AntPathMatcherTests 2015-05-08 14:37:15 +02:00
Sam Brannen c7cdbe126d Introduce failing test case in AntPathMatcherTests
Issue: SPR-12998
2015-05-08 14:31:21 +02:00
Arjen Poutsma 76beb36e4b Remove duplicate separators when combining paths
Prior to this commit, AntPathMatcher would not correctly combine a path
that ends with a separator with a path that starts with a separator.
For example, `/foo/` + `/bar` combined into `/foo//bar`.

Specifically, this commit:

 - Removes the duplicated separator in combined paths

 - Improves RequestMappingInfo's toString() representation

 - Fixes Javadoc formatting in AntPathMatcher

 - Polishes AntPathMatcherTests

 - Polishes Javadoc in AbstractRequestCondition

Issue: SPR-12975
2015-05-08 13:49:34 +02:00
Juergen Hoeller dbd82d128d Polishing 2015-05-07 20:18:17 +02:00
Juergen Hoeller 783cb2c438 StringUtils.commaDelimitedListToSet/removeDuplicateStrings preserves original order
Issue: SPR-12003
2015-05-07 16:02:48 +02:00
Juergen Hoeller b90085500d Revert introduction of isNotEmpty aliases
Issue: SPR-12009
2015-05-07 15:54:55 +02:00
Juergen Hoeller db80378dbe Avoid infinite loop in PatternMatchUtils
Issue: SPR-12971
2015-05-07 15:41:40 +02:00
Juergen Hoeller 2c043ec9d7 Fix for ASM issue 317555
Issue: SPR-12957
2015-05-07 15:41:24 +02:00
Sam Brannen 401bcd4a8a Polish Javadoc for AnnotatedElementUtils 2015-05-07 14:01:02 +02:00
Sam Brannen 7a690df925 Remove trailing whitespace from Java source code 2015-05-06 20:08:42 +02:00
Sam Brannen 6db8f24aaf Polish AnnotatedElementUtils[Tests]
Issue: SPR-11514
2015-05-06 18:48:26 +02:00
Sam Brannen 270308dfd9 Document "get vs. find" semantics in AnnotatedElementUtils
Issue: SPR-11514
2015-05-06 18:29:26 +02:00
Sam Brannen 5c0f98aea4 Document & test AnnotatedElementUtils.getAllAnnotationAttributes
Issue: SPR-11514
2015-05-06 15:55:37 +02:00
Sam Brannen 9eb3518583 Introduce tests for AnnotatedElementUtils.isAnnotated()
Issue: SPR-11514
2015-05-06 14:07:07 +02:00
Sam Brannen e2158d75de Improve documentation of AnnotatedElementUtils.Processor
Issue: SPR-11514
2015-05-06 14:07:07 +02:00
Sam Brannen 5d67219a4e Eliminate inspection of annotations on core Java annotations
This commit picks up where SPR-11483 left off, with the goal of
eliminating all unnecessary inspection of core JDK annotations in
Spring's annotation search algorithms in AnnotatedElementUtils and
AnnotationMetadataReadingVisitor.

Issue: SPR-12989
2015-05-06 00:17:12 +02:00
Sam Brannen ba84458c65 Overhaul AnnotatedElementUtils
- Methods which search for a specific annotation now properly ensure
   that the sought annotation was actually found.

 - Both the "get" and the "find" search algorithms no longer needlessly
   traverse meta-annotation hierarchies twice.

 - Both the "get" and the "find" search algorithms now properly
   increment the metaDepth when recursively searching within the
   meta-annotation hierarchy.

 - Redesigned getMetaAnnotationTypes() so that it doesn't needlessly
   search irrelevant annotations.

 - Documented and tested hasMetaAnnotationTypes().

 - Documented isAnnotated().

Issue: SPR-11514
2015-05-05 23:35:00 +02:00
Sam Brannen efce40c391 Polish internal Javadoc for AnnotatedElementUtils
Issue: SPR-11514
2015-05-04 14:15:16 +02:00
Sam Brannen bb1886c5a8 Enable AbstractStaxHandlerTestCase to run w/o Internet connection 2015-05-02 23:23:51 +02:00
Sam Brannen e56363737b Make findAnnotationAttributes power search private 2015-05-02 10:38:31 +02:00
Sam Brannen 7ef9ac7a4d Document & test status quo for getMetaAnnotationTypes()
This commit documents the status quo for the getMetaAnnotationTypes()
method in AnnotatedElementUtils and adds appropriate regression tests to
AnnotatedElementUtilsTests.

In addition, this commit also introduces a SimpleAnnotationProcessor
base class in AnnotatedElementUtils.

Issue: SPR-11514
2015-04-26 21:13:19 +02:00
Sam Brannen 99cc7d56ff Document return values in AnnotatedElementUtils
This commit documents return values throughout AnnotatedElementUtils and
improves the documentation for the internal Processor API.

Issue: SPR-11514
2015-04-26 03:00:39 +02:00
Sam Brannen 91e46cf2ad Update TODOs in AnnotatedElementUtils[Tests]
Issue: SPR-12738
2015-04-24 23:05:29 +02:00
Sam Brannen 25187eeb0d Document AnnotatedElementUtils & assert preconditions
This commit consistently documents the 'element' and 'annotationType'
method arguments throughout AnnotatedElementUtils.

In addition, this commit introduces assertions against preconditions
for all 'element' and 'annotationType' method arguments.

Issue: SPR-11514
2015-04-24 22:36:36 +02:00
Juergen Hoeller 49f3046f66 PathMatchingResourcePatternResolver skips invalid jar classpath entries
Issue: SPR-12928
2015-04-24 17:40:13 +02:00
Stephane Maldini 74c0250525 Upgrade to Reactor 2
Issue: SPR-12599
2015-04-24 07:18:42 -04: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 ececf32c05 Revert unintentional change in AnnotationUtils 2015-04-23 17:28:47 +02:00
Sam Brannen b723dcebba Polish inline documentation in AnnotatedElementUtils 2015-04-23 17:28:47 +02:00
Sam Brannen 7f0f04dfe3 Support annotations on interfaces in AnnotatedElementUtils
This commit introduces support in AnnotatedElementUtils for finding
annotations declared on interfaces at the type level.

NB: this commit does not include support for finding annotations
declared on interface methods.

In order to maintain backward compatibility with @Transactional
annotation attribute processing, a new getAnnotationAttributes() method
has been added to AnnotatedElementUtils that provides a flag to control
whether interfaces should be searched.
SpringTransactionAnnotationParser and JtaTransactionAnnotationParser
have been updated accordingly to ensure that interfaces are not
unintentionally searched in the @Transactional resolution process.

This commit also introduces additional tests and updates TODOs for
SPR-12738.

Issue: SPR-12944, SPR-12738
2015-04-23 01:33:37 +02:00
Sam Brannen 9b7fd8be4d Polish Javadoc for AnnotationUtils 2015-04-23 01:21:27 +02:00
Sam Brannen 9c6d4b7848 Assert status quo for interface support in AnnotationUtils 2015-04-23 01:19:49 +02:00
Sam Brannen b9b0b78fa1 Support n meta-annotation levels on methods in AnnotationUtils
Prior to this commit, the search algorithm used by the
findAnnotation(Method, Class) method in AnnotationUtils only found
direct annotations or direct meta-annotations (i.e., one level of
meta-annotations).

This commit reworks the search algorithm so that it supports arbitrary
levels of meta-annotations on methods. To make this possible, a new
findAnnotation(AnnotatedElement, Class) method has been introduced in
AnnotationUtils.

This fix also allows for the @Ignore'd tests in
TransactionalEventListenerTests to be re-enabled.

Issue: SPR-12941
2015-04-22 02:26:24 +02:00
Sam Brannen 666d1cecc8 Fix broken test in AnnotationUtilsTests 2015-04-21 21:06:47 +02:00
Sam Brannen 19a75f2c66 Document meta-annotation support in AnnotationUtils
Issue: SPR-12940
2015-04-21 19:54:48 +02:00
Sam Brannen ed88b7fe08 Reorganize tests in AnnotationUtilsTests for greater clarity 2015-04-21 19:54:48 +02:00
Sam Brannen dba48a1ff5 Isolate thrown exception in AssertTests 2015-04-14 20:42:23 +02:00
Sam Brannen fefbd8f85b Polish Javadoc for StringUtils and Assert 2015-04-14 20:05:56 +02:00
Sam Brannen 47f8d435e6 Introduce isNotEmpty() aliases in StringUtils
This commit introduces isNotEmpty() aliases for the existing hasLength()
methods in StringUtils.

Issue: SPR-12909
2015-04-14 20:02:18 +02:00
Arjen Poutsma b119a9c82c FutureAdapter should wrap RuntimeExceptions
RuntimeExceptions thrown from FutureAdapter.adapt() should be wrapped in
an ExecutionException, not thrown as is.

Issue: SPR-12887
2015-04-10 12:52:15 +02:00
Sam Brannen abaf81f1b5 Clean up warnings in DefaultConversionServiceTests 2015-04-07 22:40:06 -04:00
Juergen Hoeller e78b0860df AnnotatedElementUtils leniently ignores TypeNotPresentExceptions (just like AnnotationUtils)
Also refines logIntrospectionFailure to just log at debug level for meta-annotation introspection failures.

Issue: SPR-12889
2015-04-04 00:20:16 +02:00
Juergen Hoeller 514eb4281c Polishing 2015-04-01 17:23:45 +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 1d33fd039a AnnotationUtils.getAnnotationAttributes makes Method accessible (analogous to AnnotationUtils.getValue)
Issue: SPR-12858
2015-03-31 10:28:42 +02:00
Sam Brannen 502fa1796e Polish Javadoc for ClassUtils 2015-03-30 17:34:36 +02:00
Sam Brannen a4af5b8a3e Verify which factory methods are invoked in DefaultConversionServiceTests 2015-03-30 17:34:14 +02:00
Sam Brannen bddc4373fb Refactor ObjectToObjectConverter & improve exception msg
- The exception message now mentions lacking to-Object method as well.

- Documented explicit lacking support for toString() for conversions.

- Introduced dedicated has*() methods for greater clarity and to reduce
  code duplication.

- Static factory methods (i.e., of, from, valueOf) are now supported for
  conversion to a String.
2015-03-30 17:32:59 +02:00
Sam Brannen db96113bcf Polish Javadoc for converters 2015-03-30 16:24:24 +02:00
Sam Brannen 72d7963b30 Polish ConversionService tests
- Now correctly using @Test(expected=...) where appropriate.

- Renamed DefaultConversionTests to DefaultConversionServiceTests.

- Moved all tests related to DefaultConversionService from
  GenericConversionServiceTests to DefaultConversionServiceTests.

- No longer printing to System.out.

- Removed all duplicate instantiation of conversion services.

- Now using Java 8 streams to simplify implementations of custom test
  converters. Also using streams in tests where appropriate.
2015-03-30 15:58:29 +02:00
Juergen Hoeller d23893fd25 Consistent javadoc param declarations for type variables 2015-03-25 00:44:01 +01:00
Juergen Hoeller 22670b7fad Fixed addConverterFactory assertion 2015-03-25 00:42:51 +01:00
Juergen Hoeller 09027f7972 ResolvableType.forRawClass as a straight wrapper for Class.isAssignableFrom
Issue: SPR-12846
2015-03-24 19:20:15 +01:00
Juergen Hoeller 56273a8ff3 Polishing 2015-03-21 01:19:01 +01:00
Arjen Poutsma da48739628 Support byte ranges in ResourceHttpRequestHandler
This commit introduces support for HTTP byte ranges in the
ResourceHttpRequestHandler. This support consists of a number of
changes:

- Parsing of HTTP Range headers in HttpHeaders, using a new HttpRange
  class and inner ByteRange/SuffixByteRange subclasses.
- MIME boundary generation moved from FormHttpMessageConverter to
  MimeTypeUtils.
- writePartialContent() method introduced in ResourceHttpRequestHandler,
  handling the byte range logic
- Additional partial content tests added to
  ResourceHttpRequestHandlerTests.

Issue: SPR-10805
2015-03-20 15:35:43 -04: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
Juergen Hoeller bc6a98c144 Polishing (in particular updating javadoc references to Apache Commons) 2015-03-13 18:19:10 +01:00
Sam Brannen 08c67cf045 Polish AnnotationAwareOrderComparator 2015-03-07 22:35:49 +01:00
Sam Brannen afee546973 Delete unused method in TypeDescriptor 2015-03-07 22:27:11 +01:00
Sam Brannen d90cee78ef Remove trailing whitespace in source code 2015-03-07 21:16:18 +01:00
Juergen Hoeller ff4ac5b837 Collections.unmodifiableMultiValueMap explicitly casts to List<V> (for compatibility with JDK 9 build 53)
Issue: SPR-12549
2015-03-06 11:52:51 +01:00
Juergen Hoeller b541fc9366 Polishing 2015-03-05 18:56:57 +01:00
Juergen Hoeller 1e26d17a3d Preparations for JDK 9
Issue: SPR-12549
2015-03-05 18:56:07 +01:00
Juergen Hoeller 7e8ffc7bf5 CompositePropertySource rejects getPropertyNames call when containing a non-enumerable source
Issue: SPR-12788
2015-03-05 18:53:25 +01:00
Juergen Hoeller f786fc3226 ObjectToOptionalConverter preserves existing Optional instances
Issue: SPR-12785
2015-03-05 18:53:03 +01:00
Juergen Hoeller dcb1145354 Converter interface explicitly documents null values
Issue: SPR-12780
2015-03-05 18:52:38 +01:00
Sam Brannen 93c70b7440 Include charset in EncodedResource.equals()
Prior to this commit, the implementation of equals() in EncodedResource
was based solely on the resource and encoding. Thus, if a Charset were
specified instead of an encoding, invocations of equals() would not
work as expected.

This commit addresses this issue by including the charset in the
implementation of equals() and introducing corresponding tests in a new
EncodedResourceTests class. Furthermore, this commit makes
EncodedResource immutable and updates all Javadoc to reflect support
for the encoding and charset properties.

Issue: SPR-12767
2015-02-28 17:37:02 +01:00
Stephane Nicoll babbf6e871 Harmonize resources location
Issue: SPR-12766
2015-02-28 10:32:40 +01:00
Juergen Hoeller 540d8792fe Fixed javadoc warnings and revised FastByteArrayOutputStream code style 2015-02-27 23:49:55 +01:00
Sam Brannen fe8289b5e3 Implement description consistently across Resources
This commit ensures Resources have consistent, non-empty, meaningful
implementations for getDescription(), thus ensuring that calls to
toString() (e.g., in log statements) no longer return an empty String.

This commit also polishes the Javadoc for various Resource
implementations.
2015-02-27 21:41:37 +01:00
Sam Brannen 088238443b Polish Javadoc for ResourcePropertySource 2015-02-27 21:41:37 +01:00
Sam Brannen 228d9db4d4 Polish StreamConverter(Tests) 2015-02-27 19:27:37 +01:00
Juergen Hoeller 287045ef74 Allow for shared Objenesis caching in ObjenesisCglibAopProxy
Issue: SPR-12755
2015-02-26 18:34:52 +01:00
Juergen Hoeller cc33d3fac8 Polishing 2015-02-25 19:05:06 +01:00
Stephane Nicoll 4ca32d1ce5 polishing 2015-02-24 10:23:16 +01:00
Stephane Nicoll 018adb04f2 Add converter support for Stream
Add StreamConverter to provide full support for converting
java.util.stream.Stream instances to and from collections or arrays.

Also attempt to convert the element type if necessary.

StreamConverter is registered by default in the DefaultConversionService
as long as Java8 is available.

Issue: SPR-12175
2015-02-24 10:17:27 +01:00
Juergen Hoeller 91a0107e4a ResolvableType.getType() returns ParameterizedType when built with forClassWithGenerics
Issue: SPR-12701
2015-02-20 21:53:44 +01:00
Rossen Stoyanchev b94c6fdf7a Add tests for SPR-12738 2015-02-20 13:19:15 -05:00
Stephane Nicoll 1aec6a6cc2 Detect Order on target class as well
Previously, the `@Order` annotation was managed in an inconsistent way
when placed at the implementation level. For simple beans, it was
discovered properly but wasn't for beans requiring a proxy.

OrderComparator.SourceProvider now explicitly allows to return several
order sources; the default implementation returns not only the factory
method (if  any) but also the target class if it happens to be different
from the class of the bean.

Issue: SPR-12636
2015-02-19 09:47:20 +01:00
Juergen Hoeller 0c15a54007 Polishing 2015-02-18 16:45:16 +01:00
Juergen Hoeller 6ebac00f32 @RequestPart supports java.util.Optional
Issue: SPR-12644
2015-02-18 16:17:07 +01:00
Sam Brannen add718d75c Polish EnumerablePropertySource 2015-02-16 20:26:49 +01:00
Juergen Hoeller f58abd3d9a Polishing (forward-ported from 4.1.x) 2015-02-10 23:04:12 +01:00
Juergen Hoeller 058714b03a Polishing 2015-02-10 19:30:59 +01:00
Sam Brannen 6e10f7c8cf Update TODOs for SPR-11598 2015-01-24 18:01:43 +01:00