Skip to content

Support multiple composed annotations on a single annotated element [SPR-13486] #17490

Closed

Description

@spring-projects-issues

Sam Brannen opened SPR-13486 and commented

Status Quo

The findMergedAnnotation*(...) and getMergedAnnotation*(...) methods in AnnotatedElementUtils only support a single target annotation and therefore a single composed annotation.

However, there are certain scenarios for which it would be beneficial to retrieve multiple composed annotations on a single annotated element. As a concrete example, see #18054 which requests support for @Cacheable, @CacheEvict, and CachePut as merged composed annotations.

Deliverables

  1. Introduce support in AnnotatedElementUtils for processing multiple composed annotations above a single annotated element.

Affects: 4.2 GA

Issue Links:

Activity

  1. spring-projects-issues commented on Mar 20, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    Completed as described in the comments for GitHub commit a5139f3:

    Support searches for multiple merged composed annotations

    Prior to this commit it was possible to search for the 1st merged
    annotation above an annotated element. It was also possible to search
    for annotation attributes aggregated from all annotations above an
    annotated element; however, it was impossible to search for all
    composed annotations above an annotated element and have the results as
    synthesized merged annotations instead of a multi-map of attributes.

    This commit introduces a new findAllMergedAnnotations() method in
    AnnotatedElementUtils that finds all annotations of the specified type
    within the annotation hierarchy above the supplied element. For each
    such annotation found, it merges that annotation's attributes with
    matching attributes from annotations in lower levels of the annotation
    hierarchy and synthesizes the results back into an annotation of the
    specified type. All such merged annotations are collected and returned
    as a set.

  2. spring-projects-issues commented on Mar 24, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    Reopening in order to introduce a getAllMergedAnnotations() method in AnnotatedElementUtils that searches using get semantics.

  3. spring-projects-issues commented on Mar 24, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    Added support for "get" search semantics in 1ec35e9

  4. added
    type: enhancement
    in: core
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions