-
Notifications
You must be signed in to change notification settings - Fork 123
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
Enhancement Proposal: ResourceInfo.getAnnotation(Class annotationClass) #1292
Comments
Kindly asking for more opinions, in particular from committers. If nobody vetos |
There had been not upfront vetos, so I assume everybody is fine with adopting this enhancement. If not, please clearly tell me NOW. Thanks. |
When moving to CDI, I hope the annotation operations can be by CDI utilities directly. Currently, almost every spec has some util to handle the reflection-related operations. |
Should there ba a |
@mkarg Thanks for bringing this up. I like the idea. We actually had to reimplement the annotation inheritance rules for the MVC spec implementation as well. So +1 for this idea. Just one though: Shouldn't it be
I personally don't see a real benefit of having these. Especially separate ones for class- and method-level annotations. |
Never had the actual need this separation. |
Correct, I |
As nobody vetoed, I have sketched a first draft. I think it makes sense to continue our discussion there. |
I hereby propose the addition of the following method:
public <A extends Annotation> A ResourceInfo.getResourceAnnotation(Class<A> annotationClass)
The idea is that this method returns the annotation instance of the given
annotationClass
with full respect to the rules found in spec chapter 3.6. This effectively means, this method returns either the super class annotation, or the interface annotation, or the resource class annotation, or the resource method annotation, depending on whether any JAX-RS annotation is found in the particular deeper levels.The benefit of this method is that there is no need for filters / interceptors to re-implement this algorithm again and again for custom annotations, in case the annotation author wants to apply the same rules as found in chapter 3.6 (hence: the new annotation shall "look and feel" like an official JAX-RS annotation). Implementations could make the already existing algorithm publicly available here, so it is guaranteed that the exact same treatment happens for custom annotations and for official annotations.
The text was updated successfully, but these errors were encountered: