1. 23 2月, 2016 1 次提交
  2. 08 12月, 2015 1 次提交
  3. 05 11月, 2015 2 次提交
  4. 14 10月, 2015 1 次提交
  5. 10 10月, 2015 2 次提交
  6. 31 8月, 2015 1 次提交
  7. 29 8月, 2015 1 次提交
    • S
      Support implicit attribute aliases with @AliasFor · d40a35ba
      Sam Brannen 提交于
      Spring Framework 4.2 introduced support for aliases between annotation
      attributes that fall into the following two categories.
      
      1) Alias pairs: two attributes in the same annotation that use
         @AliasFor to declare that they are explicit aliases for each other.
      2) Meta-annotation attribute overrides: an attribute in one annotation
         uses @AliasFor to declare that it is an explicit override of an
         attribute in a meta-annotation.
      
      However, the existing functionality fails to support the case where two
      attributes in the same annotation both use @AliasFor to declare that
      they are both explicit overrides of the same attribute in the same
      meta-annotation. In such scenarios, one would intuitively assume that
      two such attributes would be treated as "implicit" aliases for each
      other, analogous to the existing support for explicit alias pairs.
      Furthermore, an annotation may potentially declare multiple aliases
      that are effectively a set of implicit aliases for each other.
      
      This commit introduces support for implicit aliases configured via
      @AliasFor through an extensive overhaul of the support for alias
      lookups, validation, etc. Specifically, this commit includes the
      following.
      
      - Introduced isAnnotationMetaPresent() in AnnotationUtils.
      
      - Introduced private AliasDescriptor class in AnnotationUtils in order
        to encapsulate the parsing, validation, and comparison of both
        explicit and implicit aliases configured via @AliasFor.
      
      - Switched from single values for alias names to lists of alias names.
      
      - Renamed getAliasedAttributeName() to getAliasedAttributeNames() in
        AnnotationUtils.
      
      - Converted alias map to contain lists of aliases in AnnotationUtils.
      
      - Refactored the following to support multiple implicit aliases:
        getRequiredAttributeWithAlias() in AnnotationAttributes,
        AbstractAliasAwareAnnotationAttributeExtractor,
        MapAnnotationAttributeExtractor, MergedAnnotationAttributesProcessor
        in AnnotatedElementUtils, and postProcessAnnotationAttributes() in
        AnnotationUtils.
      
      - Introduced numerous tests for implicit alias support, including
        AbstractAliasAwareAnnotationAttributeExtractorTestCase,
        DefaultAnnotationAttributeExtractorTests, and
        MapAnnotationAttributeExtractorTests.
      
      - Updated Javadoc in @AliasFor regarding implicit aliases and in
        AnnotationUtils regarding "meta-present".
      
      Issue: SPR-13345
      d40a35ba
  8. 12 8月, 2015 1 次提交
    • S
      Ensure local aliases don't override meta-annotation · e20b47c3
      Sam Brannen 提交于
      This commit introduces an additional test case to ensure that explicit
      local attribute aliases (configured via @AliasFor) do not accidentally
      override attributes of the same names in meta-annotations (i.e., by
      convention).
      
      Issue: SPR-13325
      e20b47c3
  9. 07 8月, 2015 1 次提交
    • S
      Ensure @AliasFor overrides attribute in correct meta-annotation · c8d604bf
      Sam Brannen 提交于
      Prior to this commit, an explicit override for an attribute in a
      meta-annotation configured via @AliasFor could potentially result in an
      incorrect override of an attribute of the same name but in the wrong
      meta-annotation.
      
      This commit fixes the algorithm in getAliasedAttributeName(Method,
      Class) in AnnotationUtils by ensuring that an explicit attribute
      override is only applied to the configured target meta-annotation
      (i.e., configured via the 'annotation' attribute in @AliasFor).
      
      Issue: SPR-13325
      c8d604bf
  10. 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
  11. 30 5月, 2015 2 次提交
  12. 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
  13. 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
  14. 23 5月, 2015 1 次提交
  15. 22 5月, 2015 2 次提交
    • S
      Polish annotation utility tests · 73170224
      Sam Brannen 提交于
      73170224
    • 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
  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. 07 5月, 2015 1 次提交
  18. 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
  19. 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
  20. 25 4月, 2015 1 次提交
  21. 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
  22. 23 4月, 2015 1 次提交
    • S
      Support annotations on interfaces in AnnotatedElementUtils · 7f0f04df
      Sam Brannen 提交于
      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
      7f0f04df
  23. 21 2月, 2015 1 次提交
  24. 25 1月, 2015 1 次提交
  25. 21 10月, 2014 1 次提交
  26. 26 3月, 2014 1 次提交
    • S
      Don't detect annotations on superclass in StAnMeta · a2f1169e
      Sam Brannen 提交于
      Changes introduced in conjunction with issue SPR-11475 altered the
      behavior of StandardAnnotationMetadata such that annotations could be
      detected on superclasses, specifically in the case where the
      AnnotatedElementUtils.getAllAnnotationAttributes() method is invoked to
      obtain multiple annotations of the same type (on the lowest level in the
      class hierarchy), as is the case for @Profile and @Conditional.
      
      This commit partially reverts these changes as follows:
      
       - All methods in AnnotatedElementUtils now set the
         traverseClassHierarchy to false, thereby effectively reverting the
         changes made in commit 1d30bf83.
         Note, however, that the changes made to AnnotationUtils remain in
         place.
      
       - Introduced tests in AnnotationMetadataTests that verify behavior
         present in Spring Framework 4.0.2 and earlier.
      
       - Updated tests in AnnotatedElementUtilsTests so that they pass against
         the reverted changes (i.e., align with the behavior present in Spring
         Framework 4.0.2 and earlier).
      
       - Refined Javadoc in AnnotationMetadata with regard to annotations
         being "present" vs. "defined".
      
       - Refined Javadoc in AnnotatedTypeMetadata.
      
      Issue: SPR-11475, SPR-11595
      a2f1169e
  27. 26 2月, 2014 2 次提交
    • S
      Favor 'local' annotations over inherited ones · 1d30bf83
      Sam Brannen 提交于
      Prior to this commit, the implementations of findAnnotation() in
      AnnotationUtils and getAnnotationAttributes() in AnnotatedElementUtils
      favored inherited annotations and inherited composed annotations over
      composed annotations that are declared closer to the starting class
      passed to these methods.
      
      This commit addresses this issue as follows:
      
      - Refactored AnnotationUtils to use getDeclaredAnnotation() and
        getDeclaredAnnotations() instead of getAnnotation() and
        getAnnotations() where appropriate.
      
      - AnnotatedElementUtils.doProcess() supports a traverseClassHierarchy
        flag to control whether the class hierarchy should be traversed,
        using getDeclaredAnnotations() instead of getAnnotations() if the
        flag is true.
      
      - Overhauled Javadoc in AnnotatedElementUtils.
      
      Issue: SPR-11475
      1d30bf83
    • S
      Do not inspect meta-annotations on Java annotations · 979c4833
      Sam Brannen 提交于
      This commit introduces a new isInJavaLangAnnotationPackage(Annotation)
      method in AnnotationUtils. This method is now used in AnnotationUtils,
      AnnotatedElementUtils, and MetaAnnotationUtils to ensure that search
      algorithms do no search for meta-annotations on annotations in the
      "java.lang.annotation" package.
      
      The following are some empirical results from this change:
      
      - The number of times that the findAnnotation(Class,Class,Set) method in
        AnnotationUtils is recursively invoked while executing
        AnnotationUtilsTests drops from 51 to 29.
      
      - The number of times that the process(AnnotatedElement) method in
        AnnotationUtils.AnnotationCollector is recursively invoked while
        executing AnnotationUtilsTests.getRepeatableFromMethod() drops
        from 16 to 2.
      
      - The number of times that the doProcess() method in
        AnnotatedElementUtils is recursively invoked while executing the
        "getAnnotationAttributes() On MetaCycleAnnotatedClass with missing
        target meta-annotation" test in AnnotatedElementUtilsTests drops
        from 23 to 5.
      
      - The number of times that the findAnnotationDescriptor(Class,Set,Class)
        method in MetaAnnotationUtils is recursively invoked while executing
        the "findAnnotationDescriptor() on MetaCycleAnnotatedClass with
        missing target meta-annotation" test in MetaAnnotationUtilsTests drops
        from 16 to 8.
      
      Issue: SPR-11483
      979c4833
  28. 24 2月, 2014 1 次提交