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 JAX-RS Annotation Inheritance #1098

Merged
merged 8 commits into from
Dec 6, 2019

Conversation

tylerbenson
Copy link
Contributor

@tylerbenson tylerbenson commented Nov 15, 2019

This pull request add support for jax-rs annotations on a parent class or interface.

1. ByteBuddy ElementMatcher
hasSuperMethod is a new ElementMatcher that matches on a method or its definitions in any superclass or interface. This allows ByteBuddy to match a JAX-RS annotation on an implemented interface or superclass rather than just the concrete class. The performance impact should be minimal because the TypeMatcher for the instrumentation has to match first anyway. The TypeMatcher is unchanged.

2. A class hierarchy iterator
A deterministic iterator that walks a class's supertypes and implemented interfaces in a breadth-first manner.

3. Resource naming using the iterator
In JaxRsAnnotationsDecorator, we use the iterator to find the @Path annotation on the class as well as the relevant @Path and HttpMethod annotations on the method.

4. Updated Tests
Some new tests were added and previous tests updated to account for annotations at different levels of the hierarchy. Some old tests were incorrect in that they didn't account for annotation inheritance. Additionally, the commented-out tests that relied on Java 8 were manually checked to ensure no regressions versus #1061

@randomanderson randomanderson force-pushed the tyler/jax-rs-annotation-inheritance branch from 6619e4d to aa46e81 Compare November 20, 2019 20:38
@randomanderson randomanderson changed the title Add more complexity to jersey resource test Support JAX-RS Annotation Inheritance Nov 21, 2019
@randomanderson randomanderson marked this pull request as ready for review November 21, 2019 17:48
@randomanderson randomanderson requested a review from a team as a code owner November 21, 2019 17:48
Copy link
Contributor

@dougqh dougqh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

I think we're likely to optimize the matching process later.
But for now, JAX-RS supports inheritance in its semantics, so I think we should, too.

@randomanderson randomanderson merged commit d2db6b6 into master Dec 6, 2019
Copy link
Contributor

@devinsba devinsba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is definitely room for optimization (not traversing the tree excessively) but I don't see anything that should block getting this into users hands.

* <p>6. Superclass's superclass
*
* <p>...
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to reference where in jax-rs this precedence order can be found since presumably this follows that implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants