1. 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
  2. 27 5月, 2015 1 次提交
    • 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
  3. 24 5月, 2015 9 次提交
  4. 23 5月, 2015 3 次提交
  5. 22 5月, 2015 1 次提交
    • 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
  6. 20 5月, 2015 1 次提交
  7. 15 5月, 2015 1 次提交
    • S
      Document "present" terminology in AnnotationUtils · 477d4c51
      Sam Brannen 提交于
      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
      477d4c51
  8. 13 5月, 2015 1 次提交
    • S
      Document search scope in Ann*[Element]Utils · 52153bd4
      Sam Brannen 提交于
      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
      52153bd4
  9. 06 5月, 2015 1 次提交
    • 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
  10. 24 4月, 2015 1 次提交
    • S
      Support abstract, bridge, & interface methods in AnnotatedElementUtils · ad6bea1c
      Sam Brannen 提交于
      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
      ad6bea1c
  11. 23 4月, 2015 2 次提交
  12. 22 4月, 2015 2 次提交
    • S
      Support n meta-annotation levels on methods in AnnotationUtils · b9b0b78f
      Sam Brannen 提交于
      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
      b9b0b78f
    • S
      Document meta-annotation support in AnnotationUtils · 19a75f2c
      Sam Brannen 提交于
      Issue: SPR-12940
      19a75f2c
  13. 04 4月, 2015 1 次提交
  14. 31 3月, 2015 1 次提交
  15. 20 1月, 2015 1 次提交
  16. 08 1月, 2015 1 次提交
  17. 02 12月, 2014 1 次提交
  18. 29 10月, 2014 1 次提交
  19. 21 10月, 2014 2 次提交
  20. 08 8月, 2014 1 次提交
  21. 02 8月, 2014 1 次提交
  22. 01 7月, 2014 1 次提交
  23. 27 6月, 2014 1 次提交
  24. 24 6月, 2014 2 次提交
  25. 30 4月, 2014 2 次提交