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

Allow annotation to be synthesized from a map with minimal attributes [SPR-13087] #17678

Closed
1 task done
spring-projects-issues opened this issue May 31, 2015 · 1 comment
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 May 31, 2015

Sam Brannen opened SPR-13087 and commented

Status Quo

#17659 introduced support for synthesizing an annotation from a Map (or AnnotationAttributes). This initial support also validates the supplied map and requires that it "must contain key-value pairs for every attribute defined by the supplied annotationType."

The validation that MapAnnotationAttributeExtractor currently performs was implemented in order to support Spring's internal use case of synthesizing an annotation from merged AnnotationAttributes (as created by AnnotatedElementUtils), and for that use case it is in fact an error if any attributes defined by the annotation are not present (including aliased attributes).

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. See the discussion in this Spring Integration pull request for an example.

Deliverables

  1. Refine the validation mechanism in MapAnnotationAttributeExtractor so that a reduced set of attributes may be supplied.
    • If an attribute is missing it should be set either to value of its alias (if an alias value exists) or to the value of the attribute's default value (if defined), and otherwise an exception should be thrown.

Affects: 4.2 RC2

Issue Links:

  • INT-3723 Fix IntegrationRequestMappingHandlerMapping according to the latest Spring Framework changes

Referenced from: commits d0c0d9f, ece12f9

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jun 19, 2015

Sam Brannen commented

Completed as described in GitHub commit ece12f9:

Synthesize annotation from map w/ minimal attributes

The initial support for synthesizing an annotation from a Map (or
AnnotationAttributes) introduced in #17659 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.

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.2 RC2 milestone Jan 11, 2019
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