1. 20 6月, 2015 2 次提交
    • S
      Polishing · 27d1ce84
      Sam Brannen 提交于
      27d1ce84
    • S
      Honor contract of @Repeatable in AnnotationUtils · fb83e83e
      Sam Brannen 提交于
      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
      fb83e83e
  2. 19 6月, 2015 2 次提交
    • S
      Clean up warnings and polish tests · 23547a72
      Sam Brannen 提交于
      23547a72
    • S
      Synthesize annotation from map w/ minimal attributes · ece12f9d
      Sam Brannen 提交于
      The initial support for synthesizing an annotation from a Map (or
      AnnotationAttributes) introduced in SPR-13067 required that the map
      contain key-value pairs for every attribute defined by the supplied
      annotationType. However, there are use cases that would benefit from
      being able to supply a reduced set of attributes and still have the
      annotation synthesized properly.
      
      This commit refines the validation mechanism in
      MapAnnotationAttributeExtractor so that a reduced set of attributes may
      be supplied. Specifically, if an attribute is missing in the supplied
      map the attribute will be set either to value of its alias (if an alias
      value configured via @AliasFor exists) or to the value of the
      attribute's default value (if defined), and otherwise an exception will
      be thrown.
      
      Furthermore, TransactionalTestExecutionListener has been refactored to
      take advantage of this new feature by synthesizing an instance of
      @TransactionConfiguration solely from the default values of its
      declared attributes.
      
      Issue: SPR-13087
      ece12f9d
  3. 14 6月, 2015 1 次提交
    • S
      Revise method and parameter names in annotation support · 32c17bf5
      Sam Brannen 提交于
      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
      32c17bf5
  4. 13 6月, 2015 1 次提交
  5. 09 6月, 2015 1 次提交
    • S
      Add ResolvableTypeProvider · b87816ed
      Stephane Nicoll 提交于
      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
      b87816ed
  6. 05 6月, 2015 1 次提交
  7. 04 6月, 2015 1 次提交
  8. 30 5月, 2015 3 次提交
  9. 29 5月, 2015 1 次提交
    • S
      Synthesize annotation from a map of attributes · e30c9b2e
      Sam Brannen 提交于
      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
      e30c9b2e
  10. 27 5月, 2015 3 次提交
    • S
      Ensure synthesized nested annotation arrays retain correct type · f41de12c
      Sam Brannen 提交于
      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
      f41de12c
    • S
      Support nested annotations in AnnotationAttributes · a2f152ce
      Sam Brannen 提交于
      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
      a2f152ce
    • S
      Document public API in AnnotationAttributes · 0ac0e2ce
      Sam Brannen 提交于
      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
      0ac0e2ce
  11. 24 5月, 2015 3 次提交
  12. 23 5月, 2015 1 次提交
  13. 22 5月, 2015 5 次提交
    • S
      Polish annotation utility tests · 73170224
      Sam Brannen 提交于
      73170224
    • S
      Verify that SynthesizedAnnotation must be public · e7ea9256
      Sam Brannen 提交于
      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
      e7ea9256
    • J
      ByteBufferConverter explicitly declares applicability to byte[] · 792b7b9d
      Juergen Hoeller 提交于
      Includes an optimization for simple ByteBuffer duplication.
      
      Issue: SPR-13056
      792b7b9d
    • S
      Polish · 27c435c4
      Stephane Nicoll 提交于
      27c435c4
    • S
      Support annotation attribute aliases and overrides via @AliasFor · ca66e076
      Sam Brannen 提交于
      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
      ca66e076
  14. 18 5月, 2015 1 次提交
  15. 15 5月, 2015 1 次提交
    • S
      Harmonize default converters · 0612bc7b
      Stephane Nicoll 提交于
      Provide Converter implementations for Charset, Currency and TimeZone as
      related PropertyEditors are available for those.
      
      Issue: SPR-13020
      0612bc7b
  16. 13 5月, 2015 1 次提交
    • S
      Favor local, composed annotations in AnnotatedElementUtils · ebed52cc
      Sam Brannen 提交于
      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
      ebed52cc
  17. 12 5月, 2015 1 次提交
  18. 10 5月, 2015 1 次提交
  19. 08 5月, 2015 2 次提交
    • S
      Support arbitrary levels of meta-annotations in TypeDescriptor · 04d6afe5
      Sam Brannen 提交于
      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
      04d6afe5
    • J
      Polishing · dbd82d12
      Juergen Hoeller 提交于
      dbd82d12
  20. 07 5月, 2015 2 次提交
  21. 06 5月, 2015 4 次提交
    • S
      Document & test AnnotatedElementUtils.getAllAnnotationAttributes · 5c0f98ae
      Sam Brannen 提交于
      Issue: SPR-11514
      5c0f98ae
    • S
      Introduce tests for AnnotatedElementUtils.isAnnotated() · 9eb35185
      Sam Brannen 提交于
      Issue: SPR-11514
      9eb35185
    • S
      Eliminate inspection of annotations on core Java annotations · 5d67219a
      Sam Brannen 提交于
      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
      5d67219a
    • S
      Overhaul AnnotatedElementUtils · ba84458c
      Sam Brannen 提交于
       - 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
      ba84458c
  22. 27 4月, 2015 1 次提交
    • S
      Document & test status quo for getMetaAnnotationTypes() · 7ef9ac7a
      Sam Brannen 提交于
      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
      7ef9ac7a
  23. 25 4月, 2015 1 次提交