Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
spring-projects-issues opened this issue Sep 22, 2015 · 3 comments
Closed
1 task done
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Sep 22, 2015

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:

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 20, 2016

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.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 24, 2016

Sam Brannen commented

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

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 24, 2016

Sam Brannen commented

Added support for "get" search semantics in 1ec35e9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants